Search in sources :

Example 1 with PrestoThriftSplit

use of com.facebook.presto.thrift.api.connector.PrestoThriftSplit in project presto by prestodb.

the class ThriftTpchService method getSplitsSync.

private static PrestoThriftSplitBatch getSplitsSync(PrestoThriftSchemaTableName schemaTableName, int maxSplitCount, PrestoThriftNullableToken nextToken) {
    int totalParts = DEFAULT_NUMBER_OF_SPLITS;
    // last sent part
    int partNumber = nextToken.getToken() == null ? 0 : Ints.fromByteArray(nextToken.getToken().getId());
    int numberOfSplits = min(maxSplitCount, totalParts - partNumber);
    List<PrestoThriftSplit> splits = new ArrayList<>(numberOfSplits);
    for (int i = 0; i < numberOfSplits; i++) {
        SplitInfo splitInfo = normalSplit(schemaTableName.getSchemaName(), schemaTableName.getTableName(), partNumber + 1, totalParts);
        splits.add(new PrestoThriftSplit(new PrestoThriftId(SPLIT_INFO_CODEC.toJsonBytes(splitInfo)), ImmutableList.of()));
        partNumber++;
    }
    PrestoThriftId newNextToken = partNumber < totalParts ? new PrestoThriftId(Ints.toByteArray(partNumber)) : null;
    return new PrestoThriftSplitBatch(splits, newNextToken);
}
Also used : PrestoThriftSplitBatch(com.facebook.presto.thrift.api.connector.PrestoThriftSplitBatch) PrestoThriftId(com.facebook.presto.thrift.api.connector.PrestoThriftId) ArrayList(java.util.ArrayList) PrestoThriftSplit(com.facebook.presto.thrift.api.connector.PrestoThriftSplit)

Example 2 with PrestoThriftSplit

use of com.facebook.presto.thrift.api.connector.PrestoThriftSplit in project presto by prestodb.

the class ThriftIndexedTpchService method getIndexSplitsSync.

@Override
protected PrestoThriftSplitBatch getIndexSplitsSync(PrestoThriftSchemaTableName schemaTableName, List<String> indexColumnNames, PrestoThriftPageResult keys, int maxSplitCount, PrestoThriftNullableToken nextToken) throws PrestoThriftServiceException {
    checkArgument(NUMBER_OF_INDEX_SPLITS <= maxSplitCount, "maxSplitCount for lookup splits is too low");
    checkArgument(nextToken.getToken() == null, "no continuation is supported for lookup splits");
    int totalKeys = keys.getRowCount();
    int partSize = totalKeys / NUMBER_OF_INDEX_SPLITS;
    List<PrestoThriftSplit> splits = new ArrayList<>(NUMBER_OF_INDEX_SPLITS);
    for (int splitIndex = 0; splitIndex < NUMBER_OF_INDEX_SPLITS; splitIndex++) {
        int begin = partSize * splitIndex;
        int end = partSize * (splitIndex + 1);
        if (splitIndex + 1 == NUMBER_OF_INDEX_SPLITS) {
            // add remainder to the last split
            end = totalKeys;
        }
        if (begin == end) {
            // split is empty, skip it
            continue;
        }
        SplitInfo splitInfo = indexSplit(schemaTableName.getSchemaName(), schemaTableName.getTableName(), indexColumnNames, thriftPageToList(keys, begin, end));
        splits.add(new PrestoThriftSplit(new PrestoThriftId(SPLIT_INFO_CODEC.toJsonBytes(splitInfo)), ImmutableList.of()));
    }
    return new PrestoThriftSplitBatch(splits, null);
}
Also used : PrestoThriftSplitBatch(com.facebook.presto.thrift.api.connector.PrestoThriftSplitBatch) PrestoThriftId(com.facebook.presto.thrift.api.connector.PrestoThriftId) ArrayList(java.util.ArrayList) PrestoThriftSplit(com.facebook.presto.thrift.api.connector.PrestoThriftSplit)

Example 3 with PrestoThriftSplit

use of com.facebook.presto.thrift.api.connector.PrestoThriftSplit in project presto by prestodb.

the class ThriftIndexPageSource method startDataFetchForNextSplit.

private void startDataFetchForNextSplit() {
    PrestoThriftSplit split = splits.get(splitIndex);
    splitIndex++;
    RunningSplitContext context = new RunningSplitContext(openClient(split), split);
    sendDataRequest(context, null);
}
Also used : PrestoThriftSplit(com.facebook.presto.thrift.api.connector.PrestoThriftSplit)

Aggregations

PrestoThriftSplit (com.facebook.presto.thrift.api.connector.PrestoThriftSplit)3 PrestoThriftId (com.facebook.presto.thrift.api.connector.PrestoThriftId)2 PrestoThriftSplitBatch (com.facebook.presto.thrift.api.connector.PrestoThriftSplitBatch)2 ArrayList (java.util.ArrayList)2