use of com.datastax.driver.core.ClusteringOrder in project calcite by apache.
the class CassandraSchema method getClusteringOrder.
/**
* Get the collation of all clustering key columns.
*
* @return A RelCollations representing the collation of all clustering keys
*/
public List<RelFieldCollation> getClusteringOrder(String columnFamily, boolean view) {
AbstractTableMetadata table;
if (view) {
table = getKeyspace().getMaterializedView(columnFamily);
} else {
table = getKeyspace().getTable(columnFamily);
}
List<ClusteringOrder> clusteringOrder = table.getClusteringOrder();
List<RelFieldCollation> keyCollations = new ArrayList<RelFieldCollation>();
int i = 0;
for (ClusteringOrder order : clusteringOrder) {
RelFieldCollation.Direction direction;
switch(order) {
case DESC:
direction = RelFieldCollation.Direction.DESCENDING;
break;
case ASC:
default:
direction = RelFieldCollation.Direction.ASCENDING;
break;
}
keyCollations.add(new RelFieldCollation(i, direction));
i++;
}
return keyCollations;
}
Aggregations