Search in sources :

Example 1 with ClusteringOrder

use of org.apache.cassandra.schema.ColumnMetadata.ClusteringOrder in project cassandra by apache.

the class SchemaKeyspace method createColumnFromRow.

static ColumnMetadata createColumnFromRow(UntypedResultSet.Row row, Types types) {
    String keyspace = row.getString("keyspace_name");
    String table = row.getString("table_name");
    ColumnMetadata.Kind kind = ColumnMetadata.Kind.valueOf(row.getString("kind").toUpperCase());
    int position = row.getInt("position");
    ClusteringOrder order = ClusteringOrder.valueOf(row.getString("clustering_order").toUpperCase());
    AbstractType<?> type = CQLTypeParser.parse(keyspace, row.getString("type"), types);
    if (order == ClusteringOrder.DESC)
        type = ReversedType.getInstance(type);
    ColumnIdentifier name = new ColumnIdentifier(row.getBytes("column_name_bytes"), row.getString("column_name"));
    return new ColumnMetadata(keyspace, table, name, type, position, kind);
}
Also used : ClusteringOrder(org.apache.cassandra.schema.ColumnMetadata.ClusteringOrder)

Example 2 with ClusteringOrder

use of org.apache.cassandra.schema.ColumnMetadata.ClusteringOrder in project cassandra by apache.

the class NativeSSTableLoaderClient method createDefinitionFromRow.

private static ColumnMetadata createDefinitionFromRow(Row row, String keyspace, String table, Types types) {
    ClusteringOrder order = ClusteringOrder.valueOf(row.getString("clustering_order").toUpperCase());
    AbstractType<?> type = CQLTypeParser.parse(keyspace, row.getString("type"), types);
    if (order == ClusteringOrder.DESC)
        type = ReversedType.getInstance(type);
    ColumnIdentifier name = new ColumnIdentifier(row.getBytes("column_name_bytes"), row.getString("column_name"));
    int position = row.getInt("position");
    org.apache.cassandra.schema.ColumnMetadata.Kind kind = ColumnMetadata.Kind.valueOf(row.getString("kind").toUpperCase());
    return new ColumnMetadata(keyspace, table, name, type, position, kind);
}
Also used : ColumnMetadata(org.apache.cassandra.schema.ColumnMetadata) ColumnIdentifier(org.apache.cassandra.cql3.ColumnIdentifier) ClusteringOrder(org.apache.cassandra.schema.ColumnMetadata.ClusteringOrder)

Aggregations

ClusteringOrder (org.apache.cassandra.schema.ColumnMetadata.ClusteringOrder)2 ColumnIdentifier (org.apache.cassandra.cql3.ColumnIdentifier)1 ColumnMetadata (org.apache.cassandra.schema.ColumnMetadata)1