Search in sources :

Example 1 with AttachmentPoint

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();
}
Also used : UserDefinedType(com.datastax.oss.driver.api.core.type.UserDefinedType) UserDefinedTypeBuilder(com.datastax.oss.driver.internal.core.type.UserDefinedTypeBuilder) AttachmentPoint(com.datastax.oss.driver.api.core.detach.AttachmentPoint)

Example 2 with AttachmentPoint

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);
}
Also used : ByteBuffer(java.nio.ByteBuffer) AttachmentPoint(com.datastax.oss.driver.api.core.detach.AttachmentPoint) Test(org.junit.Test)

Example 3 with AttachmentPoint

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());
}
Also used : UserDefinedType(com.datastax.oss.driver.api.core.type.UserDefinedType) UserDefinedTypeBuilder(com.datastax.oss.driver.internal.core.type.UserDefinedTypeBuilder) AttachmentPoint(com.datastax.oss.driver.api.core.detach.AttachmentPoint)

Example 4 with AttachmentPoint

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);
}
Also used : AttachmentPoint(com.datastax.oss.driver.api.core.detach.AttachmentPoint)

Aggregations

AttachmentPoint (com.datastax.oss.driver.api.core.detach.AttachmentPoint)4 UserDefinedType (com.datastax.oss.driver.api.core.type.UserDefinedType)2 UserDefinedTypeBuilder (com.datastax.oss.driver.internal.core.type.UserDefinedTypeBuilder)2 ByteBuffer (java.nio.ByteBuffer)1 Test (org.junit.Test)1