Search in sources :

Example 1 with TimeUUIDType

use of org.apache.cassandra.db.marshal.TimeUUIDType in project eiger by wlloyd.

the class UUIDTests method testTimeUUIDType.

@Test
public void testTimeUUIDType() throws UnknownHostException {
    TimeUUIDType comp = TimeUUIDType.instance;
    ByteBuffer first = ByteBuffer.wrap(UUIDGen.decompose(UUIDGen.makeType1UUIDFromHost(InetAddress.getByName("127.0.0.1"))));
    ByteBuffer second = ByteBuffer.wrap(UUIDGen.decompose(UUIDGen.makeType1UUIDFromHost(InetAddress.getByName("127.0.0.1"))));
    assert comp.compare(first, second) < 0;
    assert comp.compare(second, first) > 0;
    ByteBuffer sameAsFirst = ByteBuffer.wrap(UUIDGen.decompose(UUIDGen.getUUID(first)));
    assert comp.compare(first, sameAsFirst) == 0;
}
Also used : TimeUUIDType(org.apache.cassandra.db.marshal.TimeUUIDType) ByteBuffer(java.nio.ByteBuffer) Test(org.junit.Test)

Example 2 with TimeUUIDType

use of org.apache.cassandra.db.marshal.TimeUUIDType in project janusgraph by JanusGraph.

the class UUIDTest method timeUUIDComparison.

@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));
}
Also used : TimeUUIDType(org.apache.cassandra.db.marshal.TimeUUIDType) UUID(java.util.UUID) ByteBuffer(java.nio.ByteBuffer) Test(org.junit.Test)

Example 3 with TimeUUIDType

use of org.apache.cassandra.db.marshal.TimeUUIDType in project cassandra by apache.

the class UUIDTests method testTimeUUIDType.

@Test
public void testTimeUUIDType() {
    TimeUUIDType comp = TimeUUIDType.instance;
    ByteBuffer first = ByteBuffer.wrap(UUIDGen.getTimeUUIDBytes());
    ByteBuffer second = ByteBuffer.wrap(UUIDGen.getTimeUUIDBytes());
    assert comp.compare(first, second) < 0;
    assert comp.compare(second, first) > 0;
    ByteBuffer sameAsFirst = ByteBuffer.wrap(UUIDGen.decompose(UUIDGen.getUUID(first)));
    assert comp.compare(first, sameAsFirst) == 0;
}
Also used : TimeUUIDType(org.apache.cassandra.db.marshal.TimeUUIDType) ByteBuffer(java.nio.ByteBuffer) Test(org.junit.Test)

Example 4 with TimeUUIDType

use of org.apache.cassandra.db.marshal.TimeUUIDType in project titan by thinkaurelius.

the class UUIDTest method timeUUIDComparison.

@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));
}
Also used : TimeUUIDType(org.apache.cassandra.db.marshal.TimeUUIDType) UUID(java.util.UUID) ByteBuffer(java.nio.ByteBuffer) Test(org.junit.Test)

Aggregations

ByteBuffer (java.nio.ByteBuffer)4 TimeUUIDType (org.apache.cassandra.db.marshal.TimeUUIDType)4 Test (org.junit.Test)4 UUID (java.util.UUID)2