You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@usergrid.apache.org by to...@apache.org on 2014/08/31 03:02:13 UTC
[4/5] git commit: Tests pass
Tests pass
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/3e941cdf
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/3e941cdf
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/3e941cdf
Branch: refs/heads/datastax-driver
Commit: 3e941cdf9f5a853ef63d0ac23dc7067121d02204
Parents: 9112034
Author: Todd Nine <to...@apache.org>
Authored: Sat Aug 30 17:18:32 2014 -0600
Committer: Todd Nine <to...@apache.org>
Committed: Sat Aug 30 17:18:32 2014 -0600
----------------------------------------------------------------------
.../impl/EdgeMetadataSerializationImpl.java | 154 ++++++++++---------
.../EdgeMetadataSerializationTest.java | 2 +
2 files changed, 83 insertions(+), 73 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/3e941cdf/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/serialization/impl/EdgeMetadataSerializationImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/serialization/impl/EdgeMetadataSerializationImpl.java b/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/serialization/impl/EdgeMetadataSerializationImpl.java
index b15707a..930e12d 100644
--- a/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/serialization/impl/EdgeMetadataSerializationImpl.java
+++ b/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/serialization/impl/EdgeMetadataSerializationImpl.java
@@ -26,11 +26,8 @@ import java.util.Collections;
import java.util.Iterator;
import java.util.UUID;
-import org.apache.usergrid.persistence.core.astyanax.CassandraConfig;
-import org.apache.usergrid.persistence.core.astyanax.StringColumnParser;
import org.apache.usergrid.persistence.core.javadriver.RowIterator;
import org.apache.usergrid.persistence.core.javadriver.RowParser;
-import org.apache.usergrid.persistence.core.migration.Migration;
import org.apache.usergrid.persistence.core.scope.ApplicationScope;
import org.apache.usergrid.persistence.core.util.ValidationUtils;
import org.apache.usergrid.persistence.graph.Edge;
@@ -50,14 +47,13 @@ import com.google.common.base.Optional;
import com.google.common.base.Preconditions;
import com.google.inject.Inject;
import com.google.inject.Singleton;
-import com.netflix.astyanax.util.RangeBuilder;
/**
* Class to perform all edge metadata I/O
*/
@Singleton
-public class EdgeMetadataSerializationImpl implements EdgeMetadataSerialization{
+public class EdgeMetadataSerializationImpl implements EdgeMetadataSerialization {
/**
* CFs where the row key contains the source node id
@@ -84,34 +80,43 @@ public class EdgeMetadataSerializationImpl implements EdgeMetadataSerialization{
private static final String CF_TARGET_EDGE_TYPES = "Graph_Target_Edge_Types";
private static final String CF_TARGET_EDGE_TYPES_CREATE = "CREATE TABLE IF NOT EXISTS " + CF_TARGET_EDGE_TYPES
- + "( scopeId uuid, scopeType varchar, targetNodeId uuid, targetNodeType varchar, edgeType varchar, PRIMARY KEY ((scopeId, scopeType, " +
+ + "( scopeId uuid, scopeType varchar, targetNodeId uuid, targetNodeType varchar, edgeType varchar, " +
+ "PRIMARY KEY ((scopeId, scopeType, "
+ +
"targetNodeId, targetNodeType), edgeType ))";
//all source id types for target edge type
private static final String CF_TARGET_EDGE_ID_TYPES = "Graph_Target_Edge_Id_Types";
- private static final String CF_TARGET_EDGE_ID_TYPES_CREATE =
- "CREATE TABLE IF NOT EXISTS " + CF_TARGET_EDGE_ID_TYPES + " ( scopeId uuid, scopeType varchar, targetNodeId uuid, targetNodeType varchar, edgeType varchar, "
- + "sourceNodeType varchar, PRIMARY KEY ((scopeId, scopeType, targetNodeId, targetNodeType, " +
- "edgeType), sourceNodeType ) )";
+ private static final String CF_TARGET_EDGE_ID_TYPES_CREATE = "CREATE TABLE IF NOT EXISTS " + CF_TARGET_EDGE_ID_TYPES
+ + " ( scopeId uuid, scopeType varchar, targetNodeId uuid, targetNodeType varchar, edgeType varchar, "
+ + "sourceNodeType varchar, PRIMARY KEY ((scopeId, scopeType, targetNodeId, targetNodeType, " +
+ "edgeType), sourceNodeType ) )";
protected final Session session;
private final GraphFig graphFig;
- private PreparedStatement sourceEdgeTypesWrite;
- private PreparedStatement sourceEdgeTargetTypesWrite;
- private PreparedStatement targetEdgeTypesWrite;
- private PreparedStatement targetEdgeSourceTypesWrite;
- private PreparedStatement sourceEdgeTypesDelete;
- private PreparedStatement targetEdgeSourceTypesDelete;
- private PreparedStatement sourceEdgeTargetTypesDelete;
- private PreparedStatement targetEdgeTypesDelete;
- private PreparedStatement sourceEdgeTypesSelect;
- private PreparedStatement sourceEdgeTargetTypesSelect;
- private PreparedStatement targetEdgeTypesSelect;
- private PreparedStatement targetEdgeSourceTypesSelect;
+ private PreparedStatement sourceEdgeTypesWrite;
+ private PreparedStatement sourceEdgeTypesDelete;
+ private PreparedStatement sourceEdgeTypesSelect;
+
+
+ private PreparedStatement targetEdgeTypesWrite;
+ private PreparedStatement targetEdgeTypesDelete;
+ private PreparedStatement targetEdgeTypesSelect;
+
+
+
+ private PreparedStatement sourceEdgeTargetTypesWrite;
+ private PreparedStatement sourceEdgeTargetTypesSelect;
+ private PreparedStatement sourceEdgeTargetTypesDelete;
+
+
+ private PreparedStatement targetEdgeSourceTypesWrite;
+ private PreparedStatement targetEdgeSourceTypesDelete;
+ private PreparedStatement targetEdgeSourceTypesSelect;
/**
@@ -170,9 +175,8 @@ public class EdgeMetadataSerializationImpl implements EdgeMetadataSerialization{
final BoundStatement targetStatement = this.targetEdgeTypesWrite
.bind( applicationUuid, applicationType, targetUuid, targetType, edgeType, timestamp );
-
final BoundStatement targetSourceTypeStatement = this.targetEdgeSourceTypesWrite
- .bind( applicationUuid, applicationType, targetUuid, sourceType, edgeType, timestamp );
+ .bind( applicationUuid, applicationType, targetUuid, targetType, edgeType, sourceType, timestamp );
return Arrays.asList( sourceStatement, sourceTargetTypeStatement, targetStatement, targetSourceTypeStatement );
@@ -247,7 +251,7 @@ public class EdgeMetadataSerializationImpl implements EdgeMetadataSerialization{
final BoundStatement removeStatement = this.targetEdgeTypesDelete
- .bind( version, applicationUuid, applicationType, targetUuid, targetType, type );
+ .bind( version, applicationUuid, applicationType, targetUuid, type, targetType );
return Collections.singleton( removeStatement );
}
@@ -361,11 +365,12 @@ public class EdgeMetadataSerializationImpl implements EdgeMetadataSerialization{
final String edgeType = search.getEdgeType();
final String start = getStart( search );
+
final int limit = graphFig.getScanPageSize();
- final BoundStatement statement =
- this.targetEdgeSourceTypesSelect.bind( applicationUuid, applicationType, targetId, targetType, edgeType, start );
+ final BoundStatement statement = this.targetEdgeSourceTypesSelect
+ .bind( applicationUuid, applicationType, targetId, targetType, edgeType, start );
statement.setFetchSize( limit );
@@ -383,83 +388,86 @@ public class EdgeMetadataSerializationImpl implements EdgeMetadataSerialization{
@Override
public void prepareStatements() {
/**
- * Source with edge types
- */
- this.sourceEdgeTypesWrite = session.prepare( "INSERT INTO " + CF_SOURCE_EDGE_TYPES
- + " (scopeId, scopeType, sourceNodeId, sourceNodeType, edgeType) VALUES (?, ?, ?, ?, " +
- "?) USING TIMESTAMP ?" );
+ * Source with edge types
+ */
+ this.sourceEdgeTypesWrite = session.prepare( "INSERT INTO " + CF_SOURCE_EDGE_TYPES
+ + " (scopeId, scopeType, sourceNodeId, sourceNodeType, edgeType) VALUES (?, ?, ?, ?, " +
+ "?) USING TIMESTAMP ?" );
- this.sourceEdgeTypesDelete = session.prepare( "DELETE FROM " + CF_SOURCE_EDGE_TYPES
- + " USING TIMESTAMP ? WHERE scopeId = ? AND scopeType = ? AND sourceNodeId = ? AND sourceNodeType = ? " +
- "AND edgeType = ? " );
+ this.sourceEdgeTypesDelete = session.prepare( "DELETE FROM " + CF_SOURCE_EDGE_TYPES
+ + " USING TIMESTAMP ? WHERE scopeId = ? AND scopeType = ? AND sourceNodeId = ? AND sourceNodeType = ? "
+ +
+ "AND edgeType = ? " );
- this.sourceEdgeTypesSelect = session.prepare( "SELECT edgeType FROM " + CF_SOURCE_EDGE_TYPES
- + " WHERE scopeId = ? AND scopeType = ? AND sourceNodeId = ? AND sourceNodeType = ? AND edgeType > ?" );
+ this.sourceEdgeTypesSelect = session.prepare( "SELECT edgeType FROM " + CF_SOURCE_EDGE_TYPES
+ + " WHERE scopeId = ? AND scopeType = ? AND sourceNodeId = ? AND sourceNodeType = ? AND edgeType > ?" );
- /**
- * Source with target types
- */
+ /**
+ * Source with target types
+ */
- this.sourceEdgeTargetTypesWrite = session.prepare( "INSERT INTO " + CF_SOURCE_EDGE_ID_TYPES
- + " (scopeId, scopeType, sourceNodeId, sourceNodeType, edgeType, targetNodeType) VALUES (?, ?, ?, ?, " +
- "?, ?) USING TIMESTAMP ?" );
+ this.sourceEdgeTargetTypesWrite = session.prepare( "INSERT INTO " + CF_SOURCE_EDGE_ID_TYPES
+ + " (scopeId, scopeType, sourceNodeId, sourceNodeType, edgeType, targetNodeType) VALUES (?, ?, ?, ?, " +
+ "?, ?) USING TIMESTAMP ?" );
- this.sourceEdgeTargetTypesDelete = session.prepare( "DELETE FROM " + CF_SOURCE_EDGE_ID_TYPES
- + " USING TIMESTAMP ? WHERE scopeId = ? AND scopeType = ? AND sourceNodeId = ? AND sourceNodeType = ? AND " +
- "edgeType = ? AND targetNodeType = ? " );
+ this.sourceEdgeTargetTypesDelete = session.prepare( "DELETE FROM " + CF_SOURCE_EDGE_ID_TYPES
+ + " USING TIMESTAMP ? WHERE scopeId = ? AND scopeType = ? AND sourceNodeId = ? AND sourceNodeType = ?" +
+ " AND "
+ +
+ "edgeType = ? AND targetNodeType = ? " );
- this.sourceEdgeTargetTypesSelect = session.prepare( "SELECT targetNodeType FROM " + CF_SOURCE_EDGE_ID_TYPES
- + " WHERE scopeId = ? AND scopeType = ? AND sourceNodeId = ? AND sourceNodeType = ? AND " +
- "edgeType = ? AND targetNodeType > ?" );
+ this.sourceEdgeTargetTypesSelect = session.prepare( "SELECT targetNodeType FROM " + CF_SOURCE_EDGE_ID_TYPES
+ + " WHERE scopeId = ? AND scopeType = ? AND sourceNodeId = ? AND sourceNodeType = ? AND " +
+ "edgeType = ? AND targetNodeType > ?" );
- /**
- * Target with edge types
- */
+ /**
+ * Target with edge types
+ */
- this.targetEdgeTypesWrite = session.prepare( "INSERT INTO " + CF_TARGET_EDGE_TYPES
- + " (scopeId, scopeType, targetNodeId, targetNodeType, edgeType) VALUES (?, ?, ?, ?, " +
- "?) USING TIMESTAMP ?" );
+ this.targetEdgeTypesWrite = session.prepare( "INSERT INTO " + CF_TARGET_EDGE_TYPES
+ + " (scopeId, scopeType, targetNodeId, targetNodeType, edgeType) VALUES (?, ?, ?, ?, " +
+ "?) USING TIMESTAMP ?" );
- this.targetEdgeTypesDelete = session.prepare( "DELETE FROM " + CF_TARGET_EDGE_TYPES
- + " USING TIMESTAMP ? WHERE scopeId = ? AND scopeType = ? AND targetNodeId = ? AND targetNodeType = ? AND edgeType = ?" );
+ this.targetEdgeTypesDelete = session.prepare( "DELETE FROM " + CF_TARGET_EDGE_TYPES
+ + " USING TIMESTAMP ? WHERE scopeId = ? AND scopeType = ? AND targetNodeId = ? AND edgeType = ? AND targetNodeType = ?" );
- this.targetEdgeTypesSelect = session.prepare( "SELECT edgeType FROM " + CF_TARGET_EDGE_TYPES
- + " WHERE scopeId = ? AND scopeType = ? AND targetNodeId = ? AND targetNodeType = ?" );
+ this.targetEdgeTypesSelect = session.prepare( "SELECT edgeType FROM " + CF_TARGET_EDGE_TYPES
+ + " WHERE scopeId = ? AND scopeType = ? AND targetNodeId = ? AND targetNodeType = ? AND edgeType > ?" );
- /**
- * Target with source edge types
- */
- this.targetEdgeSourceTypesWrite = session.prepare( "INSERT INTO " + CF_TARGET_EDGE_ID_TYPES
- + " (scopeId, scopeType, targetNodeId, targetNodeType, edgeType, sourceNodeType) VALUES (?, ?, ?, ?, " +
- "?, ?) USING TIMESTAMP ?" );
+ /**
+ * Target with source edge types
+ */
+ this.targetEdgeSourceTypesWrite = session.prepare( "INSERT INTO " + CF_TARGET_EDGE_ID_TYPES
+ + " (scopeId, scopeType, targetNodeId, targetNodeType, edgeType, sourceNodeType) VALUES (?, ?, ?, ?, " +
+ "?, ?) USING TIMESTAMP ?" );
- this.targetEdgeSourceTypesDelete = session.prepare( "DELETE FROM " + CF_TARGET_EDGE_ID_TYPES
- + " USING TIMESTAMP ? WHERE scopeId = ? AND scopeType = ? AND targetNodeId = ? AND targetNodeType = ? AND " +
- "sourceNodeType = ? " );
+ this.targetEdgeSourceTypesDelete = session.prepare( "DELETE FROM " + CF_TARGET_EDGE_ID_TYPES
+ + " USING TIMESTAMP ? WHERE scopeId = ? AND scopeType = ? AND targetNodeId = ? AND targetNodeType = ? AND edgeType = ?" +
+ " AND sourceNodeType = ? " );
- this.targetEdgeSourceTypesSelect = session.prepare( "SELECT sourceNodeType FROM " + CF_TARGET_EDGE_ID_TYPES
- + " WHERE scopeId = ? AND scopeType = ? AND targetNodeId = ? AND targetNodeType = ? AND edgeType = ?" +
- " AND sourceNodeType > ?" );
+ this.targetEdgeSourceTypesSelect = session.prepare( "SELECT sourceNodeType FROM " + CF_TARGET_EDGE_ID_TYPES
+ + " WHERE scopeId = ? AND scopeType = ? AND targetNodeId = ? AND targetNodeType = ? AND edgeType = ?" +
+ " AND sourceNodeType > ?" );
}
private String getStart( final SearchEdgeType search ) {
final Optional<String> last = search.getLast();
- if(last.isPresent()){
+ if ( last.isPresent() ) {
return last.get();
}
final Optional<String> prefix = search.prefix();
- if(prefix.isPresent()){
+ if ( prefix.isPresent() ) {
return prefix + "\uffff";
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/3e941cdf/stack/corepersistence/graph/src/test/java/org/apache/usergrid/persistence/graph/serialization/EdgeMetadataSerializationTest.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/graph/src/test/java/org/apache/usergrid/persistence/graph/serialization/EdgeMetadataSerializationTest.java b/stack/corepersistence/graph/src/test/java/org/apache/usergrid/persistence/graph/serialization/EdgeMetadataSerializationTest.java
index 8001ea1..c85637a 100644
--- a/stack/corepersistence/graph/src/test/java/org/apache/usergrid/persistence/graph/serialization/EdgeMetadataSerializationTest.java
+++ b/stack/corepersistence/graph/src/test/java/org/apache/usergrid/persistence/graph/serialization/EdgeMetadataSerializationTest.java
@@ -93,6 +93,8 @@ public class EdgeMetadataSerializationTest {
when( orgId.getUuid() ).thenReturn( UUIDGenerator.newTimeUUID() );
when( scope.getApplication() ).thenReturn( orgId );
+
+ serialization.prepareStatements();
}