Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   *     http://www.apache.org/licenses/LICENSE-2.0
   *
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
 package com.facebook.presto.connector.system;
 
 
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
 import static com.facebook.presto.connector.system.SystemColumnHandle.toSystemColumnHandles;
 import static com.facebook.presto.metadata.MetadataUtil.findColumnMetadata;
 import static com.facebook.presto.util.ImmutableCollectors.toImmutableList;
 import static com.facebook.presto.util.Types.checkType;
 import static com.google.common.base.Preconditions.checkArgument;
 import static com.google.common.base.Preconditions.checkNotNull;
 import static java.util.function.Function.identity;
 import static java.util.stream.Collectors.toMap;
 
 public class SystemTablesMetadata
         extends ReadOnlyConnectorMetadata
 {
     private final Map<SchemaTableNameConnectorTableMetadatatables;
 
     public SystemTablesMetadata(Set<SystemTabletables)
     {
         this. = tables.stream()
                 .map(SystemTable::getTableMetadata)
                 .collect(toMap(ConnectorTableMetadata::getTableidentity()));
     }
 
     {
         SystemTableHandle systemTableHandle = checkType(tableHandleSystemTableHandle.class"tableHandle");
         checkArgument(.containsKey(systemTableHandle.getSchemaTableName()));
         return systemTableHandle;
     }
 
     @Override
     public List<StringlistSchemaNames(ConnectorSession session)
     {
         return .keySet().stream()
                 .map(SchemaTableName::getSchemaName)
                 .distinct()
                 .collect(toImmutableList());
     }
 
     @Override
     public ConnectorTableHandle getTableHandle(ConnectorSession sessionSchemaTableName tableName)
     {
         if (!.containsKey(tableName)) {
             return null;
         }
         return new SystemTableHandle(tableName);
     }
 
     @Override
     {
         SystemTableHandle systemTableHandle = checkTableHandle(tableHandle);
         return .get(systemTableHandle.getSchemaTableName());
     }
 
     @Override
     public List<SchemaTableNamelistTables(ConnectorSession sessionString schemaNameOrNull)
     {
         if (schemaNameOrNull == null) {
             return ImmutableList.copyOf(.keySet());
         }
 
         return .keySet().stream()
                 .filter(table -> table.getSchemaName().equals(schemaNameOrNull))
                 .collect(toImmutableList());
     }
 
     @Override
    {
        return null;
    }
    @Override
    public ColumnMetadata getColumnMetadata(ConnectorTableHandle tableHandleColumnHandle columnHandle)
    {
        SystemTableHandle systemTableHandle = checkTableHandle(tableHandle);
        ConnectorTableMetadata tableMetadata = .get(systemTableHandle.getSchemaTableName());
        String columnName = checkType(columnHandleSystemColumnHandle.class"columnHandle").getColumnName();
        ColumnMetadata columnMetadata = findColumnMetadata(tableMetadatacolumnName);
        checkArgument(columnMetadata != null"Column %s on table %s does not exist"columnNametableMetadata.getTable());
        return columnMetadata;
    }
    @Override
    {
        SystemTableHandle systemTableHandle = checkTableHandle(tableHandle);
        return toSystemColumnHandles(.get(systemTableHandle.getSchemaTableName()));
    }
    @Override
    {
        checkNotNull(prefix"prefix is null");
        ImmutableMap.Builder<SchemaTableNameList<ColumnMetadata>> builder = ImmutableMap.builder();
        for (Entry<SchemaTableNameConnectorTableMetadataentry : .entrySet()) {
            if (prefix.matches(entry.getKey())) {
                builder.put(entry.getKey(), entry.getValue().getColumns());
            }
        }
        return builder.build();
    }
New to GrepCode? Check out our FAQ X