Skip to content
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

Cassandra Reverse Replication - Integration Tests #2155

Merged
Show file tree
Hide file tree
Changes from 12 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
11 changes: 11 additions & 0 deletions v2/spanner-to-sourcedb/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,17 @@
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.beam</groupId>
<artifactId>beam-it-cassandra</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>com.datastax.cassandra</groupId>
<artifactId>cassandra-driver-core</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,11 @@ private interface HandlerSupplier<T> {
private static BigInteger handleCassandraVarintType(Object value) {
if (value instanceof byte[]) {
return new BigInteger((byte[]) value);
} else if (value instanceof ByteBuffer) {
ByteBuffer byteBuffer = (ByteBuffer) value;
byte[] byteArray = new byte[byteBuffer.remaining()];
byteBuffer.get(byteArray);
return new BigInteger(byteArray);
shreyakhajanchi marked this conversation as resolved.
Show resolved Hide resolved
}
return new BigInteger(value.toString());
}
Expand Down Expand Up @@ -166,17 +171,12 @@ private static InetAddress handleCassandraInetAddressType(String inetString) {
* @return a {@link ByteBuffer} object containing the value represented in cassandra type.
*/
private static ByteBuffer parseBlobType(Object colValue) {
byte[] byteArray;

if (colValue instanceof byte[]) {
byteArray = (byte[]) colValue;
} else if (colValue instanceof String) {
byteArray = java.util.Base64.getDecoder().decode((String) colValue);
} else {
throw new IllegalArgumentException("Unsupported type for column");
return ByteBuffer.wrap((byte[]) colValue);
} else if (colValue instanceof ByteBuffer) {
return (ByteBuffer) colValue;
}

return ByteBuffer.wrap(byteArray);
return ByteBuffer.wrap(java.util.Base64.getDecoder().decode((String) colValue));
}

/**
Expand Down Expand Up @@ -331,7 +331,14 @@ private static Object handleSpannerColumnType(
return null;
}
String hexEncodedString = valuesJson.optString(columnName);
return convertBinaryEncodedStringToByteArray(hexEncodedString);
return safeHandle(
() -> {
try {
return safeHandle(() -> convertBinaryEncodedStringToByteArray(hexEncodedString));
shreyakhajanchi marked this conversation as resolved.
Show resolved Hide resolved
} catch (IllegalArgumentException e) {
return parseBlobType(hexEncodedString);
}
});
} else {
return valuesJson.isNull(columnName) ? null : valuesJson.opt(columnName);
}
Expand Down
Loading
Loading