default boolean tryAdvance(Consumer<? super OResult> action) { if (hasNext()) { action.accept(next()); return true; } return false; }
@Override public OResult next() { if (!hasNext()) { throw new IllegalStateException(); } OResult result = entity.next(); return result; }
@Override public OResult next() { OResultInternal result = (OResultInternal) source.next(); if (result != null) { calculate(result, ctx); } return result; }
@Override public OResult next() { OResult result = upstream.next(); if (result instanceof OResultInternal) { for (OUpdateItem item : items) { item.applyUpdate((OResultInternal) result, ctx); } } return result; }
@Override public OResult next() { if (!hasNext()) { throw new IllegalStateException(); } return finalResult.next(); }
@Override public OGremlinResult next() { OResult next = inner.next(); return new OGremlinResult(graph, next); }
@Override public OResult next() { if (finished) { throw new IllegalStateException(); } if (!lastFetch.hasNext()) { if (!fetchNext()) { throw new IllegalStateException(); } } return lastFetch.next(); }
@Override public OResult next() { OResult current = upstream.next(); current.getVertex().ifPresent(x -> x.moveTo(targetClass, targetCluster)); return current; }
@Override public long count(String documentCollection) { requireNonNull(documentCollection, "query is required"); try (ODatabaseSession tx = pool.acquire()) { String query = "select count(*) from ".concat(documentCollection); OResultSet command = tx.command(query); OResult next = command.next(); Object count = next.getProperty("count(*)"); return Number.class.cast(count).longValue(); } }
private List<ODocument> toList(OResultSet rs) { if (!rs.hasNext()) { return null; } List<ODocument> result = new ArrayList<>(); while (rs.hasNext()) { result.add((ODocument) rs.next().getElement().orElse(null)); } return result; }
@Override public boolean tryAdvance(Consumer<? super OVertex> action) { while (hasNext()) { OResult elem = next(); if (elem.isVertex()) { action.accept(elem.getVertex().get()); return true; } } return false; }
@Override public boolean tryAdvance(Consumer<? super OEdge> action) { while (hasNext()) { OResult nextElem = next(); if (nextElem != null && nextElem.isEdge()) { action.accept(nextElem.getEdge().get()); return true; } } return false; }
public void executeInternal() throws OCommandExecutionException { while (true) { OResultSet nextBlock = super.fetchNext(100); if (!nextBlock.hasNext()) { return; } while (nextBlock.hasNext()) { result.add(nextBlock.next()); } } }
public long rebuild() { try (OResultSet rs = getDatabase().command(String.format(QUERY_REBUILD, name))) { return (Long) rs.next().getProperty("totalIndexed"); } }
public boolean remove(final Object key) { try(OResultSet result = getDatabase().command(String.format(QUERY_REMOVE, name), key)) { if (!result.hasNext()) { return false; } return ((long) result.next().getProperty("count")) > 0; } }
public int remove(final OIdentifiable iRecord) { try (OResultSet rs = getDatabase().command(String.format(QUERY_REMOVE3, name, iRecord.getIdentity()), iRecord)) { return (Integer) rs.next().getProperty("value"); } }
public synchronized void load(final ODatabaseDocumentInternal db) { sequences.clear(); if (db.getMetadata().getImmutableSchemaSnapshot().existsClass(OSequence.CLASS_NAME)) { try (final OResultSet result = db.query("SELECT FROM " + OSequence.CLASS_NAME)) { while (result.hasNext()) { OResult res = result.next(); final OSequence sequence = OSequenceHelper.createSequence((ODocument) res.getElement().get()); sequences.put(sequence.getName().toUpperCase(Locale.ENGLISH), sequence); } } } }
public long count(final Object iKey) { try (final OResultSet result = getDatabase().indexQuery(getName(), String.format(QUERY_COUNT, name), iKey)) { if (!result.hasNext()) { return 0; } return (Long) result.next().getProperty("size"); } }
public long getKeySize() { try (OResultSet result = getDatabase().indexQuery(getName(), String.format(QUERY_KEY_SIZE, name))) { if (result.hasNext()) return (Long) result.next().getProperty("size"); } return 0; }
public boolean contains(final Object iKey) { try (final OResultSet result = getDatabase().indexQuery(getName(), String.format(QUERY_CONTAINS, name), iKey)) { if (!result.hasNext()) { return false; } return (Long) result.next().getProperty("size") > 0; } }