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 static com.facebook.presto.util.Types.checkType;
 import static com.google.common.base.MoreObjects.toStringHelper;
 import static com.google.common.base.Preconditions.checkArgument;
 import static com.google.common.base.Preconditions.checkNotNull;
 
 public class SystemSplitManager
         implements ConnectorSplitManager
 {
     private final NodeManager nodeManager;
     private final ConcurrentMap<SchemaTableNameSystemTabletables = new ConcurrentHashMap<>();
 
     @Inject
     public SystemSplitManager(NodeManager nodeManager)
     {
         this. = checkNotNull(nodeManager"nodeManager is null");
     }
 
     public void addTable(SystemTable systemTable)
     {
         checkNotNull(systemTable"systemTable is null");
         SchemaTableName tableName = systemTable.getTableMetadata().getTable();
         checkArgument(.putIfAbsent(tableNamesystemTable) == null"Table %s is already registered"tableName);
     }
 
     @Override
     {
         checkNotNull(tupleDomain"tupleDomain is null");
         SystemTableHandle systemTableHandle = checkType(tableSystemTableHandle.class"table");
 
         List<ConnectorPartitionpartitions = ImmutableList.<ConnectorPartition>of(new SystemPartition(systemTableHandle));
         return new ConnectorPartitionResult(partitionstupleDomain);
     }
 
     @Override
     {
         checkNotNull(partitions"partitions is null");
         if (partitions.isEmpty()) {
             return new FixedSplitSource(., ImmutableList.<ConnectorSplit>of());
         }
 
         ConnectorPartition partition = Iterables.getOnlyElement(partitions);
         SystemPartition systemPartition = checkType(partitionSystemPartition.class"partition");
 
         SystemTable systemTable = .get(systemPartition.getTableHandle().getSchemaTableName());
         checkArgument(systemTable != null"Table %s does not exist"systemPartition.getTableHandle().getTableName());
 
         if (systemTable.isDistributed()) {
             ImmutableList.Builder<ConnectorSplitsplits = ImmutableList.builder();
             for (Node node : .getActiveNodes()) {
                 splits.add(new SystemSplit(systemPartition.getTableHandle(), node.getHostAndPort()));
             }
             return new FixedSplitSource(.splits.build());
         }
 
         HostAddress address = .getCurrentNode().getHostAndPort();
         ConnectorSplit split = new SystemSplit(systemPartition.getTableHandle(), address);
         return new FixedSplitSource(., ImmutableList.of(split));
     }
 
    public static class SystemPartition
            implements ConnectorPartition
    {
        private final SystemTableHandle tableHandle;
        public SystemPartition(SystemTableHandle tableHandle)
        {
            this. = checkNotNull(tableHandle"tableHandle is null");
        }
        public SystemTableHandle getTableHandle()
        {
            return ;
        }
        @Override
        public String getPartitionId()
        {
            return .getSchemaTableName().toString();
        }
        @Override
        {
            return TupleDomain.all();
        }
        @Override
        public String toString()
        {
            return toStringHelper(this)
                    .add("tableHandle")
                    .toString();
        }
    }
New to GrepCode? Check out our FAQ X