@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)); } }
public ByteBuffer fromString(String source) throws MarshalException { // Return an empty ByteBuffer for an empty string. if (source.isEmpty()) return ByteBufferUtil.EMPTY_BYTE_BUFFER; ByteBuffer idBytes = null; // ffffffff-ffff-ffff-ffff-ffffffffff if (regexPattern.matcher(source).matches()) { UUID uuid = null; try { uuid = UUID.fromString(source); idBytes = decompose(uuid); } catch (IllegalArgumentException e) { throw new MarshalException(String.format("Unable to make UUID from '%s'", source), e); } if (uuid.version() != 1) throw new MarshalException("TimeUUID supports only version 1 UUIDs"); } else { throw new MarshalException(String.format("Unknown timeuuid representation: %s", source)); } return idBytes; }
@Override public ByteBuffer fromStringCQL2(String source) throws MarshalException { // Return an empty ByteBuffer for an empty string. if (source.isEmpty()) return ByteBufferUtil.EMPTY_BYTE_BUFFER; ByteBuffer idBytes = null; // ffffffff-ffff-ffff-ffff-ffffffffff if (regexPattern.matcher(source).matches()) { UUID uuid = null; try { uuid = UUID.fromString(source); idBytes = decompose(uuid); } catch (IllegalArgumentException e) { throw new MarshalException(String.format("unable to make UUID from '%s'", source), e); } if (uuid.version() != 1) throw new MarshalException("TimeUUID supports only version 1 UUIDs"); } else { idBytes = ByteBuffer.wrap(UUIDGen.getTimeUUIDBytes(TimestampSerializer.dateStringToTimestamp(source))); } return idBytes; }
public ByteBuffer trace_next_query() throws TException { UUID sessionId = UUIDGen.getTimeUUID(); state().getQueryState().prepareTracingSession(sessionId); return TimeUUIDType.instance.decompose(sessionId); }
public ByteBuffer trace_next_query() throws TException { UUID sessionId = UUIDGen.getTimeUUID(); state().getQueryState().prepareTracingSession(sessionId); return TimeUUIDType.instance.decompose(sessionId); }
public ByteBuffer trace_next_query() throws TException { UUID sessionId = UUIDGen.getTimeUUID(); state().getQueryState().prepareTracingSession(sessionId); return TimeUUIDType.instance.decompose(sessionId); }