private static List<SelectItem> buildSelectItems(List<String> columnNames) { return columnNames.stream() .map(QueryUtil::unaliasedName) .collect(toImmutableList()); }
/** * Rows with same hash value are guaranteed to be in the same result page. */ public WorkProcessor<Page> merge(List<Type> keyTypes, List<Type> allTypes, List<WorkProcessor<Page>> channels, DriverYieldSignal driverYieldSignal) { InterpretedHashGenerator hashGenerator = createHashGenerator(keyTypes); return mergeSortedPages( channels, createHashPageWithPositionComparator(hashGenerator), IntStream.range(0, allTypes.size()).boxed().collect(toImmutableList()), allTypes, keepSameHashValuesWithinSinglePage(hashGenerator), true, memoryContext, driverYieldSignal); }
public void testLines() throws IOException { try (Stream<String> lines = source.lines()) { assertExpectedLines(lines.collect(toImmutableList())); } }
@Override public ScalarFunctionImplementation specialize(BoundVariables boundVariables, int arity, TypeManager typeManager, FunctionRegistry functionRegistry) { Type type = boundVariables.getTypeVariable("E"); checkArgument(type.isOrderable(), "Type must be orderable"); MethodHandle compareMethod = functionRegistry.getScalarFunctionImplementation(internalOperator(operatorType, BOOLEAN, ImmutableList.of(type, type))).getMethodHandle(); List<Class<?>> javaTypes = IntStream.range(0, arity) .mapToObj(i -> type.getJavaType()) .collect(toImmutableList()); Class<?> clazz = generate(javaTypes, type, compareMethod); MethodHandle methodHandle = methodHandle(clazz, getSignature().getName(), javaTypes.toArray(new Class<?>[javaTypes.size()])); return new ScalarFunctionImplementation( false, nCopies(javaTypes.size(), valueTypeArgumentProperty(RETURN_NULL_ON_NULL)), methodHandle, isDeterministic()); }
public static <T> List<T> filteredCopy(List<T> elements, Predicate<T> predicate) { requireNonNull(elements, "elements is null"); requireNonNull(predicate, "predicate is null"); return elements.stream() .filter(predicate) .collect(toImmutableList()); }
static <T> List<T> without(List<T> list, Collection<Integer> indexes) { Set<Integer> indexesSet = ImmutableSet.copyOf(indexes); return IntStream.range(0, list.size()) .filter(index -> !indexesSet.contains(index)) .mapToObj(list::get) .collect(toImmutableList()); }
public void testLines() throws IOException { source = new TestCharSource(LINES); ImmutableList<String> lines; try (Stream<String> linesStream = source.lines()) { assertTrue(source.wasStreamOpened()); assertFalse(source.wasStreamClosed()); lines = linesStream.collect(toImmutableList()); } assertTrue(source.wasStreamClosed()); assertEquals(SPLIT_LINES, lines); }
private List<String> getNewWarnings(List<PrestoWarning> warnings) { int end = warnings.size(); if (maxWarnings.isPresent()) { end = Math.min(processedWarnings + maxWarnings.getAsInt(), end); } List<String> subList = warnings.subList(processedWarnings, end).stream() .map(this::getWarningMessage) .collect(toImmutableList()); processedWarnings = end; return subList; }
private void replaceAll(String queryTemplate, Consumer<String> queryConsumer, List<List<Parameter>> parametersLists) { if (parametersLists.size() == 0) { checkQueryHasAllParametersReplaced(queryTemplate); queryConsumer.accept(queryTemplate); } else { List<List<Parameter>> restParameters = IntStream.range(1, parametersLists.size()) .mapToObj(parametersLists::get) .collect(toImmutableList()); for (Parameter parameter : parametersLists.get(0)) { String intermediateQueryTemplate = resolve(queryTemplate, parameter); replaceAll(intermediateQueryTemplate, queryConsumer, restParameters); } } }
private ZipFunction(List<String> typeParameters) { super(new Signature("zip", FunctionKind.SCALAR, typeParameters.stream().map(Signature::typeVariable).collect(toImmutableList()), ImmutableList.of(), parseTypeSignature("array(row(" + join(",", typeParameters) + "))"), typeParameters.stream().map(name -> "array(" + name + ")").map(TypeSignature::parseTypeSignature).collect(toImmutableList()), false)); this.typeParameters = typeParameters; }
private static List<ColumnStatistics> toColumnStatistics(HiveWriterVersion hiveWriterVersion, List<OrcProto.ColumnStatistics> columnStatistics, boolean isRowGroup) { if (columnStatistics == null) { return ImmutableList.of(); } return columnStatistics.stream() .map(statistics -> toColumnStatistics(hiveWriterVersion, statistics, isRowGroup)) .collect(toImmutableList()); }
private static List<Symbol> removeSymbol(List<Symbol> symbols, Symbol symbolToRemove) { return symbols.stream() .filter(symbol -> !symbolToRemove.equals(symbol)) .collect(toImmutableList()); } }
private List<ApplicableFunction> getUnknownOnlyCastFunctions(List<ApplicableFunction> applicableFunction, List<Type> actualParameters) { return applicableFunction.stream() .filter((function) -> onlyCastsUnknown(function, actualParameters)) .collect(toImmutableList()); }
public List<Symbol> sourceOutputLayout(int sourceIndex) { // Make sure the sourceOutputLayout symbols are listed in the same order as the corresponding output symbols return getOutputSymbols().stream() .map(symbol -> outputToInputs.get(symbol).get(sourceIndex)) .collect(toImmutableList()); }
public static Partitioning create(PartitioningHandle handle, List<Symbol> columns) { return new Partitioning(handle, columns.stream() .map(Symbol::toSymbolReference) .map(ArgumentBinding::expressionBinding) .collect(toImmutableList())); }
/** * Gets the index of all columns matching the specified name */ public List<Field> resolveFields(QualifiedName name) { return allFields.stream() .filter(input -> input.canResolve(name)) .collect(toImmutableList()); }
/** * This method is used for SELECT * or x.* queries */ public List<Field> resolveFieldsWithPrefix(Optional<QualifiedName> prefix) { return visibleFields.stream() .filter(input -> input.matchesPrefix(prefix)) .collect(toImmutableList()); }
public DriverFactory(int pipelineId, boolean inputDriver, boolean outputDriver, List<OperatorFactory> operatorFactories, OptionalInt driverInstances, PipelineExecutionStrategy pipelineExecutionStrategy) { this.pipelineId = pipelineId; this.inputDriver = inputDriver; this.outputDriver = outputDriver; this.operatorFactories = ImmutableList.copyOf(requireNonNull(operatorFactories, "operatorFactories is null")); checkArgument(!operatorFactories.isEmpty(), "There must be at least one operator"); this.driverInstances = requireNonNull(driverInstances, "driverInstances is null"); this.pipelineExecutionStrategy = requireNonNull(pipelineExecutionStrategy, "pipelineExecutionStrategy is null"); List<PlanNodeId> sourceIds = operatorFactories.stream() .filter(SourceOperatorFactory.class::isInstance) .map(SourceOperatorFactory.class::cast) .map(SourceOperatorFactory::getSourceId) .collect(toImmutableList()); checkArgument(sourceIds.size() <= 1, "Expected at most one source operator in driver facotry, but found %s", sourceIds); this.sourceId = sourceIds.isEmpty() ? Optional.empty() : Optional.of(sourceIds.get(0)); }
private JoinGraph replacementGraph(PlanNode oldNode, PlanNode newNode, Context context) { // TODO optimize when idea is generally approved List<Symbol> symbols = context.symbolSources.entrySet().stream() .filter(entry -> entry.getValue() == oldNode) .map(Map.Entry::getKey) .collect(toImmutableList()); symbols.forEach(symbol -> context.symbolSources.put(symbol, newNode)); return new JoinGraph(newNode); } }