List of usage examples for com.google.common.collect ImmutableList.Builder addAll
boolean addAll(Collection<? extends E> c);
From source file:com.facebook.buck.cxx.CxxPlatforms.java
public static Iterable<BuildTarget> getParseTimeDeps(CxxPlatform cxxPlatform) { ImmutableList.Builder<BuildTarget> deps = ImmutableList.builder(); deps.addAll(cxxPlatform.getAspp().getParseTimeDeps()); deps.addAll(cxxPlatform.getAs().getParseTimeDeps()); deps.addAll(cxxPlatform.getCpp().getParseTimeDeps()); deps.addAll(cxxPlatform.getCc().getParseTimeDeps()); deps.addAll(cxxPlatform.getCxxpp().getParseTimeDeps()); deps.addAll(cxxPlatform.getCxx().getParseTimeDeps()); if (cxxPlatform.getCudapp().isPresent()) { deps.addAll(cxxPlatform.getCudapp().get().getParseTimeDeps()); }/* w w w . ja v a 2 s. c o m*/ if (cxxPlatform.getCuda().isPresent()) { deps.addAll(cxxPlatform.getCuda().get().getParseTimeDeps()); } if (cxxPlatform.getAsmpp().isPresent()) { deps.addAll(cxxPlatform.getAsmpp().get().getParseTimeDeps()); } if (cxxPlatform.getAsm().isPresent()) { deps.addAll(cxxPlatform.getAsm().get().getParseTimeDeps()); } deps.addAll(cxxPlatform.getLd().getParseTimeDeps()); cxxPlatform.getSharedLibraryInterfaceFactory().ifPresent(f -> deps.addAll(f.getParseTimeDeps())); return deps.build(); }
From source file:net.hydromatic.optiq.util.graph.Graphs.java
/** Returns a map of the shortest paths between any pair of nodes. */ public static <V, E extends DefaultEdge> FrozenGraph<V, E> makeImmutable(DirectedGraph<V, E> graph) { DefaultDirectedGraph<V, E> graph1 = (DefaultDirectedGraph<V, E>) graph; Map<Pair<V, V>, List<V>> shortestPaths = new HashMap<Pair<V, V>, List<V>>(); for (DefaultDirectedGraph.VertexInfo<V, E> arc : graph1.vertexMap.values()) { for (E edge : arc.outEdges) { final V source = graph1.source(edge); final V target = graph1.target(edge); shortestPaths.put(Pair.of(source, target), ImmutableList.of(source, target)); }// w w w . ja v a 2 s. c o m } while (true) { // Take a copy of the map's keys to avoid // ConcurrentModificationExceptions. final List<Pair<V, V>> previous = ImmutableList.copyOf(shortestPaths.keySet()); int changeCount = 0; for (E edge : graph.edgeSet()) { for (Pair<V, V> edge2 : previous) { if (edge.target.equals(edge2.left)) { final Pair<V, V> key = Pair.of(graph1.source(edge), edge2.right); List<V> bestPath = shortestPaths.get(key); List<V> arc2Path = shortestPaths.get(edge2); if ((bestPath == null) || (bestPath.size() > (arc2Path.size() + 1))) { ImmutableList.Builder<V> newPath = ImmutableList.builder(); newPath.add(graph1.source(edge)); newPath.addAll(arc2Path); shortestPaths.put(key, newPath.build()); changeCount++; } } } } if (changeCount == 0) { break; } } return new FrozenGraph<V, E>(graph1, shortestPaths); }
From source file:org.prebake.core.GlobSet.java
private static void iterateOnto(PrefixTree t, ImmutableList.Builder<? super Glob> out) { out.addAll(t.globsByExtension.values()); for (PrefixTree child : t.children.values()) { iterateOnto(child, out);/*from www. j av a 2 s . com*/ } }
From source file:io.prestosql.orc.writer.LongColumnWriter.java
private static List<Integer> createLongColumnPositionList(boolean compressed, LongStreamCheckpoint dataCheckpoint, Optional<BooleanStreamCheckpoint> presentCheckpoint) { ImmutableList.Builder<Integer> positionList = ImmutableList.builder(); presentCheckpoint.ifPresent(// www. j ava2 s.c om booleanStreamCheckpoint -> positionList.addAll(booleanStreamCheckpoint.toPositionList(compressed))); positionList.addAll(dataCheckpoint.toPositionList(compressed)); return positionList.build(); }
From source file:com.gradleware.tooling.testing.Combinations.java
private static ImmutableList<List<Object>> getCombinationsRecursive(Map<Integer, List<?>> lists, int depth, Object[] current) {/*from ww w . j a va2 s. c om*/ ImmutableList.Builder<List<Object>> result = ImmutableList.builder(); Collection<?> listAtCurrentDepth = lists.get(depth); for (Object element : listAtCurrentDepth) { current[depth] = element; if (depth < lists.size() - 1) { result.addAll(getCombinationsRecursive(lists, depth + 1, current)); } else { result.add(Lists.newArrayList(current)); // use ArrayList to support null values } } return result.build(); }
From source file:com.facebook.buck.cxx.AbstractNativeLinkableInput.java
/** * Combine, in order, several {@link NativeLinkableInput} objects into a single one. *///from ww w .j av a2 s . co m public static NativeLinkableInput concat(Iterable<NativeLinkableInput> items) { ImmutableList.Builder<Arg> args = ImmutableList.builder(); ImmutableSet.Builder<FrameworkPath> frameworks = ImmutableSet.builder(); ImmutableSet.Builder<FrameworkPath> libraries = ImmutableSet.builder(); for (NativeLinkableInput item : items) { args.addAll(item.getArgs()); frameworks.addAll(item.getFrameworks()); libraries.addAll(item.getLibraries()); } return NativeLinkableInput.of(args.build(), frameworks.build(), libraries.build()); }
From source file:io.prestosql.plugin.accumulo.model.Row.java
/** * Converts the given String into a Java object based on the given Presto type * * @param str String to convert//from w w w . j a v a 2 s.com * @param type Presto Type * @return Java object * @throws PrestoException If the type is not supported by this function */ public static Object valueFromString(String str, Type type) { if (str == null || str.isEmpty()) { return null; } else if (Types.isArrayType(type)) { Type elementType = Types.getElementType(type); ImmutableList.Builder<Object> listBuilder = ImmutableList.builder(); for (String element : Splitter.on(',').split(str)) { listBuilder.add(valueFromString(element, elementType)); } return AccumuloRowSerializer.getBlockFromArray(elementType, listBuilder.build()); } else if (Types.isMapType(type)) { Type keyType = Types.getKeyType(type); Type valueType = Types.getValueType(type); ImmutableMap.Builder<Object, Object> mapBuilder = ImmutableMap.builder(); for (String element : Splitter.on(',').split(str)) { ImmutableList.Builder<String> builder = ImmutableList.builder(); List<String> keyValue = builder.addAll(Splitter.on("->").split(element)).build(); checkArgument(keyValue.size() == 2, format("Map element %s has %d entries, not 2", element, keyValue.size())); mapBuilder.put(valueFromString(keyValue.get(0), keyType), valueFromString(keyValue.get(1), valueType)); } return AccumuloRowSerializer.getBlockFromMap(type, mapBuilder.build()); } else if (type.equals(BIGINT)) { return Long.parseLong(str); } else if (type.equals(BOOLEAN)) { return Boolean.parseBoolean(str); } else if (type.equals(DATE)) { return new Date(DATE_PARSER.parseDateTime(str).getMillis()); } else if (type.equals(DOUBLE)) { return Double.parseDouble(str); } else if (type.equals(INTEGER)) { return Integer.parseInt(str); } else if (type.equals(REAL)) { return Float.parseFloat(str); } else if (type.equals(SMALLINT)) { return Short.parseShort(str); } else if (type.equals(TIME)) { return new Time(TIME_PARSER.parseDateTime(str).getMillis()); } else if (type.equals(TIMESTAMP)) { return new Timestamp(TIMESTAMP_PARSER.parseDateTime(str).getMillis()); } else if (type.equals(TINYINT)) { return Byte.valueOf(str); } else if (type.equals(VARBINARY)) { return str.getBytes(UTF_8); } else if (type instanceof VarcharType) { return str; } else { throw new PrestoException(NOT_SUPPORTED, "Unsupported type " + type); } }
From source file:com.facebook.buck.cxx.CxxLinkableEnhancer.java
public static CxxLink createCxxLinkableSharedBuildRule(CxxBuckConfig cxxBuckConfig, CxxPlatform cxxPlatform, BuildRuleParams params, BuildRuleResolver ruleResolver, final SourcePathResolver resolver, SourcePathRuleFinder ruleFinder, BuildTarget target, Path output, Optional<String> soname, ImmutableList<? extends Arg> args) { ImmutableList.Builder<Arg> linkArgsBuilder = ImmutableList.builder(); linkArgsBuilder.addAll(cxxPlatform.getLd().resolve(ruleResolver).getSharedLibFlag()); if (soname.isPresent()) { linkArgsBuilder.addAll(StringArg.from(cxxPlatform.getLd().resolve(ruleResolver).soname(soname.get()))); }//from w w w . ja va 2s . co m linkArgsBuilder.addAll(args); ImmutableList<Arg> linkArgs = linkArgsBuilder.build(); return createCxxLinkableBuildRule(cxxBuckConfig, cxxPlatform, params, ruleResolver, resolver, ruleFinder, target, output, linkArgs, Linker.LinkableDepType.SHARED, Optional.empty()); }
From source file:com.tage.calcite.adapter.druid.DruidRules.java
public static com.tage.calcite.adapter.druid.DruidQuery extendQuery( com.tage.calcite.adapter.druid.DruidQuery query, RelNode r) { final ImmutableList.Builder<RelNode> builder = ImmutableList.builder(); return DruidQuery.create(query.getCluster(), query.getTraitSet(), query.getTable(), query.druidTable, builder.addAll(query.rels).add(r).build()); }
From source file:com.spectralogic.ds3client.helpers.ReadJobImpl.java
protected static ImmutableList<BulkObject> getAllBlobApiBeans(final List<Objects> jobWithChunksApiBeans) { ImmutableList.Builder<BulkObject> builder = ImmutableList.builder(); for (final Objects objects : jobWithChunksApiBeans) { builder.addAll(objects.getObjects()); }/* w ww . j a v a2s.c om*/ return builder.build(); }