List of usage examples for com.google.common.collect Iterators transform
public static <F, T> Iterator<T> transform(final Iterator<F> fromIterator, final Function<? super F, ? extends T> function)
From source file:gobblin.util.request_allocation.BruteForceAllocator.java
@Override protected Iterator<T> getJoinIterator(Iterator<? extends Requestor<T>> requestors, ConcurrentBoundedPriorityIterable<T> requestIterable) { return Iterators.concat(Iterators.transform(requestors, new Function<Requestor<T>, Iterator<T>>() { @Nullable/*from w ww .jav a 2 s . c om*/ @Override public Iterator<T> apply(Requestor<T> input) { return input.iterator(); } })); }
From source file:ch.ethz.inf.vs.hypermedia.client.utils.DFSCrawler.java
public Iterator<B> process(B item, Set<Object> visited) { if (isPostOrder()) { Iterator<B> children = Iterators .concat(Iterators.transform(internalGetChildren(item, visited), (x) -> process(x, visited))); return Iterators.concat(children, Iterators.singletonIterator(item)); } else {/*from w ww. ja v a 2 s .c om*/ Iterator<B> children = Iterators.concat( Iterators.transform(internalGetChildren(item, visited), (item1) -> process(item1, visited))); return Iterators.concat(Iterators.singletonIterator(item), children); } }
From source file:com.palantir.giraffe.ssh.internal.SshDirectoryStream.java
@Override protected Iterator<Path> entryIterator() { return Iterators.transform(entryIterator, new Function<RemoteResourceInfo, Path>() { @Override/*from w ww.ja v a 2s .co m*/ public Path apply(RemoteResourceInfo input) { return dir.resolve(input.getName()); } }); }
From source file:com.proofpoint.event.collector.combiner.S3ObjectListing.java
@Override public Iterator<S3ObjectSummary> iterator() { Iterator<ObjectListing> objectListings = new AbstractSequentialIterator<ObjectListing>( s3Client.listObjects(listObjectsRequest)) { @Override// ww w . java2 s . c o m protected ObjectListing computeNext(ObjectListing previous) { if (!previous.isTruncated()) { return null; } return s3Client.listNextBatchOfObjects(previous); } }; return Iterators.concat( Iterators.transform(objectListings, new Function<ObjectListing, Iterator<S3ObjectSummary>>() { @Override public Iterator<S3ObjectSummary> apply(ObjectListing input) { return input.getObjectSummaries().iterator(); } })); }
From source file:sf.net.experimaestro.manager.plans.Constant.java
@Override protected Iterator<ReturnValue> _iterator(ScriptContext scriptContext) { return Iterators.transform(values.iterator(), input -> new ReturnValue(null, input)); }
From source file:uk.ac.ed.inf.ace.processors.CleanTokens.java
@Override public ReadWriteableDocument process(ReadWriteableDocument document) { @SuppressWarnings("unchecked") Iterator<String> tokens = (Iterator<String>) document.getContent(); document.setContent(Iterators.filter(Iterators.transform(tokens, NULL_TO_EMPTY), IS_NOT_EMPTY)); return document; }
From source file:org.apache.accumulo.shell.commands.NamespacesCommand.java
@Override public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws AccumuloException, AccumuloSecurityException, IOException { Map<String, String> namespaces = new TreeMap<String, String>( shellState.getConnector().namespaceOperations().namespaceIdMap()); Iterator<String> it = Iterators.transform(namespaces.entrySet().iterator(), entry -> { String name = entry.getKey(); if (Namespaces.DEFAULT_NAMESPACE.equals(name)) name = DEFAULT_NAMESPACE_DISPLAY_NAME; String id = entry.getValue(); if (cl.hasOption(namespaceIdOption.getOpt())) return String.format(TablesCommand.NAME_AND_ID_FORMAT, name, id); else//www . ja v a 2 s.c o m return name; }); shellState.printLines(it, !cl.hasOption(disablePaginationOpt.getOpt())); return 0; }
From source file:org.commoncrawl.mapred.pipelineV3.domainmeta.linkstats.UniqueIncomingRootDomainCounter.java
@Override public void reduce(TextBytes key, Iterator<TextBytes> values, OutputCollector<TextBytes, TextBytes> output, Reporter reporter) throws IOException { HashSet<String> rootDomainList = new HashSet<String>(); Iterators.addAll(rootDomainList, Iterators.transform(values, new Function<TextBytes, String>() { @Override//from w ww .jav a 2 s. c om public String apply(TextBytes arg0) { return arg0.toString(); } })); JsonObject jsonObject = new JsonObject(); JsonArray jsonArray = new JsonArray(); jsonObject.addProperty("domain-count", rootDomainList.size()); for (String domain : rootDomainList) { jsonArray.add(new JsonPrimitive(domain)); } jsonObject.add("domains", jsonArray); if (rootDomainList.size() != 0) { output.collect(key, new TextBytes(jsonObject.toString())); } }
From source file:org.geogit.di.ObjectDatabasePutInterceptor.java
private Object putAllInterceptor(MethodInvocation invocation) throws Throwable { Object[] arguments = invocation.getArguments(); @SuppressWarnings("unchecked") final Iterator<? extends RevObject> objects = (Iterator<? extends RevObject>) arguments[0]; final Iterator<? extends RevObject> sideEffectIterator; final List<RevCommit> addedCommits = Lists.newLinkedList(); sideEffectIterator = Iterators.transform(objects, new Function<RevObject, RevObject>() { @Override/*from w w w.j a va 2 s . c o m*/ public RevObject apply(RevObject input) { if (input instanceof RevCommit) { addedCommits.add((RevCommit) input); } return input; } }); arguments[0] = sideEffectIterator; Object result = invocation.proceed(); if (!addedCommits.isEmpty()) { GraphDatabase graphDatabase = graphDb.get(); for (RevCommit commit : addedCommits) { ObjectId commitId = commit.getId(); ImmutableList<ObjectId> parentIds = commit.getParentIds(); graphDatabase.put(commitId, parentIds); } } return result; }
From source file:org.apache.fluo.core.impl.scanner.RowScannerImpl.java
@Override public Iterator<ColumnScanner> iterator() { RowIterator rowiter = new RowIterator(snapshot.iterator()); return Iterators.transform(rowiter, e -> new ColumnScannerImpl(e, columnConverter)); }