@Override public BucketFunction getBucketFunction(ConnectorTransactionHandle transactionHandle, ConnectorSession session, ConnectorPartitioningHandle partitioningHandle, List<Type> partitionChannelTypes, int bucketCount) { long totalRows = ((TpchPartitioningHandle) partitioningHandle).getTotalRows(); long rowsPerBucket = totalRows / bucketCount; checkArgument(partitionChannelTypes.equals(ImmutableList.of(BIGINT)), "Expected one BIGINT parameter"); return new TpchBucketFunction(bucketCount, rowsPerBucket); } }
@Override public int getBucket(Page page, int position) { Block block = page.getBlock(0); if (block.isNull(position)) { return 0; } long orderKey = BIGINT.getLong(block, position); long rowNumber = rowNumberFromOrderKey(orderKey); int bucket = toIntExact(rowNumber / rowsPerBucket); // due to rounding, the last bucket has extra rows if (bucket >= bucketCount) { bucket = bucketCount - 1; } return bucket; }
@Override public int getBucket(Page page, int position) { Block block = page.getBlock(0); if (block.isNull(position)) { return 0; } long orderKey = BIGINT.getLong(block, position); long rowNumber = rowNumberFromOrderKey(orderKey); int bucket = toIntExact(rowNumber / rowsPerBucket); // due to rounding, the last bucket has extra rows if (bucket >= bucketCount) { bucket = bucketCount - 1; } return bucket; }
@Override public BucketFunction getBucketFunction(ConnectorTransactionHandle transactionHandle, ConnectorSession session, ConnectorPartitioningHandle partitioningHandle, List<Type> partitionChannelTypes, int bucketCount) { long totalRows = ((TpchPartitioningHandle) partitioningHandle).getTotalRows(); long rowsPerBucket = totalRows / bucketCount; checkArgument(partitionChannelTypes.equals(ImmutableList.of(BIGINT)), "Expected one BIGINT parameter"); return new TpchBucketFunction(bucketCount, rowsPerBucket); } }