@Override
public ConnectorSplitSource getPartitionSplits(ConnectorTableHandle table, List<ConnectorPartition> partitions)
{
checkNotNull(partitions, "partitions is null");
if (partitions.isEmpty()) {
return new FixedSplitSource(SYSTEM_DATASOURCE, ImmutableList.<ConnectorSplit>of());
}
ConnectorPartition partition = Iterables.getOnlyElement(partitions);
checkArgument(partition instanceof SystemPartition, "Partition must be a system partition");
SystemPartition systemPartition = (SystemPartition) partition;
SystemTable systemTable = tables.get(systemPartition.getTableHandle().getSchemaTableName());
checkArgument(systemTable != null, "Table %s does not exist", systemPartition.getTableHandle().getTableName());
if (systemTable.isDistributed()) {
ImmutableList.Builder<ConnectorSplit> splits = ImmutableList.builder();
for (Node node : nodeManager.getActiveNodes()) {
splits.add(new SystemSplit(systemPartition.tableHandle, node.getHostAndPort()));
}
return new FixedSplitSource(SYSTEM_DATASOURCE, splits.build());
}
HostAddress address = nodeManager.getCurrentNode().getHostAndPort();
ConnectorSplit split = new SystemSplit(systemPartition.tableHandle, address);
return new FixedSplitSource(SYSTEM_DATASOURCE, ImmutableList.of(split));
}