List of usage examples for com.google.common.collect ImmutableList.Builder addAll
boolean addAll(Collection<? extends E> c);
From source file:org.apache.druid.sql.calcite.planner.Rules.java
private static List<RelOptRule> baseRuleSet(final PlannerContext plannerContext, final QueryMaker queryMaker) { final PlannerConfig plannerConfig = plannerContext.getPlannerConfig(); final ImmutableList.Builder<RelOptRule> rules = ImmutableList.builder(); // Calcite rules. rules.addAll(DEFAULT_RULES); rules.addAll(MISCELLANEOUS_RULES);// w w w . ja v a2 s. com rules.addAll(CONSTANT_REDUCTION_RULES); rules.addAll(VOLCANO_ABSTRACT_RULES); rules.addAll(RELOPTUTIL_ABSTRACT_RULES); rules.addAll(SUB_QUERY_REMOVE_RULES); if (!plannerConfig.isUseApproximateCountDistinct()) { // We'll need this to expand COUNT DISTINCTs. // Avoid AggregateExpandDistinctAggregatesRule.INSTANCE; it uses grouping sets and we don't support those. rules.add(AggregateExpandDistinctAggregatesRule.JOIN); } if (plannerConfig.isUseFallback()) { rules.add(DruidRelToBindableRule.instance()); } rules.add(SortCollapseRule.instance()); rules.add(CaseFilteredAggregatorRule.instance()); rules.add(ProjectAggregatePruneUnusedCallRule.instance()); // Druid-specific rules. rules.add(new DruidTableScanRule(queryMaker)); rules.addAll(DruidRules.rules()); if (plannerConfig.getMaxSemiJoinRowsInMemory() > 0) { rules.add(DruidSemiJoinRule.instance()); } return rules.build(); }
From source file:com.spotify.heroic.lifecycle.ManyLifeCycle.java
public static LifeCycle of(final Iterable<LifeCycle> many) { final ImmutableList.Builder<LifeCycle> flattened = ImmutableList.builder(); for (final LifeCycle l : many) { if (l.equals(LifeCycle.EMPTY)) { continue; }//from w w w. jav a2 s . c o m if (l instanceof ManyLifeCycle) { flattened.addAll(((ManyLifeCycle) l).lifeCycles); continue; } flattened.add(l); } return new ManyLifeCycle(flattened.build()); }
From source file:com.facebook.presto.orc.writer.FloatColumnWriter.java
private static List<Integer> createFloatColumnPositionList(boolean compressed, FloatStreamCheckpoint dataCheckpoint, Optional<BooleanStreamCheckpoint> presentCheckpoint) { ImmutableList.Builder<Integer> positionList = ImmutableList.builder(); presentCheckpoint.ifPresent(// w w w. j a v a2s . c om booleanStreamCheckpoint -> positionList.addAll(booleanStreamCheckpoint.toPositionList(compressed))); positionList.addAll(dataCheckpoint.toPositionList(compressed)); return positionList.build(); }
From source file:io.prestosql.orc.writer.ByteColumnWriter.java
private static List<Integer> createByteColumnPositionList(boolean compressed, ByteStreamCheckpoint dataCheckpoint, Optional<BooleanStreamCheckpoint> presentCheckpoint) { ImmutableList.Builder<Integer> positionList = ImmutableList.builder(); presentCheckpoint.ifPresent(/*from www .j av a 2 s . c o m*/ booleanStreamCheckpoint -> positionList.addAll(booleanStreamCheckpoint.toPositionList(compressed))); positionList.addAll(dataCheckpoint.toPositionList(compressed)); return positionList.build(); }
From source file:io.prestosql.orc.writer.DoubleColumnWriter.java
private static List<Integer> createDoubleColumnPositionList(boolean compressed, DoubleStreamCheckpoint dataCheckpoint, Optional<BooleanStreamCheckpoint> presentCheckpoint) { ImmutableList.Builder<Integer> positionList = ImmutableList.builder(); presentCheckpoint.ifPresent(//from ww w. j a v a 2s. c o m booleanStreamCheckpoint -> positionList.addAll(booleanStreamCheckpoint.toPositionList(compressed))); positionList.addAll(dataCheckpoint.toPositionList(compressed)); return positionList.build(); }
From source file:io.prestosql.orc.writer.BooleanColumnWriter.java
private static List<Integer> createBooleanColumnPositionList(boolean compressed, BooleanStreamCheckpoint dataCheckpoint, Optional<BooleanStreamCheckpoint> presentCheckpoint) { ImmutableList.Builder<Integer> positionList = ImmutableList.builder(); presentCheckpoint.ifPresent(//from w w w. j a v a2 s . c o m booleanStreamCheckpoint -> positionList.addAll(booleanStreamCheckpoint.toPositionList(compressed))); positionList.addAll(dataCheckpoint.toPositionList(compressed)); return positionList.build(); }
From source file:io.prestosql.execution.buffer.PageSplitterUtil.java
private static List<Page> splitPage(Page page, long maxPageSizeInBytes, long previousPageSize) { checkArgument(page.getPositionCount() > 0, "page is empty"); checkArgument(maxPageSizeInBytes > 0, "maxPageSizeInBytes must be > 0"); // for Pages with certain types of Blocks (e.g., RLE blocks) the size in bytes may remain constant // through the recursive calls, which causes the recursion to only terminate when page.getPositionCount() == 1 // and create potentially a large number of Page's of size 1. So we check here that // if the size of the page doesn't improve from the previous call we terminate the recursion. if (page.getSizeInBytes() == previousPageSize || page.getSizeInBytes() <= maxPageSizeInBytes || page.getPositionCount() == 1) { return ImmutableList.of(page); }/*from w w w . j av a 2 s .c o m*/ ImmutableList.Builder<Page> outputPages = ImmutableList.builder(); long previousSize = page.getSizeInBytes(); int positionCount = page.getPositionCount(); int half = positionCount / 2; Page leftHalf = page.getRegion(0, half); outputPages.addAll(splitPage(leftHalf, maxPageSizeInBytes, previousSize)); Page rightHalf = page.getRegion(half, positionCount - half); outputPages.addAll(splitPage(rightHalf, maxPageSizeInBytes, previousSize)); return outputPages.build(); }
From source file:org.waveprotocol.box.server.persistence.blocks.impl.aggregator.AggregationLevel.java
private static AggregationJump concatenate(List<AggregationJump> toConcatenate, int level) { Preconditions.checkArgument(!toConcatenate.isEmpty(), "Operations list to concatenate size is empty"); VersionNode sourceVersion = toConcatenate.get(0).getSourceNode(); VersionNode targetVersion = toConcatenate.get(toConcatenate.size() - 1).getTargetNode(); ImmutableList.Builder<WaveletOperation> concatenated = ImmutableList.builder(); for (AggregationJump jump : toConcatenate) { if (jump.getOperations() != null) { concatenated.addAll(jump.getOperations()); }//w ww.j a v a2 s .co m } return new AggregationJump(sourceVersion, targetVersion, concatenated.build(), level, false); }
From source file:com.google.devtools.build.java.bazel.BazelJavaCompiler.java
private static JavaCompiler newInstance(final JavaCompiler delegate) { // We forward most operations to the JavaCompiler implementation in langtools.jar. return new JavaCompiler() { @Override/* w w w.ja v a 2 s . c o m*/ public CompilationTask getTask(Writer out, JavaFileManager fileManager, DiagnosticListener<? super JavaFileObject> diagnosticListener, Iterable<String> options, Iterable<String> classes, Iterable<? extends JavaFileObject> compilationUnits) { // We prepend bazel's default javacopts to user javacopts, // so that the user can override them. javac supports this // "last option wins" style of option override. ImmutableList.Builder<String> fullOptions = ImmutableList.builder(); fullOptions.addAll(getDefaultJavacopts()); if (options != null) { fullOptions.addAll(options); } return delegate.getTask(out, fileManager, diagnosticListener, fullOptions.build(), classes, compilationUnits); } @Override public StandardJavaFileManager getStandardFileManager( DiagnosticListener<? super JavaFileObject> diagnosticListener, Locale locale, Charset charset) { StandardJavaFileManager fileManager = delegate.getStandardFileManager(diagnosticListener, locale, charset); try { fileManager.setLocation(StandardLocation.PLATFORM_CLASS_PATH, // bootclasspath JavacBootclasspath.asFiles()); } catch (IOException e) { // Should never happen, according to javadocs for setLocation throw new RuntimeException(e); } return fileManager; } @Override public int run(InputStream in, OutputStream out, OutputStream err, String... arguments) { // prepend bazel's default javacopts to user arguments List<String> args = ImmutableList.<String>builder().addAll(getDefaultJavacopts()).add(arguments) .build(); return delegate.run(in, out, err, args.toArray(new String[0])); } @Override public Set<SourceVersion> getSourceVersions() { return delegate.getSourceVersions(); } @Override public int isSupportedOption(String option) { return delegate.isSupportedOption(option); } }; }
From source file:com.facebook.presto.operator.StreamingAggregationOperator.java
private static List<Type> toTypes(List<Type> groupByTypes, List<Aggregator> aggregates) { ImmutableList.Builder<Type> builder = ImmutableList.builder(); builder.addAll(groupByTypes); aggregates.stream().map(Aggregator::getType).forEach(builder::add); return builder.build(); }