List of usage examples for com.google.common.collect Iterables concat
public static <T> Iterable<T> concat(final Iterable<? extends Iterable<? extends T>> inputs)
From source file:com.palantir.common.collect.IterableView.java
public IterableView<T> concat(Iterable<? extends T> b, Iterable<? extends T> c) { Preconditions.checkNotNull(b);//from w ww. java2 s . co m Preconditions.checkNotNull(c); return of(Iterables.concat(ImmutableList.of(delegate(), b, c))); }
From source file:com.eviware.loadui.impl.summary.sections.ProjectExecutionMetricsSection.java
public ProjectExecutionMetricsSection(ProjectItem project) { super("Execution Metrics"); addValue("Assertion Failure Ratio", getFailedAssertions(project)); addValue("Request Failure Ratio", getFailedRequests(project)); addTable("Runners", getRunnersMetrics(project)); Iterable<AssertionItem<?>> childAssertions = Iterables .concat(Iterables.transform(project.getChildren(), getAssertions)); Iterable<AssertionItem<?>> allAssertions = Iterables.concat(childAssertions, project.getAddon(AssertionAddon.class).getAssertions()); addTable("Assertions", new AssertionMetricsTableModel(allAssertions)); }
From source file:de.monticore.utils.NodeWithParent.java
@Override public Iterator<NodeWithParent<?>> iterator() { Iterator<NodeWithParent<?>> childIterator = Iterables.concat(children).iterator(); return Iterators.concat(Iterators.singletonIterator(this), childIterator); }
From source file:org.eclipse.viatra.query.runtime.matchers.psystem.queries.PDisjunction.java
/** * Returns all queries directly referred in the constraints. They are all required to evaluate this query * /*from ww w. ja va 2s.com*/ * @return a non-null, but possibly empty list of query definitions */ public Set<PQuery> getDirectReferredQueries() { Iterable<PQuery> queries = Iterables .concat(Iterables.transform(this.getBodies(), PQueries.directlyReferencedQueriesFunction())); return Sets.newHashSet(queries); }
From source file:org.calrissian.mango.accumulo.util.BatchScannerWithScanners.java
@Override public Iterator<Map.Entry<Key, Value>> iterator() { return Iterables.concat(Iterables.transform(ranges, new Function<Range, Iterable<Map.Entry<Key, Value>>>() { @Override//from ww w .jav a2 s .co m public Iterable<Map.Entry<Key, Value>> apply(Range range) { try { Scanner scanner = connector.createScanner(tableName, authorizations); scanner.setRange(range); //add iterator settings for (IterInfo iterInfo : serverSideIteratorList) { String iterName = iterInfo.getIterName(); IteratorSetting iteratorSetting = new IteratorSetting(iterInfo.getPriority(), iterName, iterInfo.getClassName()); iteratorSetting.addOptions(serverSideIteratorOptions.get(iterName)); scanner.addScanIterator(iteratorSetting); } //add fetched columns for (Column column : fetchedColumns) { scanner.fetchColumn(new Text(column.getColumnFamily()), new Text(column.getColumnQualifier())); } return scanner; } catch (TableNotFoundException e) { throw new RuntimeException(e); } } })).iterator(); }
From source file:brooklyn.location.docker.strategy.affinity.DockerAffinityRuleStrategy.java
@Override public List<DockerHostLocation> filterLocations(List<DockerHostLocation> locations, Entity entity) { List<DockerHostLocation> available = Lists.newArrayList(); // Select hosts that satisfy the affinity rules for (DockerHostLocation machine : locations) { Optional<List<String>> entityRules = Optional .fromNullable(entity.config().get(DockerHost.DOCKER_HOST_AFFINITY_RULES)); Optional<List<String>> hostRules = Optional .fromNullable(machine.getOwner().config().get(DockerHost.DOCKER_HOST_AFFINITY_RULES)); Optional<List<String>> infrastructureRules = Optional.fromNullable( machine.getOwner().getInfrastructure().config().get(DockerHost.DOCKER_HOST_AFFINITY_RULES)); Iterable<String> combined = Iterables.concat( Optional.presentInstances(ImmutableList.of(entityRules, hostRules, infrastructureRules))); AffinityRules rules = AffinityRules.rulesFor(entity).parse(combined); Iterable<Entity> entities = getBrooklynManagementContext().getEntityManager() .findEntities(EntityPredicates.locationsIncludes(machine)); if (Iterables.isEmpty(entities)) { if (rules.allowEmptyLocations()) { available.add(machine);/*from www . jav a 2 s. c o m*/ } } else { Iterable<Entity> filtered = Iterables.filter(entities, rules); if (Iterables.size(filtered) == Iterables.size(entities)) { available.add(machine); } } } if (LOG.isDebugEnabled()) { LOG.debug("Available Docker hosts: {}", Iterables.toString(available)); } return available; }
From source file:org.apache.mahout.cf.taste.example.kddcup.track1.svd.KDDCupFactorizablePreferences.java
@Override public Iterable<Preference> getPreferences() { Iterable<Iterable<Preference>> prefIterators = Iterables.transform(new DataFileIterable(dataFile), new Function<Pair<PreferenceArray, long[]>, Iterable<Preference>>() { @Override// ww w .j av a2 s . c o m public Iterable<Preference> apply(Pair<PreferenceArray, long[]> from) { return from.getFirst(); } }); return Iterables.concat(prefIterators); }
From source file:org.jclouds.aws.ec2.compute.strategy.AWSEC2DestroyNodeStrategy.java
@Override protected void destroyInstanceInRegion(String id, String region) { String spotId = id;//from ww w .j av a 2 s. c o m if (id.indexOf("sir-") != 0) { try { spotId = getOnlyElement( Iterables.concat(client.getInstanceApi().get().describeInstancesInRegion(region, id))) .getSpotInstanceRequestId(); credentialStore.remove("node#" + region + "/" + spotId); } catch (NoSuchElementException e) { } super.destroyInstanceInRegion(id, region); } else { client.getSpotInstanceApi().get().cancelSpotInstanceRequestsInRegion(region, spotId); credentialStore.remove("node#" + region + "/" + id); } }
From source file:com.github.rodionmoiseev.c10n.guice.C10NModule.java
private Set<URL> getPackageURLs() { Iterable<URL> packages = Iterables .concat(Iterables.transform(Arrays.asList(packagePrefixes), new Function<String, Set<URL>>() { @Override//www. j a va2 s . c o m public Set<URL> apply(String prefix) { return ClasspathHelper.forPackage(prefix); } })); return Sets.newHashSet(packages); }
From source file:org.elasticsearch.action.admin.indices.flush.SyncedFlushResponse.java
public SyncedFlushResponse(Map<String, List<ShardsSyncedFlushResult>> shardsResultPerIndex) { this.shardsResultPerIndex = ImmutableMap.copyOf(shardsResultPerIndex); this.shardCounts = calculateShardCounts(Iterables.concat(shardsResultPerIndex.values())); }