use of com.facebook.presto.spi.ConnectorSplitSource in project presto by prestodb.
the class AbstractTestHiveClient method testGetPartitionSplitsEmpty.
@Test
public void testGetPartitionSplitsEmpty() throws Exception {
try (Transaction transaction = newTransaction()) {
ConnectorSplitSource splitSource = splitManager.getSplits(transaction.getTransactionHandle(), newSession(), emptyTableLayoutHandle);
// fetch full list
getSplitCount(splitSource);
}
}
use of com.facebook.presto.spi.ConnectorSplitSource in project presto by prestodb.
the class AbstractTestHiveClientS3 method testGetRecordsS3.
@Test
public void testGetRecordsS3() throws Exception {
try (Transaction transaction = newTransaction()) {
ConnectorMetadata metadata = transaction.getMetadata();
ConnectorSession session = newSession();
ConnectorTableHandle table = getTableHandle(metadata, tableS3);
List<ColumnHandle> columnHandles = ImmutableList.copyOf(metadata.getColumnHandles(session, table).values());
Map<String, Integer> columnIndex = indexColumns(columnHandles);
List<ConnectorTableLayoutResult> tableLayoutResults = metadata.getTableLayouts(session, table, new Constraint<>(TupleDomain.all(), bindings -> true), Optional.empty());
HiveTableLayoutHandle layoutHandle = (HiveTableLayoutHandle) getOnlyElement(tableLayoutResults).getTableLayout().getHandle();
assertEquals(layoutHandle.getPartitions().get().size(), 1);
ConnectorSplitSource splitSource = splitManager.getSplits(transaction.getTransactionHandle(), session, layoutHandle);
long sum = 0;
for (ConnectorSplit split : getAllSplits(splitSource)) {
try (ConnectorPageSource pageSource = pageSourceProvider.createPageSource(transaction.getTransactionHandle(), session, split, columnHandles)) {
MaterializedResult result = materializeSourceDataStream(session, pageSource, getTypes(columnHandles));
for (MaterializedRow row : result) {
sum += (Long) row.getField(columnIndex.get("t_bigint"));
}
}
}
assertEquals(sum, 78300);
}
}
use of com.facebook.presto.spi.ConnectorSplitSource in project presto by prestodb.
the class SplitManager method getSplits.
public SplitSource getSplits(Session session, TableLayoutHandle layout) {
ConnectorId connectorId = layout.getConnectorId();
ConnectorSplitManager splitManager = getConnectorSplitManager(connectorId);
ConnectorSession connectorSession = session.toConnectorSession(connectorId);
ConnectorSplitSource source = splitManager.getSplits(layout.getTransactionHandle(), connectorSession, layout.getConnectorHandle());
SplitSource splitSource = new ConnectorAwareSplitSource(connectorId, layout.getTransactionHandle(), source);
if (minScheduleSplitBatchSize > 1) {
splitSource = new BufferingSplitSource(splitSource, minScheduleSplitBatchSize);
}
return splitSource;
}
use of com.facebook.presto.spi.ConnectorSplitSource in project presto by prestodb.
the class InformationSchemaSplitManager method getSplits.
@Override
public ConnectorSplitSource getSplits(ConnectorTransactionHandle transaction, ConnectorSession session, ConnectorTableLayoutHandle layout) {
InformationSchemaTableLayoutHandle handle = (InformationSchemaTableLayoutHandle) layout;
Map<ColumnHandle, NullableValue> bindings = extractFixedValues(handle.getConstraint()).orElse(ImmutableMap.of());
List<HostAddress> localAddress = ImmutableList.of(nodeManager.getCurrentNode().getHostAndPort());
Map<String, NullableValue> filters = bindings.entrySet().stream().collect(toMap(entry -> ((InformationSchemaColumnHandle) entry.getKey()).getColumnName(), Entry::getValue));
ConnectorSplit split = new InformationSchemaSplit(handle.getTable(), filters, localAddress);
return new FixedSplitSource(ImmutableList.of(split));
}
use of com.facebook.presto.spi.ConnectorSplitSource in project presto by prestodb.
the class TestRaptorSplitManager method testSanity.
@Test
public void testSanity() {
List<ConnectorTableLayoutResult> layouts = metadata.getTableLayouts(SESSION, tableHandle, Constraint.alwaysTrue(), Optional.empty());
assertEquals(layouts.size(), 1);
ConnectorTableLayoutResult layout = getOnlyElement(layouts);
assertInstanceOf(layout.getTableLayout().getHandle(), RaptorTableLayoutHandle.class);
ConnectorSplitSource splitSource = getSplits(raptorSplitManager, layout);
int splitCount = 0;
while (!splitSource.isFinished()) {
List<ConnectorSplit> splits = getSplits(splitSource, 1000);
splitCount += splits.size();
RaptorSplit split = (RaptorSplit) (splits.get(0));
assertFalse(split.isTableSupportsDeltaDelete());
assertEquals(split.getColumnTypes(), Optional.empty());
}
assertEquals(splitCount, 4);
}
Aggregations