use of com.datastax.oss.driver.api.core.detach.AttachmentPoint in project java-driver by datastax.
the class DefaultUdtValueTest method newInstance.
@Override
protected UdtValue newInstance(List<DataType> dataTypes, AttachmentPoint attachmentPoint) {
UserDefinedTypeBuilder builder = new UserDefinedTypeBuilder(CqlIdentifier.fromInternal("ks"), CqlIdentifier.fromInternal("type"));
for (int i = 0; i < dataTypes.size(); i++) {
builder.withField(CqlIdentifier.fromInternal("field" + i), dataTypes.get(i));
}
UserDefinedType userDefinedType = builder.build();
userDefinedType.attach(attachmentPoint);
return userDefinedType.newValue();
}
use of com.datastax.oss.driver.api.core.detach.AttachmentPoint in project java-driver by datastax.
the class AccessibleByIndexTestBase method should_get_primitive_value_by_index.
@Test
public void should_get_primitive_value_by_index() {
// Given
T t = newInstance(ImmutableList.of(DataTypes.INT), attachmentPoint);
t = t.setBytesUnsafe(0, Bytes.fromHexString("0x00000001"));
// When
int i = t.getInt(0);
// Then
verify(codecRegistry).codecFor(DataTypes.INT, Integer.class);
verify(intCodec).decodePrimitive(any(ByteBuffer.class), eq(ProtocolVersion.DEFAULT));
assertThat(i).isEqualTo(1);
}
use of com.datastax.oss.driver.api.core.detach.AttachmentPoint in project java-driver by datastax.
the class DefaultUdtValueTest method newInstance.
@Override
protected UdtValue newInstance(List<DataType> dataTypes, List<Object> values, AttachmentPoint attachmentPoint) {
UserDefinedTypeBuilder builder = new UserDefinedTypeBuilder(CqlIdentifier.fromInternal("ks"), CqlIdentifier.fromInternal("type"));
for (int i = 0; i < dataTypes.size(); i++) {
builder.withField(CqlIdentifier.fromInternal("field" + i), dataTypes.get(i));
}
UserDefinedType userDefinedType = builder.build();
userDefinedType.attach(attachmentPoint);
return userDefinedType.newValue(values.toArray());
}
use of com.datastax.oss.driver.api.core.detach.AttachmentPoint in project java-driver by datastax.
the class DefaultPagingState method matches.
@Override
public boolean matches(@NonNull Statement<?> statement, @Nullable Session session) {
AttachmentPoint attachmentPoint = (session == null) ? AttachmentPoint.NONE : session.getContext();
byte[] actual = hash(statement, rawPagingState, attachmentPoint);
return Arrays.equals(actual, hash);
}
Aggregations