@Override public void close() { if (null != iterator) { iterator.close(); } }
@Override public T next() { if (!hasNext()) { throw new NoSuchElementException(); } index++; return iterator.next(); }
@Override public boolean hasNext() { final boolean withinLimit = (null == end || index < end); if (!withinLimit && !truncate && iterator.hasNext()) { // Throw an exception if we are - not within the limit, we don't want to truncate and there are items remaining. throw new LimitExceededException("Limit of " + end + " exceeded."); } final boolean hasNext = withinLimit && iterator.hasNext(); if (!hasNext) { close(); } return hasNext; }
.build(); final CloseableIterable<? extends Element> edges = graph.execute(query, user); final Element edge = edges.iterator().next(); final ReservoirItemsSketch<String> stringsSketch = ((com.yahoo.sketches.sampling.ReservoirItemsUnion) edge.getProperty("stringsSample")) .getResult(); .build(); final CloseableIterable<? extends Element> entities = graph.execute(query2, user); final Element entity = entities.iterator().next(); final ReservoirItemsSketch<String> neighboursSketch = ((com.yahoo.sketches.sampling.ReservoirItemsUnion) entity.getProperty("neighboursSample")) .getResult();
@Override public void close() { iterator.close(); }
.build(); final CloseableIterable<? extends Element> edges = graph.execute(query, user); final Element edge = edges.iterator().next(); final com.yahoo.sketches.quantiles.DoublesUnion doublesUnion = (com.yahoo.sketches.quantiles.DoublesUnion) edge.getProperty("doublesUnion"); final double[] quantiles = doublesUnion.getResult().getQuantiles(new double[]{0.25D, 0.5D, 0.75D}); .build(); final CloseableIterable<? extends Element> edges2 = graph.execute(query2, user); final Element edge2 = edges2.iterator().next(); final DoublesSketch doublesSketch2 = ((com.yahoo.sketches.quantiles.DoublesUnion) edge2.getProperty("doublesUnion")).getResult(); final double[] cdf = doublesSketch2.getCDF(new double[]{0.0D, 1.0D, 2.0D});
@Override public CloseableIterable<? extends Element> doOperation(final GetElements operation, final Context context, final Store store) throws OperationException { final CloseableIterable<? extends Element> result; final Iterable<? extends ElementId> input = operation.getInput(); if (null == input) { throw new OperationException("Operation input is undefined - please specify an input."); } else { final Iterator<? extends ElementId> inputIter = input.iterator(); if (inputIter.hasNext()) { result = doOperation(operation, (ParquetStore) store, context.getUser()); } else { result = new EmptyClosableIterable<>(); } if (inputIter instanceof CloseableIterator) { ((CloseableIterator) inputIter).close(); } } if (input instanceof CloseableIterable) { ((CloseableIterable) input).close(); } return result; }
.build(); final CloseableIterable<? extends Element> edges = graph.execute(query, user); final Element edge = edges.iterator().next(); final com.yahoo.sketches.frequencies.LongsSketch longsSketch = (com.yahoo.sketches.frequencies.LongsSketch) edge.getProperty("longsSketch"); final String estimates = "Edge A-B: 1L seen approximately " + longsSketch.getEstimate(1L)
new WriteUnsortedData(store, groupToSplitPoints).writeElements(inputIter); if (inputIter instanceof CloseableIterator) { ((CloseableIterator) inputIter).close();
.build(); final CloseableIterable<? extends Element> edges = graph.execute(query, user); final Element edge = edges.iterator().next(); final uk.gov.gchq.gaffer.time.TimestampSet timestampSet = (uk.gov.gchq.gaffer.time.TimestampSet) edge.getProperty("timestampSet"); final Instant earliest = timestampSet.getEarliest();
final CloseableIterable<? extends Element> allEntities2 = graph.execute(getAllEntities2, user); final CloseableIterator<? extends Element> it = allEntities2.iterator(); final Element entityDay1 = it.next(); final CompactSketch sketchDay1 = ((Union) entityDay1.getProperty("size")).getResult(); final Element entityDay2 = it.next(); final CompactSketch sketchDay2 = ((Union) entityDay2.getProperty("size")).getResult(); final double estimateDay1 = sketchDay1.getEstimate(); .build(); final CloseableIterable<? extends Element> allEntities = graph.execute(getAllEntities, user); final Element entity = allEntities.iterator().next(); final double unionSizeEstimate = ((Union) entity.getProperty("size")).getResult().getEstimate();
final Element roadUse10Cardinality = graph.execute(getCardinalities, user).iterator().next(); log("\nRoadUse edge cardinality at vertex 10:"); final String edgeGroup = (roadUse10Cardinality.getProperty("edgeGroup")).toString();
final Entity redCardinality = graph.execute(getCardinalities, user).iterator().next();