Search in sources :

Example 1 with MongodbIndexKey

use of io.hetu.core.plugin.mongodb.MongoIndex.MongodbIndexKey in project hetu-core by openlookeng.

the class MongoMetadata method getTableProperties.

@Override
public ConnectorTableProperties getTableProperties(ConnectorSession session, ConnectorTableHandle table) {
    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()));
            }
        }
    }
    return new ConnectorTableProperties(TupleDomain.all(), Optional.empty(), partitioningColumns, Optional.empty(), localProperties.build());
}
Also used : ColumnHandle(io.prestosql.spi.connector.ColumnHandle) Set(java.util.Set) ImmutableList(com.google.common.collect.ImmutableList) MongodbIndexKey(io.hetu.core.plugin.mongodb.MongoIndex.MongodbIndexKey) LocalProperty(io.prestosql.spi.connector.LocalProperty) ConnectorTableProperties(io.prestosql.spi.connector.ConnectorTableProperties)

Aggregations

ImmutableList (com.google.common.collect.ImmutableList)1 MongodbIndexKey (io.hetu.core.plugin.mongodb.MongoIndex.MongodbIndexKey)1 ColumnHandle (io.prestosql.spi.connector.ColumnHandle)1 ConnectorTableProperties (io.prestosql.spi.connector.ConnectorTableProperties)1 LocalProperty (io.prestosql.spi.connector.LocalProperty)1 Set (java.util.Set)1