public static ByteBuffer getSchemaKSKey(String ksName) { return AsciiType.instance.fromString(ksName); }
@Override public Term fromJSONObject(Object parsed) throws MarshalException { try { return new Constants.Value(fromString((String) parsed)); } catch (ClassCastException exc) { throw new MarshalException(String.format( "Expected an ascii string, but got a %s: %s", parsed.getClass().getSimpleName(), parsed)); } }
@Override public Term fromJSONObject(Object parsed) throws MarshalException { try { return new Constants.Value(fromString((String) parsed)); } catch (ClassCastException exc) { throw new MarshalException(String.format( "Expected an ascii string, but got a %s: %s", parsed.getClass().getSimpleName(), parsed)); } }
@Override public Term fromJSONObject(Object parsed) throws MarshalException { try { return new Constants.Value(fromString((String) parsed)); } catch (ClassCastException exc) { throw new MarshalException(String.format( "Expected an ascii string, but got a %s: %s", parsed.getClass().getSimpleName(), parsed)); } }
@Override public Term fromJSONObject(Object parsed) throws MarshalException { try { return new Constants.Value(fromString((String) parsed)); } catch (ClassCastException exc) { throw new MarshalException(String.format( "Expected an ascii string, but got a %s: %s", parsed.getClass().getSimpleName(), parsed)); } }
/** * Returns the typed value, serialized to a ByteBuffer. * * @return a ByteBuffer of the value. * @throws InvalidRequestException if unable to coerce the string to its type. */ public ByteBuffer getByteBuffer() throws InvalidRequestException { switch (type) { case STRING: return AsciiType.instance.fromString(text); case INTEGER: return IntegerType.instance.fromString(text); case UUID: // we specifically want the Lexical class here, not "UUIDType," because we're supposed to have // a uuid-shaped string here, and UUIDType also accepts integer or date strings (and turns them into version 1 uuids). return LexicalUUIDType.instance.fromString(text); case FLOAT: return FloatType.instance.fromString(text); } // FIXME: handle scenario that should never happen return null; }
private static long readTypeTimestamp(String keyspaceName, String typeName) { ColumnFamilyStore store = org.apache.cassandra.db.Keyspace.open(SchemaConstants.SYSTEM_KEYSPACE_NAME) .getColumnFamilyStore(SystemKeyspace.LEGACY_USERTYPES); ClusteringComparator comparator = store.metadata.comparator; Slices slices = Slices.with(comparator, Slice.make(comparator, typeName)); int nowInSec = FBUtilities.nowInSeconds(); DecoratedKey key = store.metadata.decorateKey(AsciiType.instance.fromString(keyspaceName)); SinglePartitionReadCommand command = SinglePartitionReadCommand.create(store.metadata, nowInSec, key, slices); try (ReadExecutionController controller = command.executionController(); RowIterator partition = UnfilteredRowIterators.filter(command.queryMemtableAndDisk(store, controller), nowInSec)) { return partition.next().primaryKeyLivenessInfo().timestamp(); } }
private static long readTypeTimestamp(String keyspaceName, String typeName) { ColumnFamilyStore store = org.apache.cassandra.db.Keyspace.open(SchemaConstants.SYSTEM_KEYSPACE_NAME) .getColumnFamilyStore(SystemKeyspace.LEGACY_USERTYPES); ClusteringComparator comparator = store.metadata.comparator; Slices slices = Slices.with(comparator, Slice.make(comparator, typeName)); int nowInSec = FBUtilities.nowInSeconds(); DecoratedKey key = store.metadata.decorateKey(AsciiType.instance.fromString(keyspaceName)); SinglePartitionReadCommand command = SinglePartitionReadCommand.create(store.metadata, nowInSec, key, slices); try (ReadExecutionController controller = command.executionController(); RowIterator partition = UnfilteredRowIterators.filter(command.queryMemtableAndDisk(store, controller), nowInSec)) { return partition.next().primaryKeyLivenessInfo().timestamp(); } }
private static long readTypeTimestamp(String keyspaceName, String typeName) { ColumnFamilyStore store = org.apache.cassandra.db.Keyspace.open(SchemaConstants.SYSTEM_KEYSPACE_NAME) .getColumnFamilyStore(SystemKeyspace.LEGACY_USERTYPES); ClusteringComparator comparator = store.metadata.comparator; Slices slices = Slices.with(comparator, Slice.make(comparator, typeName)); int nowInSec = FBUtilities.nowInSeconds(); DecoratedKey key = store.metadata.decorateKey(AsciiType.instance.fromString(keyspaceName)); SinglePartitionReadCommand command = SinglePartitionReadCommand.create(store.metadata, nowInSec, key, slices); try (ReadExecutionController controller = command.executionController(); RowIterator partition = UnfilteredRowIterators.filter(command.queryMemtableAndDisk(store, controller), nowInSec)) { return partition.next().primaryKeyLivenessInfo().timestamp(); } }