private RexNode createPartitionColComparator(final RexBuilder rexBuilder, List<RexNode> inputs) { final DrillSqlOperator op = new DrillSqlOperator(WriterPrel.PARTITION_COMPARATOR_FUNC, 1, true, false); final List<RexNode> compFuncs = Lists.newArrayListWithExpectedSize(inputs.size()); for (final RexNode input : inputs) { compFuncs.add(rexBuilder.makeCall(op, ImmutableList.of(input))); } return composeDisjunction(rexBuilder, compFuncs); }
private List<E> snapshot() { List<E> list = Lists.newArrayListWithExpectedSize(size()); for (Multiset.Entry<E> entry : entrySet()) { E element = entry.getElement(); for (int i = entry.getCount(); i > 0; i--) { list.add(element); } } return list; }
private void setupHashTable() throws SchemaChangeException { final List<Comparator> comparators = Lists.newArrayListWithExpectedSize(conditions.size()); conditions.forEach(cond->comparators.add(JoinUtils.checkAndReturnSupportedJoinComparator(cond))); if ( skipHashTableBuild ) { return; } // Setup the hash table configuration object List<NamedExpression> leftExpr = new ArrayList<>(conditions.size()); // Create named expressions from the conditions for (int i = 0; i < conditions.size(); i++) { leftExpr.add(new NamedExpression(conditions.get(i).getLeft(), new FieldReference("probe_side_" + i))); } // Set the left named expression to be null if the probe batch is empty. if (leftUpstream != IterOutcome.OK_NEW_SCHEMA && leftUpstream != IterOutcome.OK) { leftExpr = null; } else { if (probeBatch.getSchema().getSelectionVectorMode() != BatchSchema.SelectionVectorMode.NONE) { final String errorMsg = new StringBuilder().append("Hash join does not support probe batch with selection vectors. ").append("Probe batch has selection mode = ").append (probeBatch.getSchema().getSelectionVectorMode()).toString(); throw new SchemaChangeException(errorMsg); } } final HashTableConfig htConfig = new HashTableConfig((int) context.getOptions().getOption(ExecConstants.MIN_HASH_TABLE_SIZE), true, HashTable.DEFAULT_LOAD_FACTOR, rightExpr, leftExpr, comparators, joinControl.asInt()); // Create the chained hash table baseHashTable = new ChainedHashTable(htConfig, context, allocator, buildBatch, probeBatch, null); if (enableRuntimeFilter) { setupHash64(htConfig); } }
protected MergeJoinBatch(MergeJoinPOP popConfig, FragmentContext context, RecordBatch left, RecordBatch right) throws OutOfMemoryException { super(popConfig, context, true, left, right); // Instantiate the batch memory manager final int configuredBatchSize = (int) context.getOptions().getOption(ExecConstants.OUTPUT_BATCH_SIZE_VALIDATOR); batchMemoryManager = new MergeJoinMemoryManager(configuredBatchSize, left, right); RecordBatchStats.logRecordBatchStats(getRecordBatchStatsContext(), "configured output batch size: %d", configuredBatchSize); if (popConfig.getConditions().size() == 0) { throw new UnsupportedOperationException("Merge Join currently does not support cartesian join. This join operator was configured with 0 conditions"); } this.leftIterator = new RecordIterator(left, this, oContext, 0, false, batchMemoryManager); this.rightIterator = new RecordIterator(right, this, oContext, 1, batchMemoryManager); this.joinType = popConfig.getJoinType(); this.status = new JoinStatus(leftIterator, rightIterator, this); this.conditions = popConfig.getConditions(); this.comparators = Lists.newArrayListWithExpectedSize(conditions.size()); for (JoinCondition condition : conditions) { this.comparators.add(JoinUtils.checkAndReturnSupportedJoinComparator(condition)); } }
final List<RexNode> exprs = Lists.newArrayListWithExpectedSize(queryRowType.getFieldCount() + 1); final List<String> fieldNames = new ArrayList<>(queryRowType.getFieldNames()); } else { final List<RexNode> partitionColumnExprs = Lists.newArrayListWithExpectedSize(partitionColumns.size()); for (final String colName : partitionColumns) { final RelDataTypeField field = childRowType.getField(colName, false, false);
comparators = Lists.newArrayListWithExpectedSize(numGrpByExprs); for (int i=0; i<numGrpByExprs; i++) {
new HashPrelUtil.RexNodeBasedHashExpressionCreatorHelper(rexBuilder); final List<RexNode> distFieldRefs = Lists.newArrayListWithExpectedSize(distFields.size()); for (DistributionField distField : distFields) { final int fieldId = distField.getFieldId(); final List <RexNode> updatedExpr = Lists.newArrayListWithExpectedSize(childRowTypeFields.size()); removeUpdatedExpr = Lists.newArrayListWithExpectedSize(childRowTypeFields.size()); for (RelDataTypeField field : childRowTypeFields) { RexNode rex = rexBuilder.makeInputRef(field.getType(), field.getIndex());