public static UntypedResultSet resultify(Row serializedColumns) { String query = String.format("SELECT * FROM %s.%s", Keyspace.SYSTEM_KS, SystemKeyspace.SCHEMA_COLUMNS_CF); return QueryProcessor.resultify(query, serializedColumns); }
public static UntypedResultSet resultify(String query, RowIterator partition) { return resultify(query, PartitionIterators.singletonIterator(partition)); }
public static UntypedResultSet resultify(String query, RowIterator partition) { return resultify(query, PartitionIterators.singletonIterator(partition)); }
public static UntypedResultSet resultify(String query, RowIterator partition) { return resultify(query, PartitionIterators.singletonIterator(partition)); }
public static Map<ByteBuffer, UserType> fromSchema(Row row) { UntypedResultSet results = QueryProcessor.resultify("SELECT * FROM system." + SystemKeyspace.SCHEMA_USER_TYPES_CF, row); Map<ByteBuffer, UserType> types = new HashMap<>(results.size()); for (UntypedResultSet.Row result : results) { UserType type = fromSchema(result); types.put(type.name, type); } return types; }
/** * Deserialize ColumnFamilies from low-level schema representation, all of them belong to the same keyspace * * @return map containing name of the ColumnFamily and it's metadata for faster lookup */ public static Map<String, CFMetaData> deserializeColumnFamilies(Row row) { if (row.cf == null) return Collections.emptyMap(); Map<String, CFMetaData> cfms = new HashMap<>(); UntypedResultSet results = QueryProcessor.resultify("SELECT * FROM system.schema_columnfamilies", row); for (UntypedResultSet.Row result : results) { CFMetaData cfm = CFMetaData.fromSchema(result); cfms.put(cfm.cfName, cfm); } return cfms; } }
private static CFMetaData fromSchema(Row row) { UntypedResultSet.Row result = QueryProcessor.resultify("SELECT * FROM system.schema_columnfamilies", row).one(); return fromSchema(result); }
/** * Deserialize triggers from storage-level representation. * * @param serializedTriggers storage-level partition containing the trigger definitions * @return the list of processed TriggerDefinitions */ public static List<TriggerDefinition> fromSchema(Row serializedTriggers) { List<TriggerDefinition> triggers = new ArrayList<>(); String query = String.format("SELECT * FROM %s.%s", Keyspace.SYSTEM_KS, SystemKeyspace.SCHEMA_TRIGGERS_CF); for (UntypedResultSet.Row row : QueryProcessor.resultify(query, serializedTriggers)) { String name = row.getString(TRIGGER_NAME); String classOption = row.getMap(TRIGGER_OPTIONS, UTF8Type.instance, UTF8Type.instance).get(CLASS); triggers.add(new TriggerDefinition(name, classOption)); } return triggers; }
public static UntypedResultSet resultify(String query, List<Row> rows) { try { SelectStatement ss = (SelectStatement) getStatement(query, null).statement; ResultSet cqlRows = ss.process(rows); return UntypedResultSet.create(cqlRows); } catch (RequestValidationException e) { throw new AssertionError(e); } }
/** * Deserialize only Keyspace attributes without nested ColumnFamilies * * @param row Keyspace attributes in serialized form * * @return deserialized keyspace without cf_defs */ public static KSMetaData fromSchema(Row row, Iterable<CFMetaData> cfms, UTMetaData userTypes) { UntypedResultSet.Row result = QueryProcessor.resultify("SELECT * FROM system.schema_keyspaces", row).one(); try { return new KSMetaData(result.getString("keyspace_name"), AbstractReplicationStrategy.getClass(result.getString("strategy_class")), fromJsonMap(result.getString("strategy_options")), result.getBoolean("durable_writes"), cfms, userTypes); } catch (ConfigurationException e) { throw new RuntimeException(e); } }