Search in sources :

Example 1 with MongodbIndexKey

use of com.facebook.presto.mongodb.MongoIndex.MongodbIndexKey in project presto by prestodb.

the class MongoMetadata method getTableLayouts.

@Override
public List<ConnectorTableLayoutResult> getTableLayouts(ConnectorSession session, ConnectorTableHandle table, Constraint<ColumnHandle> constraint, Optional<Set<ColumnHandle>> desiredColumns) {
    MongoTableHandle tableHandle = (MongoTableHandle) table;
    // TODO: sharding key
    Optional<Set<ColumnHandle>> partitioningColumns = Optional.empty();
    ImmutableList.Builder<LocalProperty<ColumnHandle>> localProperties = ImmutableList.builder();
    MongoTable tableInfo = mongoSession.getTable(tableHandle.getSchemaTableName());
    Map<String, ColumnHandle> columns = getColumnHandles(session, tableHandle);
    for (MongoIndex index : tableInfo.getIndexes()) {
        for (MongodbIndexKey key : index.getKeys()) {
            if (!key.getSortOrder().isPresent()) {
                continue;
            }
            if (columns.get(key.getName()) != null) {
                localProperties.add(new SortingProperty<>(columns.get(key.getName()), key.getSortOrder().get()));
            }
        }
    }
    ConnectorTableLayout layout = new ConnectorTableLayout(new MongoTableLayoutHandle(tableHandle, constraint.getSummary()), Optional.empty(), TupleDomain.all(), Optional.empty(), partitioningColumns, Optional.empty(), localProperties.build());
    return ImmutableList.of(new ConnectorTableLayoutResult(layout, constraint.getSummary()));
}
Also used : ColumnHandle(com.facebook.presto.spi.ColumnHandle) Set(java.util.Set) ImmutableList(com.google.common.collect.ImmutableList) ConnectorTableLayoutResult(com.facebook.presto.spi.ConnectorTableLayoutResult) MongodbIndexKey(com.facebook.presto.mongodb.MongoIndex.MongodbIndexKey) ConnectorTableLayout(com.facebook.presto.spi.ConnectorTableLayout) LocalProperty(com.facebook.presto.spi.LocalProperty)

Aggregations

MongodbIndexKey (com.facebook.presto.mongodb.MongoIndex.MongodbIndexKey)1 ColumnHandle (com.facebook.presto.spi.ColumnHandle)1 ConnectorTableLayout (com.facebook.presto.spi.ConnectorTableLayout)1 ConnectorTableLayoutResult (com.facebook.presto.spi.ConnectorTableLayoutResult)1 LocalProperty (com.facebook.presto.spi.LocalProperty)1 ImmutableList (com.google.common.collect.ImmutableList)1 Set (java.util.Set)1