Skip to content

Commit

Permalink
feat(VPack): Refactoring on how the VPack serialization works. Part of
Browse files Browse the repository at this point in the history
  • Loading branch information
arcanefoam committed Jun 25, 2019
1 parent 1568d85 commit d7d4abc
Show file tree
Hide file tree
Showing 28 changed files with 630 additions and 321 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,4 @@ public Map<String, Vertex> loadAll(Iterable<? extends String> keys) {
return result;
}



}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

/**
* The ArangoDB property filter class constructs AQL segments for comparing a document property
* with a given value.
* with a given baseValue.
*
* @author Achim Brandt (http://www.triagens.de)
* @author Johannes Gocke (http://www.triagens.de)
Expand Down Expand Up @@ -103,12 +103,12 @@ public ArangoDBPropertyFilter has(
}

/**
* Constructs the the AQL segment for each property filter and adds the required name-value
* Constructs the the AQL segment for each property filter and adds the required name-baseValue
* entries to the bind parameters map.
*
* @param prefix the iterator/variable to which the property filter will be applied
* @param filterSegments the list to populate with the AQL segments
* @param bindVars the map to populate with the name-value bindings
* @param bindVars the map to populate with the name-baseValue bindings
*/

public void addAqlSegments(
Expand Down Expand Up @@ -170,7 +170,7 @@ public void addAqlSegments(
*
* @param bindVars the bind vars
* @param propertyName the property name
* @param value the value
* @param value the baseValue
* @return the string
*/

Expand Down Expand Up @@ -213,7 +213,7 @@ private class PropertyContainer {

public final String key;

/** The value. */
/** The baseValue. */

public final Object value;

Expand All @@ -225,7 +225,7 @@ private class PropertyContainer {
* Instantiates a new property container.
*
* @param key the name
* @param value the value
* @param value the baseValue
* @param compare the compare
*/
public PropertyContainer(final String key, final Object value, final Compare compare) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ public ArangoGraph createGraph(
// * Get a document from the database. The method is generic so we it can be used to retrieve
// * vertices, elementProperties or variables.
// *
// * @param <V> the value type
// * @param <V> the baseValue type
// * @param id the id of the document (should be a valid ArangoDB handle)
// * @param docClass the returned document class
// * @return the document
Expand Down Expand Up @@ -419,7 +419,7 @@ public ArangoGraph createGraph(
// /**
// * Get an edge from the graph.
// *
// * @param <V> the value type
// * @param <V> the baseValue type
// * @param id the id (name) of the edge
// * @param label the label from which the edge is retrieved
// * @param edgeClass the edge's specialised class
Expand Down Expand Up @@ -537,7 +537,7 @@ public ArangoGraph createGraph(
// * @param document the document
// * @param edgeLabelsFilter a list of edge types to follow
// * @param direction a direction
// * @param propertyFilter filter the neighbours on the given property:value values
// * @param propertyFilter filter the neighbours on the given property:baseValue values
// * @param resultType the result type
// * @return ArangoDBBaseQuery the query object
// */
Expand Down Expand Up @@ -571,7 +571,7 @@ public ArangoGraph createGraph(
// * @param <T> the generic type
// * @param document the document
// * @param edgeLabelsFilter a list of edge types to follow
// * @param propertyFilter Filter the neighbours on the given property:value values
// * @param propertyFilter Filter the neighbours on the given property:baseValue values
// * @param propertyType the property type
// * @return ArangoDBBaseQuery the query object
// */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public GraphCreationException(String message) {
/**
* Execute the AQL query against the database
* @param query the AQL query
* @param bindVars a map of primaryKey:value for bind variables
* @param bindVars a map of primaryKey:baseValue for bind variables
* @param aqlQueryOptions AQL query options
* @param type The type of the elements in the result
* @param <T> The type of the elements in the result
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public interface GraphClient extends AutoCloseable {
/**
* Execute the AQL query against the database
* @param query the AQL query
* @param bindVars a map of primaryKey:value for bind variables
* @param bindVars a map of primaryKey:baseValue for bind variables
* @param aqlQueryOptions AQL query options
* @param type The type of the elements in the result
* @param <T> The type of the elements in the result
Expand All @@ -50,7 +50,7 @@ <T> ArangoCursor<T> executeAqlQuery(String query, Map<String, Object> bindVars,
* Insert a new vertex in the graph.
* @param key the vertex's primary key (can be null)
* @param label the vertex's label
* @param keyValues the key:value edge property pairs
* @param keyValues the key:baseValue edge property pairs
* @return a new instance of the vertex that uses the provided client.
*/
ArangoDBVertex insertVertex(String key, String label, Object... keyValues);
Expand All @@ -74,7 +74,7 @@ <T> ArangoCursor<T> executeAqlQuery(String query, Map<String, Object> bindVars,
* @param from the source vertex of the edge
* @param to the target vertex of the edge
* @param edgeClient the edge clien to assing to the edge
* @param keyValues the key:value edge property pairs
* @param keyValues the key:baseValue edge property pairs
* @return
*/
ArangoDBEdge insertEdge(String key, String label,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public interface GraphConfiguration {
*
* The graph name is configured via the {@link #PROPERTY_KEY_GRAPH_NAME} setting.
*
* @return An Optional containing the graph name, or empty if the configuration does not have the value
* @return An Optional containing the graph name, or empty if the configuration does not have the baseValue
*/
Optional<String> graphName();

Expand All @@ -78,25 +78,25 @@ public interface GraphConfiguration {
*
* The database name is configured via the {@link #PROPERTY_KEY_DB_NAME} setting.
*
* @return An Optional containing the database name, or empty if the configuration does not have the value
* @return An Optional containing the database name, or empty if the configuration does not have the baseValue
*/
Optional<String> databaseName();

/**
* Get the should prefix label names flag value from the configuration. If not present the default value is true.
* Get the should prefix label names flag baseValue from the configuration. If not present the default baseValue is true.
*
* The shouldPrefixCollectionNames name is configured via the {@link #PROPERTY_KEY_SHOULD_PREFIX_COLLECTION_NAMES} setting.
*
* @return The flag value.
* @return The flag baseValue.
*/
boolean shouldPrefixCollectionNames();

/**
* Get the create db flag value from the configuration. If not present the default value is false.
* Get the create db flag baseValue from the configuration. If not present the default baseValue is false.
*
* The create db is configured via the {@link #PROPERTY_KEY_DB_CREATE} setting.
*
* @return The flag value.
* @return The flag baseValue.
*/

boolean createDatabase();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,14 @@ public ArangoDBEdge(
this(null, key, null, label, from, to, null, new ArngElementProperties());
}

public ArangoDBEdge(
String id,
String key,
String rev,
String label) {
this(id, key, rev, label, null, null, null, new ArngElementProperties());
}

/**
*
* @param id the edge handle
Expand Down Expand Up @@ -148,19 +156,23 @@ public ArangoDBEdge(
vertices = CacheBuilder.newBuilder()
.expireAfterAccess(10, TimeUnit.SECONDS)
.build(new EdgeVertexLoader(this, client));
vertices.put("from", from);
vertices.put("to", to);
if (from != null) {
vertices.put("from", from);
}
if (to != null) {
vertices.put("to", to);
}
this.properties = properties;
}

// // FIXME Move to interface
// public ArangoDBEdge useClient(EdgeClient client) {
// try {
// return new ArangoDBEdge(_id, _key, _rev, label, vertices.get("from"), vertices.get("to"), client);
// } catch (ExecutionException e) {
// throw new IllegalStateException("Error assigning client to edge", e);
// }
// }
// FIXME Move to interface
public ArangoDBEdge useClient(EdgeClient client) {
try {
return new ArangoDBEdge(_id, _key, _rev, label, vertices.get("from"), vertices.get("to"), client, properties);
} catch (ExecutionException e) {
throw new IllegalStateException("Error assigning client to edge", e);
}
}

@Override
public String from() {
Expand All @@ -185,7 +197,7 @@ public Object id() {
try {
return handle();
} catch (ElementNotPairedException e) {
throw new IllegalStateException("Id of unpaired elements can't be retrieved.", e);
return primaryKey();
}
}

Expand Down Expand Up @@ -276,7 +288,7 @@ public <V> Iterator<V> values(String... propertyKeys) {

@Override
public <V> Property<V> property(final String key, final V value) {
Property<V> result = properties.property(key, value, this);
Property<V> result = properties.property(this, key, value);
update();
return result;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
* graphClient name. If no vertex, edge and relation information is provided, the graphClient will be considered
* schema-less.
* <p>
* All settings are prefixed with "gremlin.arangodb.conf". So, for example, to set the value of the
* All settings are prefixed with "gremlin.arangodb.conf". So, for example, to set the baseValue of the
* Arango DB hosts property (arango db configuration), the configuration must read:
* <pre>gremlin.arangodb.conf.arangodb.hosts = 127.0.0.1:8529
* </pre>
Expand Down Expand Up @@ -107,7 +107,7 @@
* In order to allow multiple graphs in the same databaseClient, vertex and edge collections can be prefixed with the
* graphClient name in order to avoid label clashes. To enable this function the graphClient.shouldPrefixCollectionNames
* property should be set to <code>true</code>. If you have an existing graphClient/collections and want to reuse those,
* the flag should be set to <code>false</code>. The default value is <code>true</code>.
* the flag should be set to <code>false</code>. The default baseValue is <code>true</code>.
* <p>
* The list of allowed settings is:
* <ul>
Expand Down Expand Up @@ -309,7 +309,7 @@ public boolean supportsUuidIds() {
* the string representation of these is fine for ArangoDB, which makes the test
* complain because it expects the actual class to be deserialized. We can test
* to see if a string is accepted for deserialization.
* TODO As with elementProperties, a way to support this is to store the id value class
* TODO As with elementProperties, a way to support this is to store the id baseValue class
*/
return false;
}
Expand Down Expand Up @@ -392,7 +392,7 @@ public boolean supportsUuidIds() {
* the string representation of these is fine for ArangoDB, which makes the test
* complain because it expects the actual class to be deserialized. We can test
* to see if a string is accepted for deserialization.
* TODO As with elementProperties, a way to support this is to store the id value class
* TODO As with elementProperties, a way to support this is to store the id baseValue class
*/
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public static class ArangoDBGraphVariableFeatures implements Graph.Features.Vari

}

/** The primaryKey:value store for elementProperties. */
/** The primaryKey:baseValue store for elementProperties. */

private final Map<String, Object> store = new HashMap<>(4);

Expand Down
Loading

0 comments on commit d7d4abc

Please sign in to comment.