com.arangodb.velocypack.VPackSlice Java Examples
The following examples show how to use
com.arangodb.velocypack.VPackSlice.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ArangoCollectionImpl.java From arangodb-java-driver with Apache License 2.0 | 6 votes |
@Override public Boolean documentExists(final String key, final DocumentExistsOptions options) throws ArangoDBException { try { executor.execute(documentExistsRequest(key, options), VPackSlice.class); return true; } catch (final ArangoDBException e) { // handle Response: 404, Error: 1655 - transaction not found if (e.getErrorNum() != null && e.getErrorNum() == 1655) { throw e; } if ((e.getResponseCode() != null && (e.getResponseCode() == 404 || e.getResponseCode() == 304 || e.getResponseCode() == 412)) && (options == null || options.isCatchException())) { return false; } throw e; } }
Example #2
Source File: VPackExample.java From arangodb-java-driver with Apache License 2.0 | 6 votes |
@Test public void buildObject() throws VPackException { final VPackBuilder builder = new VPackBuilder(); builder.add(ValueType.OBJECT);// object start builder.add("foo", 1); // add field "foo" with value 1 builder.add("bar", 2); // add field "bar" with value 2 builder.close();// object end final VPackSlice slice = builder.slice(); // create slice assertThat(slice.isObject(), is(true)); assertThat(slice.size(), is(2)); // number of fields final VPackSlice foo = slice.get("foo"); // get field "foo" assertThat(foo.isInteger(), is(true)); assertThat(foo.getAsInt(), is(1)); final VPackSlice bar = slice.get("bar"); // get field "bar" assertThat(bar.isInteger(), is(true)); assertThat(bar.getAsInt(), is(2)); // iterate over the fields for (final Iterator<Entry<String, VPackSlice>> iterator = slice.objectIterator(); iterator.hasNext(); ) { final Entry<String, VPackSlice> field = iterator.next(); assertThat(field.getValue().isInteger(), is(true)); } }
Example #3
Source File: DefaultArangoConverter.java From spring-data with Apache License 2.0 | 6 votes |
private Object readMap(final TypeInformation<?> type, final VPackSlice source) { if (!source.isObject()) { throw new MappingException( String.format("Can't read map type %s from VPack type %s!", type, source.getType())); } final Class<?> keyType = getNonNullComponentType(type).getType(); final TypeInformation<?> valueType = getNonNullMapValueType(type); final Map<Object, Object> map = CollectionFactory.createMap(type.getType(), keyType, source.size()); final Iterator<Entry<String, VPackSlice>> iterator = source.objectIterator(); while (iterator.hasNext()) { final Entry<String, VPackSlice> entry = iterator.next(); if (typeMapper.isTypeKey(entry.getKey())) { continue; } final Object key = convertIfNecessary(entry.getKey(), keyType); final VPackSlice value = entry.getValue(); map.put(key, readInternal(valueType, value)); } return map; }
Example #4
Source File: VPackExample.java From arangodb-java-driver with Apache License 2.0 | 6 votes |
@Test public void buildObjectInObject() throws VPackException { final VPackBuilder builder = new VPackBuilder(); builder.add(ValueType.OBJECT);// object start builder.add("foo", ValueType.OBJECT); // add object in field "foo" builder.add("bar", 2); // add field "bar" with value 2 to object "foo" builder.close();// object "foo" end builder.close();// object end final VPackSlice slice = builder.slice(); // create slice assertThat(slice.isObject(), is(true)); final VPackSlice foo = slice.get("foo"); assertThat(foo.isObject(), is(true)); final VPackSlice bar = foo.get("bar"); // get field "bar" from "foo" assertThat(bar.isInteger(), is(true)); }
Example #5
Source File: DefaultArangoConverter.java From spring-data with Apache License 2.0 | 6 votes |
private Object readCollection(final TypeInformation<?> type, final VPackSlice source) { if (!source.isArray()) { throw new MappingException( String.format("Can't read collection type %s from VPack type %s!", type, source.getType())); } final TypeInformation<?> componentType = getNonNullComponentType(type); final Class<?> collectionType = Iterable.class.equals(type.getType()) ? Collection.class : type.getType(); final Collection<Object> collection = CollectionFactory.createCollection(collectionType, componentType.getType(), source.getLength()); final Iterator<VPackSlice> iterator = source.arrayIterator(); while (iterator.hasNext()) { final VPackSlice elem = iterator.next(); collection.add(readInternal(componentType, elem)); } return collection; }
Example #6
Source File: InternalArangoDatabase.java From arangodb-java-driver with Apache License 2.0 | 6 votes |
protected <E, V> ResponseDeserializer<TraversalEntity<V, E>> executeTraversalResponseDeserializer( final Class<V> vertexClass, final Class<E> edgeClass) { return response -> { final TraversalEntity<V, E> result = new TraversalEntity<>(); final VPackSlice visited = response.getBody().get(ArangoResponseField.RESULT).get("visited"); result.setVertices(deserializeVertices(vertexClass, visited)); final Collection<PathEntity<V, E>> paths = new ArrayList<>(); for (final Iterator<VPackSlice> iterator = visited.get("paths").arrayIterator(); iterator.hasNext(); ) { final PathEntity<V, E> path = new PathEntity<>(); final VPackSlice next = iterator.next(); path.setEdges(deserializeEdges(edgeClass, next)); path.setVertices(deserializeVertices(vertexClass, next)); paths.add(path); } result.setPaths(paths); return result; }; }
Example #7
Source File: VstCommunication.java From arangodb-java-driver with Apache License 2.0 | 6 votes |
protected Collection<Chunk> buildChunks(final Message message) { final Collection<Chunk> chunks = new ArrayList<>(); final VPackSlice head = message.getHead(); int size = head.getByteSize(); final VPackSlice body = message.getBody(); if (body != null) { size += body.getByteSize(); } final int n = size / chunksize; final int numberOfChunks = (size % chunksize != 0) ? (n + 1) : n; int off = 0; for (int i = 0; size > 0; i++) { final int len = Math.min(chunksize, size); final long messageLength = (i == 0 && numberOfChunks > 1) ? size : -1L; final Chunk chunk = new Chunk(message.getId(), i, numberOfChunks, messageLength, off, len); size -= len; off += len; chunks.add(chunk); } return chunks; }
Example #8
Source File: ArangoResultConverter.java From spring-data with Apache License 2.0 | 6 votes |
/** * 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; }
Example #9
Source File: VPackExample.java From arangodb-java-driver with Apache License 2.0 | 6 votes |
@Test public void buildObjectInObject() throws VPackException { final VPackBuilder builder = new VPackBuilder(); builder.add(ValueType.OBJECT);// object start builder.add("foo", ValueType.OBJECT); // add object in field "foo" builder.add("bar", 2); // add field "bar" with value 2 to object "foo" builder.close();// object "foo" end builder.close();// object end final VPackSlice slice = builder.slice(); // create slice assertThat(slice.isObject(), is(true)); final VPackSlice foo = slice.get("foo"); assertThat(foo.isObject(), is(true)); final VPackSlice bar = foo.get("bar"); // get field "bar" from "foo" assertThat(bar.isInteger(), is(true)); }
Example #10
Source File: AqlQueryWithSpecialReturnTypesExample.java From arangodb-java-driver with Apache License 2.0 | 6 votes |
@Test public void aqlWithLimitQueryAsVPackArray() throws InterruptedException, ExecutionException { final String query = "FOR t IN " + COLLECTION_NAME + " FILTER t.age >= 20 && t.age < 30 && t.gender == @gender RETURN [t.name, t.gender, t.age]"; final Map<String, Object> bindVars = new MapBuilder().put("gender", Gender.FEMALE).get(); db.query(query, bindVars, null, VPackSlice.class) .whenComplete((cursor, ex) -> { assertThat(cursor, is(notNullValue())); cursor.forEachRemaining(vpack -> { assertThat(vpack.get(0).getAsString(), isOneOf("TestUser11", "TestUser13", "TestUser15", "TestUser17", "TestUser19")); assertThat(vpack.get(1).getAsString(), is(Gender.FEMALE.name())); assertThat(vpack.get(2).getAsInt(), isOneOf(21, 23, 25, 27, 29)); }); }) .get(); }
Example #11
Source File: InternalArangoCollection.java From arangodb-java-driver with Apache License 2.0 | 6 votes |
protected <T, U> ResponseDeserializer<DocumentUpdateEntity<U>> updateDocumentResponseDeserializer( final T value, final DocumentUpdateOptions options, final Class<U> returnType) { return response -> { final VPackSlice body = response.getBody(); final DocumentUpdateEntity<U> doc = util().deserialize(body, DocumentUpdateEntity.class); final VPackSlice newDoc = body.get(NEW); if (newDoc.isObject()) { doc.setNew(util(Serializer.CUSTOM).deserialize(newDoc, returnType)); } final VPackSlice oldDoc = body.get(OLD); if (oldDoc.isObject()) { doc.setOld(util(Serializer.CUSTOM).deserialize(oldDoc, returnType)); } if (options == null || Boolean.TRUE != options.getSilent()) { final Map<DocumentField.Type, String> values = new HashMap<>(); values.put(DocumentField.Type.REV, doc.getRev()); executor.documentCache().setValues(value, values); } return doc; }; }
Example #12
Source File: InternalArangoCollection.java From arangodb-java-driver with Apache License 2.0 | 6 votes |
protected <T> ResponseDeserializer<DocumentUpdateEntity<T>> replaceDocumentResponseDeserializer( final T value, final DocumentReplaceOptions options) { return response -> { final VPackSlice body = response.getBody(); final DocumentUpdateEntity<T> doc = util().deserialize(body, DocumentUpdateEntity.class); final VPackSlice newDoc = body.get(NEW); if (newDoc.isObject()) { doc.setNew(util(Serializer.CUSTOM).deserialize(newDoc, value.getClass())); } final VPackSlice oldDoc = body.get(OLD); if (oldDoc.isObject()) { doc.setOld(util(Serializer.CUSTOM).deserialize(oldDoc, value.getClass())); } if (options == null || Boolean.TRUE != options.getSilent()) { final Map<DocumentField.Type, String> values = new HashMap<>(); values.put(DocumentField.Type.REV, doc.getRev()); executor.documentCache().setValues(value, values); } return doc; }; }
Example #13
Source File: InternalArangoCollection.java From arangodb-java-driver with Apache License 2.0 | 6 votes |
protected <T> ResponseDeserializer<MultiDocumentEntity<T>> getDocumentsResponseDeserializer( final Class<T> type, final DocumentReadOptions options) { return response -> { final MultiDocumentEntity<T> multiDocument = new MultiDocumentEntity<>(); final Collection<T> docs = new ArrayList<>(); final Collection<ErrorEntity> errors = new ArrayList<>(); final Collection<Object> documentsAndErrors = new ArrayList<>(); final VPackSlice body = response.getBody(); for (final Iterator<VPackSlice> iterator = body.arrayIterator(); iterator.hasNext(); ) { final VPackSlice next = iterator.next(); if (next.get(ArangoResponseField.ERROR).isTrue()) { final ErrorEntity error = util().deserialize(next, ErrorEntity.class); errors.add(error); documentsAndErrors.add(error); } else { final T doc = util(Serializer.CUSTOM).deserialize(next, type); docs.add(doc); documentsAndErrors.add(doc); } } multiDocument.setDocuments(docs); multiDocument.setErrors(errors); multiDocument.setDocumentsAndErrors(documentsAndErrors); return multiDocument; }; }
Example #14
Source File: InternalArangoCollection.java From arangodb-java-driver with Apache License 2.0 | 6 votes |
protected <T> ResponseDeserializer<DocumentCreateEntity<T>> insertDocumentResponseDeserializer( final T value, final DocumentCreateOptions options) { return response -> { final VPackSlice body = response.getBody(); final DocumentCreateEntity<T> doc = util().deserialize(body, DocumentCreateEntity.class); final VPackSlice newDoc = body.get(NEW); if (newDoc.isObject()) { doc.setNew(util(Serializer.CUSTOM).deserialize(newDoc, value.getClass())); } final VPackSlice oldDoc = body.get(OLD); if (oldDoc.isObject()) { doc.setOld(util(Serializer.CUSTOM).deserialize(oldDoc, value.getClass())); } if (options == null || Boolean.TRUE != options.getSilent()) { final Map<DocumentField.Type, String> values = new HashMap<>(); values.put(DocumentField.Type.ID, doc.getId()); values.put(DocumentField.Type.KEY, doc.getKey()); values.put(DocumentField.Type.REV, doc.getRev()); executor.documentCache().setValues(value, values); } return doc; }; }
Example #15
Source File: ArangoDatabaseTest.java From arangodb-java-driver-async with Apache License 2.0 | 6 votes |
@Test public void shouldIncludeExceptionMessage() throws InterruptedException, ExecutionException { final String exceptionMessage = "My error context"; final String action = "function (params) {" + "throw '" + exceptionMessage + "';" + "}"; try { db.transaction(action, VPackSlice.class, null).get(); fail(); } catch (final ExecutionException e) { assertThat(e.getCause(), instanceOf(ArangoDBException.class)); ArangoDBException cause = ((ArangoDBException) e.getCause()); assertThat(cause.getErrorNum(), is(1650)); if (isAtLeastVersion(3, 4)) { assertThat(cause.getErrorMessage(), is(exceptionMessage)); } } }
Example #16
Source File: ArangoDatabaseTest.java From arangodb-java-driver-async with Apache License 2.0 | 6 votes |
@Test public void transactionallowImplicit() throws InterruptedException, ExecutionException { try { db.createCollection("someCollection", null).get(); db.createCollection("someOtherCollection", null).get(); final String action = "function (params) {" + "var db = require('internal').db;" + "return {'a':db.someCollection.all().toArray()[0], 'b':db.someOtherCollection.all().toArray()[0]};" + "}"; final TransactionOptions options = new TransactionOptions().readCollections("someCollection"); db.transaction(action, VPackSlice.class, options).get(); try { options.allowImplicit(false); db.transaction(action, VPackSlice.class, options).get(); fail(); } catch (final ExecutionException e) { assertThat(e.getCause(), instanceOf(ArangoDBException.class)); } } finally { db.collection("someCollection").drop().get(); db.collection("someOtherCollection").drop().get(); } }
Example #17
Source File: AqlQueryWithSpecialReturnTypesExample.java From arangodb-java-driver with Apache License 2.0 | 6 votes |
@Test public void aqlWithLimitQueryAsVPackObject() throws InterruptedException, ExecutionException { final String query = "FOR t IN " + COLLECTION_NAME + " FILTER t.age >= 20 && t.age < 30 && t.gender == @gender RETURN t"; final Map<String, Object> bindVars = new MapBuilder().put("gender", Gender.FEMALE).get(); db.query(query, bindVars, null, VPackSlice.class) .whenComplete((cursor, ex) -> { assertThat(cursor, is(notNullValue())); cursor.forEachRemaining(vpack -> { assertThat(vpack.get("name").getAsString(), isOneOf("TestUser11", "TestUser13", "TestUser15", "TestUser17", "TestUser19")); assertThat(vpack.get("gender").getAsString(), is(Gender.FEMALE.name())); assertThat(vpack.get("age").getAsInt(), isOneOf(21, 23, 25, 27, 29)); }); }) .get(); }
Example #18
Source File: ArangoDatabaseTest.java From arangodb-java-driver with Apache License 2.0 | 6 votes |
@Test public void transactionallowImplicit() throws InterruptedException, ExecutionException { try { db.createCollection("someCollection", null).get(); db.createCollection("someOtherCollection", null).get(); final String action = "function (params) {" + "var db = require('internal').db;" + "return {'a':db.someCollection.all().toArray()[0], 'b':db.someOtherCollection.all().toArray()[0]};" + "}"; final TransactionOptions options = new TransactionOptions().readCollections("someCollection"); db.transaction(action, VPackSlice.class, options).get(); try { options.allowImplicit(false); db.transaction(action, VPackSlice.class, options).get(); fail(); } catch (final ExecutionException e) { assertThat(e.getCause(), instanceOf(ArangoDBException.class)); } } finally { db.collection("someCollection").drop().get(); db.collection("someOtherCollection").drop().get(); } }
Example #19
Source File: VPackExample.java From arangodb-java-driver-async with Apache License 2.0 | 6 votes |
@Test public void buildObjectInObject() throws VPackException { final VPackBuilder builder = new VPackBuilder(); builder.add(ValueType.OBJECT);// object start builder.add("foo", ValueType.OBJECT); // add object in field "foo" builder.add("bar", 2); // add field "bar" with value 2 to object "foo" builder.close();// object "foo" end builder.close();// object end final VPackSlice slice = builder.slice(); // create slice assertThat(slice.isObject(), is(true)); final VPackSlice foo = slice.get("foo"); assertThat(foo.isObject(), is(true)); final VPackSlice bar = foo.get("bar"); // get field "bar" from "foo" assertThat(bar.isInteger(), is(true)); }
Example #20
Source File: VPackExample.java From arangodb-java-driver-async with Apache License 2.0 | 6 votes |
@Test public void buildObject() throws VPackException { final VPackBuilder builder = new VPackBuilder(); builder.add(ValueType.OBJECT);// object start builder.add("foo", 1); // add field "foo" with value 1 builder.add("bar", 2); // add field "bar" with value 2 builder.close();// object end final VPackSlice slice = builder.slice(); // create slice assertThat(slice.isObject(), is(true)); assertThat(slice.size(), is(2)); // number of fields final VPackSlice foo = slice.get("foo"); // get field "foo" assertThat(foo.isInteger(), is(true)); assertThat(foo.getAsInt(), is(1)); final VPackSlice bar = slice.get("bar"); // get field "bar" assertThat(bar.isInteger(), is(true)); assertThat(bar.getAsInt(), is(2)); // iterate over the fields for (final Iterator<Entry<String, VPackSlice>> iterator = slice.objectIterator(); iterator.hasNext();) { final Entry<String, VPackSlice> field = iterator.next(); assertThat(field.getValue().isInteger(), is(true)); } }
Example #21
Source File: ArangoDatabaseTest.java From arangodb-java-driver with Apache License 2.0 | 5 votes |
@Test public void shouldIncludeExceptionMessage() { assumeTrue(isAtLeastVersion(3, 4)); final String exceptionMessage = "My error context"; final String action = "function (params) {" + "throw '" + exceptionMessage + "';" + "}"; try { db.transaction(action, VPackSlice.class, null); fail(); } catch (final ArangoDBException e) { assertThat(e.getErrorMessage(), is(exceptionMessage)); } }
Example #22
Source File: InternalArangoEdgeCollection.java From arangodb-java-driver with Apache License 2.0 | 5 votes |
protected <T> ResponseDeserializer<EdgeEntity> insertEdgeResponseDeserializer(final T value) { return response -> { final VPackSlice body = response.getBody().get(EDGE); final EdgeEntity doc = util().deserialize(body, EdgeEntity.class); final Map<DocumentField.Type, String> values = new HashMap<>(); values.put(DocumentField.Type.ID, doc.getId()); values.put(DocumentField.Type.KEY, doc.getKey()); values.put(DocumentField.Type.REV, doc.getRev()); executor.documentCache().setValues(value, values); return doc; }; }
Example #23
Source File: InternalArangoCollection.java From arangodb-java-driver with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") protected <T> ResponseDeserializer<MultiDocumentEntity<DocumentUpdateEntity<T>>> updateDocumentsResponseDeserializer( final Class<T> returnType) { return response -> { final MultiDocumentEntity<DocumentUpdateEntity<T>> multiDocument = new MultiDocumentEntity<>(); final Collection<DocumentUpdateEntity<T>> docs = new ArrayList<>(); final Collection<ErrorEntity> errors = new ArrayList<>(); final Collection<Object> documentsAndErrors = new ArrayList<>(); final VPackSlice body = response.getBody(); if (body.isArray()) { for (final Iterator<VPackSlice> iterator = body.arrayIterator(); iterator.hasNext(); ) { final VPackSlice next = iterator.next(); if (next.get(ArangoResponseField.ERROR).isTrue()) { final ErrorEntity error = util().deserialize(next, ErrorEntity.class); errors.add(error); documentsAndErrors.add(error); } else { final DocumentUpdateEntity<T> doc = util().deserialize(next, DocumentUpdateEntity.class); final VPackSlice newDoc = next.get(NEW); if (newDoc.isObject()) { doc.setNew(util(Serializer.CUSTOM).deserialize(newDoc, returnType)); } final VPackSlice oldDoc = next.get(OLD); if (oldDoc.isObject()) { doc.setOld(util(Serializer.CUSTOM).deserialize(oldDoc, returnType)); } docs.add(doc); documentsAndErrors.add(doc); } } } multiDocument.setDocuments(docs); multiDocument.setErrors(errors); multiDocument.setDocumentsAndErrors(documentsAndErrors); return multiDocument; }; }
Example #24
Source File: InternalArangoCollection.java From arangodb-java-driver with Apache License 2.0 | 5 votes |
protected <T> ResponseDeserializer<MultiDocumentEntity<DocumentDeleteEntity<T>>> deleteDocumentsResponseDeserializer( final Class<T> type) { return response -> { final MultiDocumentEntity<DocumentDeleteEntity<T>> multiDocument = new MultiDocumentEntity<>(); final Collection<DocumentDeleteEntity<T>> docs = new ArrayList<>(); final Collection<ErrorEntity> errors = new ArrayList<>(); final Collection<Object> documentsAndErrors = new ArrayList<>(); final VPackSlice body = response.getBody(); if (body.isArray()) { for (final Iterator<VPackSlice> iterator = body.arrayIterator(); iterator.hasNext(); ) { final VPackSlice next = iterator.next(); if (next.get(ArangoResponseField.ERROR).isTrue()) { final ErrorEntity error = util().deserialize(next, ErrorEntity.class); errors.add(error); documentsAndErrors.add(error); } else { final DocumentDeleteEntity<T> doc = util().deserialize(next, DocumentDeleteEntity.class); final VPackSlice oldDoc = next.get(OLD); if (oldDoc.isObject()) { doc.setOld(util(Serializer.CUSTOM).deserialize(oldDoc, type)); } docs.add(doc); documentsAndErrors.add(doc); } } } multiDocument.setDocuments(docs); multiDocument.setErrors(errors); multiDocument.setDocumentsAndErrors(documentsAndErrors); return multiDocument; }; }
Example #25
Source File: InternalArangoDatabase.java From arangodb-java-driver with Apache License 2.0 | 5 votes |
protected ResponseDeserializer<Collection<AqlFunctionEntity>> getAqlFunctionsResponseDeserializer() { return response -> { final VPackSlice body = response.getBody(); // compatibility with ArangoDB < 3.4 // https://www.arangodb.com/docs/stable/release-notes-upgrading-changes34.html final VPackSlice result = body.isArray() ? body : body.get(ArangoResponseField.RESULT); return util().deserialize(result, new Type<Collection<AqlFunctionEntity>>() { }.getType()); }; }
Example #26
Source File: GetDocumentExample.java From arangodb-java-driver with Apache License 2.0 | 5 votes |
@Test public void getAsVPack() throws InterruptedException, ExecutionException { collection.getDocument(key, VPackSlice.class) .whenComplete((doc, ex) -> { assertThat(doc, is(notNullValue())); assertThat(doc.get("foo").isString(), is(true)); assertThat(doc.get("foo").getAsString(), is("bar")); }) .get(); }
Example #27
Source File: InternalArangoEdgeCollection.java From arangodb-java-driver with Apache License 2.0 | 5 votes |
protected <T> ResponseDeserializer<EdgeUpdateEntity> replaceEdgeResponseDeserializer(final T value) { return response -> { final VPackSlice body = response.getBody().get(EDGE); final EdgeUpdateEntity doc = util().deserialize(body, EdgeUpdateEntity.class); final Map<DocumentField.Type, String> values = new HashMap<>(); values.put(DocumentField.Type.REV, doc.getRev()); executor.documentCache().setValues(value, values); return doc; }; }
Example #28
Source File: InternalArangoDatabase.java From arangodb-java-driver with Apache License 2.0 | 5 votes |
protected <V> Collection<V> deserializeVertices(final Class<V> vertexClass, final VPackSlice vpack) throws VPackException { final Collection<V> vertices = new ArrayList<>(); for (final Iterator<VPackSlice> iterator = vpack.get("vertices").arrayIterator(); iterator.hasNext(); ) { vertices.add(util(Serializer.CUSTOM).deserialize(iterator.next(), vertexClass)); } return vertices; }
Example #29
Source File: ArangoCollectionTest.java From arangodb-java-driver with Apache License 2.0 | 5 votes |
@Test public void getDocumentDirtyRead() { final BaseDocument doc = new BaseDocument(); collection.insertDocument(doc); final VPackSlice document = collection .getDocument(doc.getKey(), VPackSlice.class, new DocumentReadOptions().allowDirtyRead(true)); assertThat(document, is(notNullValue())); }
Example #30
Source File: InternalArangoDatabase.java From arangodb-java-driver with Apache License 2.0 | 5 votes |
protected ResponseDeserializer<Integer> deleteAqlFunctionResponseDeserializer() { return response -> { // compatibility with ArangoDB < 3.4 // https://www.arangodb.com/docs/stable/release-notes-upgrading-changes34.html Integer count = null; final VPackSlice body = response.getBody(); if (body.isObject()) { final VPackSlice deletedCount = body.get("deletedCount"); if (deletedCount.isInteger()) { count = deletedCount.getAsInt(); } } return count; }; }