org.apache.cassandra.db.marshal.UUIDType Java Examples
The following examples show how to use
org.apache.cassandra.db.marshal.UUIDType.
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 |
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: StorageProxy.java From stratio-cassandra with Apache License 2.0 | 6 votes |
private static void asyncRemoveFromBatchlog(Collection<InetAddress> endpoints, UUID uuid) { AbstractWriteResponseHandler handler = new WriteResponseHandler(endpoints, Collections.<InetAddress>emptyList(), ConsistencyLevel.ANY, Keyspace.open(Keyspace.SYSTEM_KS), null, WriteType.SIMPLE); Mutation mutation = new Mutation(Keyspace.SYSTEM_KS, UUIDType.instance.decompose(uuid)); mutation.delete(SystemKeyspace.BATCHLOG_CF, FBUtilities.timestampMicros()); MessageOut<Mutation> message = mutation.createMessage(); for (InetAddress target : endpoints) { if (target.equals(FBUtilities.getBroadcastAddress()) && OPTIMIZE_LOCAL_REQUESTS) insertLocal(message.payload, handler); else MessagingService.instance().sendRR(message, target, handler, false); } }
Example #3
Source File: ColumnMapperUUIDTest.java From stratio-cassandra with Apache License 2.0 | 6 votes |
@Test public void testSortMixedUUIDs() { List<UUID> uuids = toList("520fdc7d-8d62-4c46-a22c-1f6c481f032f", "6a5a5f84-0482-408e-9600-6b7fafaaa9cb", "ece1ff82-c92c-4179-9e7f-0d6349810472", "6c211cca-fbf3-4777-b359-85440e10b1fa", "33b51b24-a2fe-4713-b881-d53acc970758", "33b51b24-a2fe-4713-b881-d53acc970758", "a156804e-7ec1-496a-af77-80b8576d6cda", "0c9510f1-b3de-404d-a38e-e6d73b5bd566", "cea36e37-de23-4875-912d-be1da52eef33", "055b32ee-8b26-4dc1-8e4f-70580f855349", "675b03f0-74bb-49b6-877f-562b6f306bea", "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, UUIDType.instance); }
Example #4
Source File: CassandraTypeDeserializerTest.java From debezium-incubator with Apache License 2.0 | 5 votes |
@Test public void testUUIDType() { UUID uuid = UUID.randomUUID(); String expectedFixedUUID = Values.convertToString(CassandraTypeKafkaSchemaBuilders.UUID_TYPE, UuidUtil.asBytes(uuid)); ByteBuffer serializedUUID = UUIDType.instance.decompose(uuid); Object deserializedUUID = CassandraTypeDeserializer.deserialize(UUIDType.instance, serializedUUID); Assert.assertEquals(expectedFixedUUID, deserializedUUID); }
Example #5
Source File: MvccLogEntrySerializationStrategyV1Impl.java From usergrid with Apache License 2.0 | 5 votes |
@Override public Collection<MultiTenantColumnFamilyDefinition> getColumnFamilies() { //create the CF entity data. We want it reversed b/c we want the most recent version at the top of the //row for fast seeks MultiTenantColumnFamilyDefinition cf = new MultiTenantColumnFamilyDefinition( CF_ENTITY_LOG, BytesType.class.getSimpleName(), ReversedType.class.getSimpleName() + "(" + UUIDType.class.getSimpleName() + ")", IntegerType.class.getSimpleName(), MultiTenantColumnFamilyDefinition.CacheOption.KEYS ); return Collections.singleton( cf ); }
Example #6
Source File: MvccLogEntrySerializationStrategyV2Impl.java From usergrid with Apache License 2.0 | 5 votes |
@Override public Collection<MultiTenantColumnFamilyDefinition> getColumnFamilies() { //create the CF entity data. We want it reversed b/c we want the most recent version at the top of the //row for fast seeks MultiTenantColumnFamilyDefinition cf = new MultiTenantColumnFamilyDefinition( CF_ENTITY_LOG_V2, BytesType.class.getSimpleName(), ReversedType.class.getSimpleName() + "(" + UUIDType.class.getSimpleName() + ")", IntegerType.class.getSimpleName(), MultiTenantColumnFamilyDefinition.CacheOption.KEYS ); return Collections.singleton( cf ); }
Example #7
Source File: MvccEntitySerializationStrategyImpl.java From usergrid with Apache License 2.0 | 5 votes |
@Override public java.util.Collection getColumnFamilies() { //create the CF entity data. We want it reversed b/c we want the most recent version at the top of the //row for fast seeks MultiTenantColumnFamilyDefinition cf = new MultiTenantColumnFamilyDefinition( columnFamily, BytesType.class.getSimpleName(), ReversedType.class.getSimpleName() + "(" + UUIDType.class.getSimpleName() + ")", BytesType.class.getSimpleName(), MultiTenantColumnFamilyDefinition.CacheOption.KEYS ); return Collections.singleton( cf ); }
Example #8
Source File: ColumnMapperUUIDTest.java From stratio-cassandra with Apache License 2.0 | 5 votes |
@Test public void testSortRandomUUIDs() { List<UUID> uuids = toList("520fdc7d-8d62-4c46-a22c-1f6c481f032f", "6a5a5f84-0482-408e-9600-6b7fafaaa9cb", "ece1ff82-c92c-4179-9e7f-0d6349810472", "6c211cca-fbf3-4777-b359-85440e10b1fa", "33b51b24-a2fe-4713-b881-d53acc970758", "33b51b24-a2fe-4713-b881-d53acc970758", "a156804e-7ec1-496a-af77-80b8576d6cda", "0c9510f1-b3de-404d-a38e-e6d73b5bd566", "cea36e37-de23-4875-912d-be1da52eef33", "055b32ee-8b26-4dc1-8e4f-70580f855349", "675b03f0-74bb-49b6-877f-562b6f306bea"); testSort(uuids, UUIDType.instance); }
Example #9
Source File: ColumnMapperUUIDTest.java From stratio-cassandra with Apache License 2.0 | 5 votes |
@Test public void testSortTimeUUIDsAsGeneral() { 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, UUIDType.instance); }
Example #10
Source File: HintedHandOffTest.java From stratio-cassandra with Apache License 2.0 | 5 votes |
@Test public void testHintsMetrics() throws Exception { for (int i = 0; i < 99; i++) HintedHandOffManager.instance.metrics.incrPastWindow(InetAddress.getLocalHost()); HintedHandOffManager.instance.metrics.log(); UntypedResultSet rows = executeInternal("SELECT hints_dropped FROM system." + SystemKeyspace.PEER_EVENTS_CF); Map<UUID, Integer> returned = rows.one().getMap("hints_dropped", UUIDType.instance, Int32Type.instance); assertEquals(Iterators.getLast(returned.values().iterator()).intValue(), 99); }
Example #11
Source File: BatchlogManager.java From stratio-cassandra with Apache License 2.0 | 5 votes |
@VisibleForTesting static Mutation getBatchlogMutationFor(Collection<Mutation> mutations, UUID uuid, int version, long now) { ColumnFamily cf = ArrayBackedSortedColumns.factory.create(CFMetaData.BatchlogCf); CFRowAdder adder = new CFRowAdder(cf, CFMetaData.BatchlogCf.comparator.builder().build(), now); adder.add("data", serializeMutations(mutations, version)) .add("written_at", new Date(now / 1000)) .add("version", version); return new Mutation(Keyspace.SYSTEM_KS, UUIDType.instance.decompose(uuid), cf); }
Example #12
Source File: CassandraTypeConverterTest.java From debezium-incubator with Apache License 2.0 | 5 votes |
@Test public void testUUID() { DataType uuid = DataType.uuid(); AbstractType<?> convertedType = CassandraTypeConverter.convert(uuid); UUIDType expectedType = UUIDType.instance; Assert.assertEquals(expectedType, convertedType); }
Example #13
Source File: ColumnMapperUUIDTest.java From stratio-cassandra with Apache License 2.0 | 4 votes |
@Test public void testCompareTimeUUID() { ColumnMapperUUID mapper = new ColumnMapperUUID(); UUID uuid1 = UUID.fromString("d9b602c0-89d8-11e4-b116-123b93f75cba"); UUID uuid2 = UUID.fromString("d9b6ff0e-89d8-11e4-b116-123b93f75cba"); ByteBuffer bb1 = UUIDType.instance.decompose(uuid1); ByteBuffer bb2 = UUIDType.instance.decompose(uuid2); String s1 = mapper.indexValue("uuid1", uuid1); String s2 = mapper.indexValue("uuid2", uuid2); int nativeComparison = flatComparison(UUIDType.instance.compare(bb1, bb2)); int mapperComparison = flatComparison(s1.compareTo(s2)); Assert.assertEquals(nativeComparison, mapperComparison); }
Example #14
Source File: ColumnMapperUUIDTest.java From stratio-cassandra with Apache License 2.0 | 4 votes |
@Test public void testCompareRandomUUID() throws InterruptedException { ColumnMapperUUID mapper = new ColumnMapperUUID(); UUID uuid1 = UUID.fromString("5e9384d7-c72b-402a-aa13-2745f9b6b318"); UUID uuid2 = UUID.fromString("eddfdc0d-76ee-4a5c-a155-3e5dd16ce1ae"); ByteBuffer bb1 = UUIDType.instance.decompose(uuid1); ByteBuffer bb2 = UUIDType.instance.decompose(uuid2); String s1 = mapper.indexValue("uuid1", uuid1); String s2 = mapper.indexValue("uuid2", uuid2); int nativeComparison = flatComparison(UUIDType.instance.compare(bb1, bb2)); int mapperComparison = flatComparison(s1.compareTo(s2)); Assert.assertEquals(nativeComparison, mapperComparison); }
Example #15
Source File: ColumnMapperUUIDTest.java From stratio-cassandra with Apache License 2.0 | 4 votes |
@Test public void testCompareDifferentTypes() { ColumnMapperUUID mapper = new ColumnMapperUUID(); UUID uuidTimeBased = UUID.fromString("c4c61dc4-89d7-11e4-b116-123b93f75cba"); UUID uuidRandom = UUID.fromString("c4c61dc4-89d7-41e4-b116-123b93f75cba"); ByteBuffer bb1 = UUIDType.instance.decompose(uuidTimeBased); ByteBuffer bb2 = UUIDType.instance.decompose(uuidRandom); String s1 = mapper.indexValue("uuidTimeBased", uuidTimeBased); String s2 = mapper.indexValue("uuidRandom", uuidRandom); int nativeComparison = flatComparison(UUIDType.instance.compare(bb1, bb2)); int mapperComparison = flatComparison(s1.compareTo(s2)); Assert.assertEquals(nativeComparison, mapperComparison); }
Example #16
Source File: UUIDs.java From stratio-cassandra with Apache License 2.0 | 4 votes |
public UUIDs(String name, GeneratorConfig config) { super(UUIDType.instance, config, name, UUID.class); }
Example #17
Source File: CqlTableDataTypeTest.java From stratio-cassandra with Apache License 2.0 | 4 votes |
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); } }
Example #18
Source File: BatchlogManager.java From stratio-cassandra with Apache License 2.0 | 4 votes |
private void deleteBatch(UUID id) { Mutation mutation = new Mutation(Keyspace.SYSTEM_KS, UUIDType.instance.decompose(id)); mutation.delete(SystemKeyspace.BATCHLOG_CF, FBUtilities.timestampMicros()); mutation.apply(); }