org.apache.cassandra.db.marshal.TimeUUIDType Java Examples

The following examples show how to use org.apache.cassandra.db.marshal.TimeUUIDType. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CellValidatorTest.java    From deep-spark with Apache License 2.0 6 votes vote down vote up
public void testValidatorClassToKind() {
    assertEquals(Kind.validatorClassToKind(null), Kind.NOT_A_COLLECTION);
    assertEquals(Kind.validatorClassToKind(TimeUUIDType.class), Kind.NOT_A_COLLECTION);
    assertEquals(Kind.validatorClassToKind(UTF8Type.class), Kind.NOT_A_COLLECTION);
    assertEquals(Kind.validatorClassToKind(Int32Type.class), Kind.NOT_A_COLLECTION);

    assertEquals(Kind.validatorClassToKind(BooleanType.class), Kind.NOT_A_COLLECTION);
    assertEquals(Kind.validatorClassToKind(TimestampType.class), Kind.NOT_A_COLLECTION);
    assertEquals(Kind.validatorClassToKind(DecimalType.class), Kind.NOT_A_COLLECTION);
    assertEquals(Kind.validatorClassToKind(LongType.class), Kind.NOT_A_COLLECTION);
    assertEquals(Kind.validatorClassToKind(DoubleType.class), Kind.NOT_A_COLLECTION);

    assertEquals(Kind.validatorClassToKind(FloatType.class), Kind.NOT_A_COLLECTION);
    assertEquals(Kind.validatorClassToKind(InetAddressType.class), Kind.NOT_A_COLLECTION);
    assertEquals(Kind.validatorClassToKind(IntegerType.class), Kind.NOT_A_COLLECTION);
    assertEquals(Kind.validatorClassToKind(UUIDType.class), Kind.NOT_A_COLLECTION);

    assertEquals(Kind.validatorClassToKind(SetType.class), Kind.SET);
    assertEquals(Kind.validatorClassToKind(ListType.class), Kind.LIST);
    assertEquals(Kind.validatorClassToKind(MapType.class), Kind.MAP);
}
 
Example #2
Source File: CassandraTypeConverterTest.java    From debezium-incubator with Apache License 2.0 5 votes vote down vote up
@Test
public void testTimeUUID() {
    DataType timeUUID = DataType.timeuuid();
    AbstractType<?> convertedType = CassandraTypeConverter.convert(timeUUID);

    TimeUUIDType expectedType = TimeUUIDType.instance;

    Assert.assertEquals(expectedType, convertedType);
}
 
Example #3
Source File: CassandraTypeDeserializerTest.java    From debezium-incubator with Apache License 2.0 5 votes vote down vote up
@Test
public void testTimeUUIDType() {
    UUID timeUUID = UUID.randomUUID();
    String expectedFixedUUID = Values.convertToString(CassandraTypeKafkaSchemaBuilders.UUID_TYPE, UuidUtil.asBytes(timeUUID));

    ByteBuffer serializedTimeUUID = TimeUUIDType.instance.decompose(timeUUID);

    Object deserializedTimeUUID = CassandraTypeDeserializer.deserialize(TimeUUIDType.instance, serializedTimeUUID);

    Assert.assertEquals(expectedFixedUUID, deserializedTimeUUID);
}
 
Example #4
Source File: UUIDTest.java    From titan1withtp3.1 with Apache License 2.0 5 votes vote down vote up
@Test
public void timeUUIDComparison() {
    TimeUUIDType ti = TimeUUIDType.instance;

    UUID zu = UUID.fromString(z);
    UUID vu = UUID.fromString(v);

    ByteBuffer zb = ti.decompose(zu);
    ByteBuffer vb = ti.decompose(vu);

    assertEquals(-1, ti.compare(zb, vb));
    assertEquals(1, zu.compareTo(vu));
    assertEquals(1, ti.compare(vb, zb));
    assertEquals(-1, vu.compareTo(zu));
}
 
Example #5
Source File: ColumnMapperUUIDTest.java    From stratio-cassandra with Apache License 2.0 5 votes vote down vote up
@Test
public void testSortTimeUUIDsAsNative() {
    List<UUID> uuids = toList("24f340bc-89da-11e4-b116-123b93f75cba",
                              "24f34328-89da-11e4-b116-123b93f75cba",
                              "24f34486-89da-11e4-b116-123b93f75cba",
                              "24f3465c-89da-11e4-b116-123b93f75cba",
                              "24f3481e-89da-11e4-b116-123b93f75cba",
                              "24f3481e-89da-11e4-b116-123b93f75cba",
                              "24f3495e-89da-11e4-b116-123b93f75cba",
                              "24f34a8a-89da-11e4-b116-123b93f75cba",
                              "24f34bb6-89da-11e4-b116-123b93f75cba",
                              "24f34ce2-89da-11e4-b116-123b93f75cba",
                              "24f34e0e-89da-11e4-b116-123b93f75cba");
    testSort(uuids, TimeUUIDType.instance);
}
 
Example #6
Source File: CassandraServer.java    From stratio-cassandra with Apache License 2.0 4 votes vote down vote up
public ByteBuffer trace_next_query() throws TException
{
    UUID sessionId = UUIDGen.getTimeUUID();
    state().getQueryState().prepareTracingSession(sessionId);
    return TimeUUIDType.instance.decompose(sessionId);
}
 
Example #7
Source File: Tracing.java    From stratio-cassandra with Apache License 2.0 4 votes vote down vote up
public UUID newSession()
{
    return newSession(TimeUUIDType.instance.compose(ByteBuffer.wrap(UUIDGen.getTimeUUIDBytes())));
}
 
Example #8
Source File: TimeUUIDs.java    From stratio-cassandra with Apache License 2.0 4 votes vote down vote up
public TimeUUIDs(String name, GeneratorConfig config)
{
    super(TimeUUIDType.instance, config, name, UUID.class);
    dateGen = new Dates(name, config);
    clockSeqAndNode = config.salt;
}
 
Example #9
Source File: CqlTableDataTypeTest.java    From stratio-cassandra with Apache License 2.0 4 votes vote down vote up
private void cqlTableTest(String initialQuery) throws IOException
{
    pig.registerQuery(initialQuery);
    Iterator<Tuple> it = pig.openIterator("rows");
    //{key: int, 
    //col_ascii: chararray, 
    //col_bigint: long, 
    //col_blob: bytearray, 
    //col_boolean: bytearray,
    //col_decimal: chararray, 
    //col_double: double, 
    //col_float: float, 
    //col_inet: chararray, 
    //col_int: int,
    //col_text: chararray, 
    //col_timestamp: long, 
    //col_timeuuid: bytearray, 
    //col_uuid: chararray,
    //col_varchar: chararray, 
    //col_varint: int}
    if (it.hasNext()) {
        Tuple t = it.next();
        Assert.assertEquals(t.get(0), 1);
        Assert.assertEquals(t.get(1), "ascii");
        Assert.assertEquals(t.get(2), 12345678L);
        Assert.assertEquals(t.get(3), new DataByteArray(Hex.hexToBytes("23446c6c6f")));
        Assert.assertEquals(t.get(4), false);
        Assert.assertEquals(t.get(5), "23.4567");
        Assert.assertEquals(t.get(6), 12345678.12345678d);
        Assert.assertEquals(t.get(7), 123.12f);
        Assert.assertEquals(t.get(8), "127.0.0.1");
        Assert.assertEquals(t.get(9), 123);
        Assert.assertEquals(t.get(10), "text");
        Assert.assertEquals(t.get(11), 1296705900000L);
        Assert.assertEquals(t.get(12), new DataByteArray((TimeUUIDType.instance.fromString("e23f450f-53a6-11e2-7f7f-7f7f7f7f7f7f").array())));
        Assert.assertEquals(t.get(13), new DataByteArray((UUIDType.instance.fromString("550e8400-e29b-41d4-a716-446655440000").array())));
        Assert.assertEquals(t.get(14), "varchar");
        Assert.assertEquals(t.get(15), 123);
    }
    else
    {
        Assert.fail("Failed to get data for query " + initialQuery);
    }
}