Skip to content

Remove cassandra-all #6

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Mar 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 6 additions & 20 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>com.ing.data</groupId>
<artifactId>cassandra-jdbc-wrapper</artifactId>
<version>4.5.0</version>
<version>4.5.1</version>
<packaging>jar</packaging>

<name>Cassandra JDBC Wrapper</name>
Expand Down Expand Up @@ -76,10 +76,10 @@
<java.version>1.8</java.version>

<!-- Versions for dependencies -->
<cassandra-all.version>3.11.9</cassandra-all.version>
<checkstyle.version>8.45.1</checkstyle.version>
<commons-lang3.version>3.12.0</commons-lang3.version>
<datastax.java.driver.version>4.13.0</datastax.java.driver.version>
<guava-version>18.0</guava-version>
<datastax.java.driver.version>4.14.0</datastax.java.driver.version>
<libthrift.version>0.13.0</libthrift.version>
<!-- Versions for test dependencies -->
<achilles-embedded.version>6.0.4</achilles-embedded.version>
Expand Down Expand Up @@ -108,23 +108,9 @@
</dependency>

<dependency>
<groupId>org.apache.cassandra</groupId>
<artifactId>cassandra-all</artifactId>
<version>${cassandra-all.version}</version>
<!-- Exclude vulnerable dependencies -->
<exclusions>
<!-- The version of libthrift is overridden below. -->
<exclusion>
<groupId>org.apache.thrift</groupId>
<artifactId>libthrift</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- Force the use of a more recent version of libthrift. -->
<dependency>
<groupId>org.apache.thrift</groupId>
<artifactId>libthrift</artifactId>
<version>${libthrift.version}</version>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>${guava-version}</version>
</dependency>

<!-- Apache Commons Lang 3 -->
Expand Down
87 changes: 87 additions & 0 deletions src/main/java/com/ing/data/cassandra/jdbc/ByteBufferUtil.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
/*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.ing.data.cassandra.jdbc;

import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;

/**
* Partial copy of org.apache.cassandra.utils.ByteBufferUtil
*
*/
public class ByteBufferUtil {
public static ByteBuffer bytes(String s) {
return ByteBuffer.wrap(s.getBytes(StandardCharsets.UTF_8));
}


public static ByteBuffer bytes(byte b) {
return ByteBuffer.allocate(1).put(0, b);
}

public static ByteBuffer bytes(short s) {
return ByteBuffer.allocate(2).putShort(0, s);
}

public static ByteBuffer bytes(int i) {
return ByteBuffer.allocate(4).putInt(0, i);
}

public static ByteBuffer bytes(long n) {
return ByteBuffer.allocate(8).putLong(0, n);
}

public static ByteBuffer bytes(float f) {
return ByteBuffer.allocate(4).putFloat(0, f);
}

public static ByteBuffer bytes(double d) {
return ByteBuffer.allocate(8).putDouble(0, d);
}

public static int toInt(ByteBuffer bytes) {
return bytes.getInt(bytes.position());
}

public static short toShort(ByteBuffer bytes) {
return bytes.getShort(bytes.position());
}

public static long toLong(ByteBuffer bytes) {
return bytes.getLong(bytes.position());
}

public static float toFloat(ByteBuffer bytes) {
return bytes.getFloat(bytes.position());
}

public static double toDouble(ByteBuffer bytes) {
return bytes.getDouble(bytes.position());
}

public static byte[] getArray(ByteBuffer buffer) {
int length = buffer.remaining();
if (buffer.hasArray()) {
int boff = buffer.arrayOffset() + buffer.position();
return Arrays.copyOfRange(buffer.array(), boff, boff + length);
} else {
byte[] bytes = new byte[length];
buffer.duplicate().get(bytes);
return bytes;
}
}

}
7 changes: 3 additions & 4 deletions src/main/java/com/ing/data/cassandra/jdbc/DataTypeEnum.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import com.datastax.oss.protocol.internal.ProtocolConstants.DataType;
import com.google.common.collect.Maps;
import edu.umd.cs.findbugs.annotations.NonNull;
import org.apache.cassandra.db.marshal.CollectionType;

import java.math.BigDecimal;
import java.math.BigInteger;
Expand Down Expand Up @@ -54,9 +53,9 @@ public enum DataTypeEnum {
FLOAT(DataType.FLOAT, Float.class, cqlName(DataTypes.FLOAT)),
INET(DataType.INET, InetAddress.class, cqlName(DataTypes.INET)),
INT(DataType.INT, Integer.class, cqlName(DataTypes.INT)),
LIST(DataType.LIST, List.class, CollectionType.Kind.LIST.name().toLowerCase()),
MAP(DataType.MAP, Map.class, CollectionType.Kind.MAP.name().toLowerCase()),
SET(DataType.SET, Set.class, CollectionType.Kind.SET.name().toLowerCase()),
LIST(DataType.LIST, List.class, "list"),
MAP(DataType.MAP, Map.class, "map"),
SET(DataType.SET, Set.class, "set"),
SMALLINT(DataType.SMALLINT, Short.class, cqlName(DataTypes.SMALLINT)),
TEXT(DataType.VARCHAR, String.class, cqlName(DataTypes.TEXT)),
TIME(DataType.TIME, Time.class, cqlName(DataTypes.TIME)),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import com.datastax.oss.driver.api.core.type.codec.TypeCodec;
import com.datastax.oss.driver.api.core.type.reflect.GenericType;
import edu.umd.cs.findbugs.annotations.NonNull;
import org.apache.cassandra.utils.ByteBufferUtil;
import com.ing.data.cassandra.jdbc.ByteBufferUtil;

import java.math.BigDecimal;
import java.nio.ByteBuffer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import com.datastax.oss.driver.api.core.type.codec.TypeCodec;
import com.datastax.oss.driver.api.core.type.reflect.GenericType;
import edu.umd.cs.findbugs.annotations.NonNull;
import org.apache.cassandra.utils.ByteBufferUtil;
import com.ing.data.cassandra.jdbc.ByteBufferUtil;

import java.nio.ByteBuffer;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import com.datastax.oss.driver.api.core.type.codec.TypeCodec;
import com.datastax.oss.driver.api.core.type.reflect.GenericType;
import edu.umd.cs.findbugs.annotations.NonNull;
import org.apache.cassandra.utils.ByteBufferUtil;
import com.ing.data.cassandra.jdbc.ByteBufferUtil;

import java.nio.ByteBuffer;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import com.datastax.oss.driver.api.core.type.codec.TypeCodec;
import com.datastax.oss.driver.api.core.type.reflect.GenericType;
import edu.umd.cs.findbugs.annotations.NonNull;
import org.apache.cassandra.utils.ByteBufferUtil;
import com.ing.data.cassandra.jdbc.ByteBufferUtil;

import java.nio.ByteBuffer;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import com.datastax.oss.driver.api.core.type.codec.TypeCodec;
import com.datastax.oss.driver.api.core.type.reflect.GenericType;
import edu.umd.cs.findbugs.annotations.NonNull;
import org.apache.cassandra.utils.ByteBufferUtil;
import com.ing.data.cassandra.jdbc.ByteBufferUtil;

import java.nio.ByteBuffer;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import com.datastax.oss.driver.api.core.type.codec.TypeCodec;
import com.datastax.oss.driver.api.core.type.reflect.GenericType;
import edu.umd.cs.findbugs.annotations.NonNull;
import org.apache.cassandra.utils.ByteBufferUtil;
import com.ing.data.cassandra.jdbc.ByteBufferUtil;

import java.nio.ByteBuffer;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import com.datastax.oss.driver.api.core.type.codec.TypeCodec;
import com.datastax.oss.driver.api.core.type.reflect.GenericType;
import edu.umd.cs.findbugs.annotations.NonNull;
import org.apache.cassandra.utils.ByteBufferUtil;
import com.ing.data.cassandra.jdbc.ByteBufferUtil;

import java.nio.ByteBuffer;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import com.datastax.oss.driver.api.core.type.codec.TypeCodec;
import com.datastax.oss.driver.api.core.type.reflect.GenericType;
import edu.umd.cs.findbugs.annotations.NonNull;
import org.apache.cassandra.utils.ByteBufferUtil;
import com.ing.data.cassandra.jdbc.ByteBufferUtil;

import java.nio.ByteBuffer;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import com.datastax.oss.driver.api.core.type.codec.TypeCodec;
import com.datastax.oss.driver.api.core.type.reflect.GenericType;
import edu.umd.cs.findbugs.annotations.NonNull;
import org.apache.cassandra.utils.ByteBufferUtil;
import com.ing.data.cassandra.jdbc.ByteBufferUtil;

import java.nio.ByteBuffer;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import com.datastax.oss.driver.api.core.ProtocolVersion;
import com.datastax.oss.driver.api.core.type.DataTypes;
import com.datastax.oss.driver.api.core.type.reflect.GenericType;
import org.apache.cassandra.utils.ByteBufferUtil;
import com.ing.data.cassandra.jdbc.ByteBufferUtil;
import org.apache.commons.lang3.StringUtils;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
Expand Down