List of usage examples for com.google.common.collect Iterators emptyIterator
@Deprecated public static <T> UnmodifiableIterator<T> emptyIterator()
From source file:gr.forth.ics.swkm.model2.index.TreeMapModelIndexer.java
public Iterator<Triple> findTriples(Resource namedGraph, ObjectNode subject, Resource predicate, RdfNode object) {//from www.j av a 2s . c om Iterable<Triple> triples = findTriples(subject, predicate, object); if (triples == null) { return Iterators.emptyIterator(); } if (namedGraph == null) { return triples.iterator(); } // namedGraph != null if (triples == spo) { // all the triples are selected return graphIndexer.get(namedGraph).iterator(); } return AbstractModelIndexer.findTriples(triples, namedGraph); }
From source file:org.apache.tajo.engine.planner.physical.CommonJoinExec.java
/** * Return an tuple iterator filters rows in a right table by using a join filter. * It must takes rows of a right table./*from ww w.j a v a2 s .c o m*/ * * @param rightTuples Tuple iterator * @return rows Filtered by a join filter on right table. */ protected Iterator<Tuple> rightFiltered(Iterable<Tuple> rightTuples) { if (rightTuples == null) { return Iterators.emptyIterator(); } if (rightJoinFilter == null) { return rightTuples.iterator(); } return Iterators.filter(rightTuples.iterator(), new Predicate<Tuple>() { @Override public boolean apply(Tuple input) { return rightJoinFilter.eval(input).isTrue(); } }); }
From source file:org.locationtech.geogig.api.plumbing.DiffTree.java
/** * Finds differences between the two specified trees. * /*from w w w . ja v a2 s . c o m*/ * @return an iterator to a set of differences between the two trees * @see DiffEntry */ @Override protected Iterator<DiffEntry> _call() throws IllegalArgumentException { checkNotNull(oldRefSpec, "old version not specified"); checkNotNull(newRefSpec, "new version not specified"); final RevTree oldTree = resolveTree(oldRefSpec); final RevTree newTree = resolveTree(newRefSpec); if (oldTree.equals(newTree)) { return Iterators.emptyIterator(); } ObjectDatabase leftSource = objectDatabase(); ObjectDatabase rightSource = objectDatabase(); final PreOrderDiffWalk visitor = new PreOrderDiffWalk(oldTree, newTree, leftSource, rightSource); final BlockingQueue<DiffEntry> queue = new ArrayBlockingQueue<>(100); final DiffEntryProducer diffProducer = new DiffEntryProducer(queue); diffProducer.setReportTrees(this.reportTrees); diffProducer.setRecursive(this.recursive); final List<RuntimeException> producerErrors = new LinkedList<>(); Thread producerThread = new Thread("DiffTree producer thread") { @Override public void run() { Consumer consumer = diffProducer; if (customFilter != null) {// evaluated the latest consumer = new PreOrderDiffWalk.FilteringConsumer(consumer, customFilter); } if (changeTypeFilter != null) { consumer = new ChangeTypeFilteringDiffConsumer(changeTypeFilter, consumer); } if (boundsFilter != null) { consumer = new BoundsFilteringDiffConsumer(boundsFilter, consumer, objectDatabase()); } if (!pathFilters.isEmpty()) {// evaluated the former consumer = new PathFilteringDiffConsumer(pathFilters, consumer); } try { visitor.walk(consumer); } catch (RuntimeException e) { LOGGER.error("Error traversing diffs", e); producerErrors.add(e); } finally { diffProducer.finished = true; } } }; producerThread.setDaemon(true); producerThread.start(); Iterator<DiffEntry> consumerIterator = new AbstractIterator<DiffEntry>() { @Override protected DiffEntry computeNext() { if (!producerErrors.isEmpty()) { throw new RuntimeException("Error in producer thread", producerErrors.get(0)); } BlockingQueue<DiffEntry> entries = queue; boolean finished = diffProducer.isFinished(); boolean empty = entries.isEmpty(); while (!finished || !empty) { try { DiffEntry entry = entries.poll(10, TimeUnit.MILLISECONDS); if (entry != null) { return entry; } finished = diffProducer.isFinished(); empty = entries.isEmpty(); } catch (InterruptedException e) { throw Throwables.propagate(e); } } return endOfData(); } @Override protected void finalize() { diffProducer.finished = true; } }; return consumerIterator; }
From source file:org.sakaiproject.nakamura.resource.lite.LiteResourceResolver.java
/** * {@inheritDoc}/*from w w w . j a v a 2s . c o m*/ * * @see org.apache.sling.api.resource.ResourceResolver#findResources(java.lang.String, * java.lang.String) */ public Iterator<Resource> findResources(String query, String language) { return Iterators.emptyIterator(); }
From source file:org.locationtech.geogig.cli.porcelain.Diff.java
/** * Executes the diff command with the specified options. */// ww w . j a va 2 s .c om @Override protected void runInternal(GeogigCLI cli) throws IOException { checkParameter(refSpec.size() <= 2, "Commit list is too long :%s", refSpec); checkParameter(!(nogeom && summary), "Only one printing mode allowed"); checkParameter(!(bounds && count), "Only one of --bounds or --count is allowed"); checkParameter(!(cached && refSpec.size() > 1), "--cached allows zero or one ref specs to compare the index with."); GeoGIG geogig = cli.getGeogig(); String oldVersion = resolveOldVersion(); String newVersion = resolveNewVersion(); List<String> paths = removeEmptyPaths(); if (bounds) { DiffBounds diff = geogig.command(DiffBounds.class).setOldVersion(oldVersion).setNewVersion(newVersion) .setCompareIndex(cached); diff.setPathFilters(paths); CoordinateReferenceSystem crs = parseCrs(); if (crs != null) { diff.setCRS(crs); } DiffSummary<BoundingBox, BoundingBox> diffBounds = diff.call(); BoundsDiffPrinter.print(geogig, cli.getConsole(), diffBounds); return; } if (count) { if (oldVersion == null) { oldVersion = Ref.HEAD; } if (newVersion == null) { newVersion = cached ? Ref.STAGE_HEAD : Ref.WORK_HEAD; } DiffCount cdiff = geogig.command(DiffCount.class).setOldVersion(oldVersion).setNewVersion(newVersion); cdiff.setFilter(paths); DiffObjectCount count = cdiff.call(); ConsoleReader console = cli.getConsole(); console.println(String.format("Trees changed: %d, features changed: %,d", count.treeCount(), count.featureCount())); console.flush(); return; } DiffOp diff = geogig.command(DiffOp.class); diff.setOldVersion(oldVersion).setNewVersion(newVersion).setCompareIndex(cached); Iterator<DiffEntry> entries; if (paths.isEmpty()) { entries = diff.setProgressListener(cli.getProgressListener()).call(); } else { entries = Iterators.emptyIterator(); for (String path : paths) { Iterator<DiffEntry> moreEntries = diff.setFilter(path) .setProgressListener(cli.getProgressListener()).call(); entries = Iterators.concat(entries, moreEntries); } } if (!entries.hasNext()) { cli.getConsole().println("No differences found"); return; } DiffPrinter printer; if (summary) { printer = new SummaryDiffPrinter(); } else { printer = new FullDiffPrinter(nogeom, false); } DiffEntry entry; while (entries.hasNext()) { entry = entries.next(); printer.print(geogig, cli.getConsole(), entry); } }
From source file:org.elasticsearch.action.termvector.TermVectorResponse.java
public Fields getFields() throws IOException { if (hasTermVectors() && isExists()) { if (!sourceCopied) { // make the bytes safe headerRef = headerRef.copyBytesArray(); termVectors = termVectors.copyBytesArray(); }/* w ww . ja v a 2 s . c o m*/ return new TermVectorFields(headerRef, termVectors); } else { return new Fields() { @Override public Iterator<String> iterator() { return Iterators.emptyIterator(); } @Override public Terms terms(String field) throws IOException { return null; } @Override public int size() { return 0; } }; } }
From source file:org.eclipse.emf.compare.match.DefaultMatchEngine.java
/** * This will only query the scope for the given Resources' children, then delegate to an * {@link IEObjectMatcher} to determine the EObject matches. * <p>/*from w w w . j a va 2s . c om*/ * We expect at least two of the given resources not to be <code>null</code>. * </p> * * @param left * The left {@link Resource}. Can be <code>null</code>. * @param right * The right {@link Resource}. Can be <code>null</code>. * @param origin * The common ancestor of <code>left</code> and <code>right</code>. Can be <code>null</code>. */ protected void match(Resource left, Resource right, Resource origin) { // We need at least two resources to match them if (atLeastTwo(left == null, right == null, origin == null)) { /* * TODO But if we have only one resource, which is then unmatched, should we not still do * something with it? */ return; } final Iterator<? extends EObject> leftEObjects; if (left != null) { leftEObjects = getScope().getCoveredEObjects(left); } else { leftEObjects = Iterators.emptyIterator(); } final Iterator<? extends EObject> rightEObjects; if (right != null) { rightEObjects = getScope().getCoveredEObjects(right); } else { rightEObjects = Iterators.emptyIterator(); } final Iterator<? extends EObject> originEObjects; if (origin != null) { originEObjects = getScope().getCoveredEObjects(origin); } else { originEObjects = Iterators.emptyIterator(); } final IEObjectMatcher matcher = createEObjectMatcher(); final Iterable<Match> matches = matcher.createMatches(leftEObjects, rightEObjects, originEObjects); Iterables.addAll(getComparison().getMatches(), matches); }
From source file:gobblin.data.management.copy.hive.HiveDataset.java
@Override public Iterator<FileSet<CopyEntity>> getFileSetIterator(FileSystem targetFs, CopyConfiguration configuration) throws IOException { if (!canCopyTable()) { return Iterators.emptyIterator(); }/*from ww w.j av a 2s . c o m*/ try { return new HiveCopyEntityHelper(this, configuration, targetFs).getCopyEntities(configuration); } catch (IOException ioe) { log.error("Failed to copy table " + this.table, ioe); return Iterators.emptyIterator(); } }
From source file:org.sakaiproject.nakamura.resource.lite.LiteResourceResolver.java
/** * {@inheritDoc}//from ww w. j a v a2 s . c o m * * @see org.apache.sling.api.resource.ResourceResolver#queryResources(java.lang.String, * java.lang.String) */ public Iterator<Map<String, Object>> queryResources(String query, String language) { return Iterators.emptyIterator(); }
From source file:org.apache.rya.mongodb.iter.RyaStatementBindingSetCursorIterator.java
private void submitBatchQuery() { int count = 0; executedRangeMap.clear();// www . j a va2s. co m final List<Document> pipeline = new ArrayList<>(); final List<DBObject> match = new ArrayList<>(); while (queryIterator.hasNext() && count < QUERY_BATCH_SIZE) { count++; RyaStatement query = queryIterator.next(); executedRangeMap.putAll(query, rangeMap.get(query)); final DBObject currentQuery = strategy.getQuery(query); match.add(currentQuery); } if (match.size() > 1) { pipeline.add(new Document("$match", new Document("$or", match))); } else if (match.size() == 1) { pipeline.add(new Document("$match", match.get(0))); } else { batchQueryResultsIterator = Iterators.emptyIterator(); return; } // Executing redact aggregation to only return documents the user has access to. pipeline.addAll(AggregationUtil.createRedactPipeline(auths)); log.info(pipeline); final AggregateIterable<Document> aggIter = coll.aggregate(pipeline); aggIter.batchSize(1000); batchQueryResultsIterator = aggIter.iterator(); }