cursor = arangoDB.db(databaseName).query(aqlQuery, bindVars, null, VPackSlice.class); while (cursor.hasNext()) { VPackSlice aDocument = cursor.next(); HashMap<String, ByteIterator> aMap = new HashMap<String, ByteIterator>(aDocument.size()); if (!this.fillMap(aMap, aDocument)) {
private Object getNext(final ArangoCursor<?> cursor) { return cursor.hasNext() ? cursor.next() : null; } }
private Object getNext(final ArangoCursor<?> cursor) { return cursor.hasNext() ? cursor.next() : null; } }
/** * Finds one document which matches the given example object * * @param example * example object to construct query with * @param <S> * @return An object representing the example if it exists, else null */ @Override public <S extends T> Optional<S> findOne(final Example<S> example) { final ArangoCursor cursor = findAllInternal((Pageable) null, example, new HashMap()); return cursor.hasNext() ? Optional.ofNullable((S) cursor.next()) : Optional.empty(); }
/** * Finds one document which matches the given example object * * @param example * example object to construct query with * @param <S> * @return An object representing the example if it exists, else null */ @Override public <S extends T> Optional<S> findOne(final Example<S> example) { final ArangoCursor cursor = findAllInternal((Pageable) null, example, new HashMap()); return cursor.hasNext() ? Optional.ofNullable((S) cursor.next()) : Optional.empty(); }
@SuppressWarnings("unchecked") @Override public IType next() { ArangoDBBaseDocument next = null; next = (ArangoDBBaseDocument) delegate.next(); next.graph(graph); next.setPaired(true); return (IType) next; }
@SuppressWarnings("unchecked") @Override public P next() { ArangoDBElementProperty<V> next = null; next = (ArangoDBElementProperty<V>) delegate.next(); next.graph(graph); next.setPaired(true); return (P) next; }
/** * Counts the number of documents in the collection which match with the given example * * @param example * example object to construct query with * @param <S> * @return number of matching documents found */ @Override public <S extends T> long count(final Example<S> example) { final Map<String, Object> bindVars = new HashMap<>(); final String predicate = exampleConverter.convertExampleToPredicate(example, bindVars); final String filter = predicate.length() == 0 ? "" : " FILTER " + predicate; final String query = String.format("FOR e IN %s%s COLLECT WITH COUNT INTO length RETURN length", getCollectionName(), filter); final ArangoCursor<Long> cursor = arangoOperations.query(query, bindVars, null, Long.class); return cursor.next(); }
/** * Counts the number of documents in the collection which match with the given example * * @param example * example object to construct query with * @param <S> * @return number of matching documents found */ @Override public <S extends T> long count(final Example<S> example) { final Map<String, Object> bindVars = new HashMap<>(); final String predicate = exampleConverter.convertExampleToPredicate(example, bindVars); final String filter = predicate.length() == 0 ? "" : " FILTER " + predicate; final String query = String.format("FOR e IN %s%s COLLECT WITH COUNT INTO length RETURN length", getCollectionName(), filter); final ArangoCursor<Long> cursor = arangoOperations.query(query, bindVars, null, Long.class); return cursor.next(); }
@Override public Variables variables() { ArangoCursor<ArangoDBGraphVariables> iter = client.getGraphVariables(this.name, variables_id); if (iter.hasNext()) { ArangoDBGraphVariables v = iter.next(); v.graph(this); return v; } else { throw new ArangoDBGraphException("Existing graph does not have a Variables collection"); } }
ArangoCursor<String> iter = client.getGraphVariablesId(this.name); if (iter.hasNext()) { this.variables_id = iter.next();
private Object convertResult(final ArangoCursor<?> result, final ArangoParameterAccessor accessor) { if (isExistsQuery()) { if (!result.hasNext()) { return false; } return (Integer) result.next() > 0; } final ArangoResultConverter resultConverter = new ArangoResultConverter(accessor, result, operations, domainClass); return resultConverter.convertResult(method.getReturnType().getType()); }
private Object convertResult(final ArangoCursor<?> result, final ArangoParameterAccessor accessor) { if (isExistsQuery()) { if (!result.hasNext()) { return false; } return (Integer) result.next() > 0; } final ArangoResultConverter resultConverter = new ArangoResultConverter(accessor, result, operations, domainClass); return resultConverter.convertResult(method.getReturnType().getType()); }
/** * Build a GeoResult from the given ArangoCursor * * @param cursor * query result from driver * @return GeoResult object */ private GeoResult<?> buildGeoResult(final ArangoCursor<?> cursor) { GeoResult<?> geoResult = null; while (cursor.hasNext() && geoResult == null) { final Object object = cursor.next(); if (!(object instanceof VPackSlice)) { continue; } final VPackSlice slice = (VPackSlice) object; final VPackSlice distSlice = slice.get("_distance"); final Double distanceInMeters = distSlice.isDouble() ? distSlice.getAsDouble() : null; if (distanceInMeters == null) { continue; } final Object entity = operations.getConverter().read(domainClass, slice); final Distance distance = new Distance(distanceInMeters / 1000, Metrics.KILOMETERS); geoResult = new GeoResult<>(entity, distance); } return geoResult; }
/** * Build a GeoResult from the given ArangoCursor * * @param cursor * query result from driver * @return GeoResult object */ private GeoResult<?> buildGeoResult(final ArangoCursor<?> cursor) { GeoResult<?> geoResult = null; while (cursor.hasNext() && geoResult == null) { final Object object = cursor.next(); if (!(object instanceof VPackSlice)) { continue; } final VPackSlice slice = (VPackSlice) object; final VPackSlice distSlice = slice.get("_distance"); final Double distanceInMeters = distSlice.isDouble() ? distSlice.getAsDouble() : null; if (distanceInMeters == null) { continue; } final Object entity = operations.getConverter().read(domainClass, slice); final Distance distance = new Distance(distanceInMeters / 1000, Metrics.KILOMETERS); geoResult = new GeoResult<>(entity, distance); } return geoResult; }