private List<Dependency> get(Map<AbstractProject, List<DependencyGroup>> map, AbstractProject src) { List<DependencyGroup> v = map.get(src); if(v==null) { return ImmutableList.of(); } else { ImmutableList.Builder<Dependency> builder = ImmutableList.builder(); for (DependencyGroup dependencyGroup : v) { builder.addAll(dependencyGroup.getGroup()); } return builder.build(); } }
private static List<IndexJoinNode.EquiJoinClause> createEquiJoinClause(List<Symbol> probeSymbols, List<Symbol> indexSymbols) { checkArgument(probeSymbols.size() == indexSymbols.size()); ImmutableList.Builder<IndexJoinNode.EquiJoinClause> builder = ImmutableList.builder(); for (int i = 0; i < probeSymbols.size(); i++) { builder.add(new IndexJoinNode.EquiJoinClause(probeSymbols.get(i), indexSymbols.get(i))); } return builder.build(); } }
private static List<ColumnStatistics> toFileStats(List<List<ColumnStatistics>> stripes) { if (stripes.isEmpty()) { return ImmutableList.of(); } int columnCount = stripes.get(0).size(); checkArgument(stripes.stream().allMatch(stripe -> columnCount == stripe.size())); ImmutableList.Builder<ColumnStatistics> fileStats = ImmutableList.builder(); for (int i = 0; i < columnCount; i++) { int column = i; fileStats.add(ColumnStatistics.mergeColumnStatistics(stripes.stream() .map(stripe -> stripe.get(column)) .collect(toList()))); } return fileStats.build(); }
@Test public void testQueryRewriteException() { config.setControlGateway(URL); Query invalidQuery = new Query( CATALOG, SCHEMA, ImmutableList.of("INSERT INTO test_table (a, b, c) values (10, 10.11, 'k')"), "INSERT INTO test_table (a, b, c) values (11, 11.12, 'l')", ImmutableList.of(), null, null, ImmutableMap.of()); List<QueryPair> rewrittenQueries = rewriteQueries(parser, config, ImmutableList.<QueryPair>builder() .addAll(queryPairs) .add(new QueryPair(QUERY_SUITE, QUERY_NAME, invalidQuery, invalidQuery)) .build()); assertEquals(rewrittenQueries.size(), queryPairs.size()); }
public FieldSetFilteringRecordSet(FunctionRegistry functionRegistry, RecordSet delegate, List<Set<Integer>> fieldSets) { requireNonNull(functionRegistry, "functionRegistry is null"); this.delegate = requireNonNull(delegate, "delegate is null"); ImmutableList.Builder<Set<Field>> fieldSetsBuilder = ImmutableList.builder(); List<Type> columnTypes = delegate.getColumnTypes(); for (Set<Integer> fieldSet : requireNonNull(fieldSets, "fieldSets is null")) { ImmutableSet.Builder<Field> fieldSetBuilder = ImmutableSet.builder(); for (int field : fieldSet) { fieldSetBuilder.add(new Field( field, functionRegistry.getScalarFunctionImplementation(internalOperator(OperatorType.EQUAL, BooleanType.BOOLEAN, ImmutableList.of(columnTypes.get(field), columnTypes.get(field)))).getMethodHandle())); } fieldSetsBuilder.add(fieldSetBuilder.build()); } this.fieldSets = fieldSetsBuilder.build(); }
private static Optional<List<DwrfSequenceEncoding>> toAdditionalSequenceEncodings(List<DwrfProto.ColumnEncoding> columnEncodings, OrcType type) { if (columnEncodings.size() == 1) { return Optional.empty(); } ImmutableList.Builder<DwrfSequenceEncoding> additionalSequenceEncodings = ImmutableList.builder(); for (int i = 1; i < columnEncodings.size(); i++) { additionalSequenceEncodings.add(toSequenceEncoding(type, columnEncodings.get(i))); } return Optional.of(additionalSequenceEncodings.build()); }
@Override public List<StreamDataOutput> getIndexStreams(CompressedMetadataWriter metadataWriter) throws IOException { checkState(closed); ImmutableList.Builder<RowGroupIndex> rowGroupIndexes = ImmutableList.builder(); List<FloatStreamCheckpoint> dataCheckpoints = dataStream.getCheckpoints(); Optional<List<BooleanStreamCheckpoint>> presentCheckpoints = presentStream.getCheckpoints(); for (int i = 0; i < rowGroupColumnStatistics.size(); i++) { int groupId = i; ColumnStatistics columnStatistics = rowGroupColumnStatistics.get(groupId); FloatStreamCheckpoint dataCheckpoint = dataCheckpoints.get(groupId); Optional<BooleanStreamCheckpoint> presentCheckpoint = presentCheckpoints.map(checkpoints -> checkpoints.get(groupId)); List<Integer> positions = createFloatColumnPositionList(compressed, dataCheckpoint, presentCheckpoint); rowGroupIndexes.add(new RowGroupIndex(positions, columnStatistics)); } Slice slice = metadataWriter.writeRowIndexes(rowGroupIndexes.build()); Stream stream = new Stream(column, StreamKind.ROW_INDEX, slice.length(), false); return ImmutableList.of(new StreamDataOutput(slice, stream)); }
private static List<Type> toTypes(List<? extends Type> sourceTypes, List<Integer> outputChannels, boolean generateRowNumber) { ImmutableList.Builder<Type> types = ImmutableList.builder(); for (int channel : outputChannels) { types.add(sourceTypes.get(channel)); } if (generateRowNumber) { types.add(BIGINT); } return types.build(); } }
private static List<Integer> getHashChannels(RowPagesBuilder probe, RowPagesBuilder build) { ImmutableList.Builder<Integer> hashChannels = ImmutableList.builder(); if (probe.getHashChannel().isPresent()) { hashChannels.add(probe.getHashChannel().get()); } if (build.getHashChannel().isPresent()) { hashChannels.add(probe.getTypes().size() + build.getHashChannel().get()); } return hashChannels.build(); }
private PhysicalOperation( OperatorFactory operatorFactory, Map<Symbol, Integer> layout, LocalExecutionPlanContext context, Optional<PhysicalOperation> source, PipelineExecutionStrategy pipelineExecutionStrategy) { requireNonNull(operatorFactory, "operatorFactory is null"); requireNonNull(layout, "layout is null"); requireNonNull(context, "context is null"); requireNonNull(source, "source is null"); requireNonNull(pipelineExecutionStrategy, "pipelineExecutionStrategy is null"); this.operatorFactories = ImmutableList.<OperatorFactory>builder() .addAll(source.map(PhysicalOperation::getOperatorFactories).orElse(ImmutableList.of())) .add(operatorFactory) .build(); this.layout = ImmutableMap.copyOf(layout); this.types = toTypes(layout, context); this.pipelineExecutionStrategy = pipelineExecutionStrategy; }
private List<MongoCredential> buildCredentials(Iterable<String> userPasses) { ImmutableList.Builder<MongoCredential> builder = ImmutableList.builder(); for (String userPass : userPasses) { List<String> values = USER_SPLITTER.splitToList(userPass); checkArgument(values.size() == 3, "Invalid Credential format. Requires user:password@collection"); builder.add(createCredential(values.get(0), values.get(2), values.get(1).toCharArray())); } return builder.build(); }
@Override public List<StreamDataOutput> getIndexStreams(CompressedMetadataWriter metadataWriter) throws IOException { checkState(closed); ImmutableList.Builder<RowGroupIndex> rowGroupIndexes = ImmutableList.builder(); List<ByteStreamCheckpoint> dataCheckpoints = dataStream.getCheckpoints(); Optional<List<BooleanStreamCheckpoint>> presentCheckpoints = presentStream.getCheckpoints(); for (int i = 0; i < rowGroupColumnStatistics.size(); i++) { int groupId = i; ColumnStatistics columnStatistics = rowGroupColumnStatistics.get(groupId); ByteStreamCheckpoint dataCheckpoint = dataCheckpoints.get(groupId); Optional<BooleanStreamCheckpoint> presentCheckpoint = presentCheckpoints.map(checkpoints -> checkpoints.get(groupId)); List<Integer> positions = createByteColumnPositionList(compressed, dataCheckpoint, presentCheckpoint); rowGroupIndexes.add(new RowGroupIndex(positions, columnStatistics)); } Slice slice = metadataWriter.writeRowIndexes(rowGroupIndexes.build()); Stream stream = new Stream(column, StreamKind.ROW_INDEX, slice.length(), false); return ImmutableList.of(new StreamDataOutput(slice, stream)); }
private String getSpatialPartitioning(Rectangle extent, List<OGCGeometry> geometries, int partitionCount) { ImmutableList.Builder<Rectangle> rectangles = ImmutableList.builder(); for (OGCGeometry geometry : geometries) { Envelope envelope = new Envelope(); geometry.getEsriGeometry().queryEnvelope(envelope); rectangles.add(new Rectangle(envelope.getXMin(), envelope.getYMin(), envelope.getXMax(), envelope.getYMax())); } return KdbTreeUtils.toJson(buildKdbTree(roundToInt(geometries.size() * 1.0 / partitionCount, CEILING), extent, rectangles.build())); } }
public List<BenchmarkSchema> selectSchemas(Iterable<String> schemas) { if (schemaNameTemplates.isEmpty()) { return ImmutableList.of(); } ImmutableList.Builder<BenchmarkSchema> benchmarkSchemas = ImmutableList.builder(); for (RegexTemplate schemaNameTemplate : schemaNameTemplates) { for (String schema : schemas) { Optional<Map<String, String>> tags = schemaNameTemplate.parse(schema); if (tags.isPresent()) { benchmarkSchemas.add(new BenchmarkSchema(schema, tags.get())); } } } return benchmarkSchemas.build(); }
private ImmutableList<TypeToken<? super T>> boundsAsInterfaces(Type[] bounds) { ImmutableList.Builder<TypeToken<? super T>> builder = ImmutableList.builder(); for (Type bound : bounds) { @SuppressWarnings("unchecked") // upper bound of T TypeToken<? super T> boundType = (TypeToken<? super T>) of(bound); if (boundType.getRawType().isInterface()) { builder.add(boundType); } } return builder.build(); }