usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From toddn...@apache.org
Subject [19/19] incubator-usergrid git commit: Updated bi-directional to create 2 directional indexes
Date Fri, 22 May 2015 00:22:17 GMT
Updated bi-directional to create 2 directional indexes


Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/f7b47a84
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/f7b47a84
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/f7b47a84

Branch: refs/heads/USERGRID-641
Commit: f7b47a845bcbe30c066d8d8855aa3e3572b0a548
Parents: 17d2d73
Author: Todd Nine <tnine@apigee.com>
Authored: Thu May 21 18:21:54 2015 -0600
Committer: Todd Nine <tnine@apigee.com>
Committed: Thu May 21 18:21:54 2015 -0600

----------------------------------------------------------------------
 .../corepersistence/CpRelationManager.java      | 26 ++++++++---
 .../corepersistence/index/IndexServiceImpl.java | 46 +-------------------
 2 files changed, 20 insertions(+), 52 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/f7b47a84/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpRelationManager.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpRelationManager.java
b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpRelationManager.java
index 4a2d887..c31288a 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpRelationManager.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpRelationManager.java
@@ -72,6 +72,7 @@ import org.apache.usergrid.persistence.index.query.Identifier;
 import org.apache.usergrid.persistence.model.entity.Id;
 import org.apache.usergrid.persistence.model.entity.SimpleId;
 import org.apache.usergrid.persistence.schema.CollectionInfo;
+import org.apache.usergrid.utils.InflectionUtils;
 import org.apache.usergrid.utils.MapUtils;
 
 import com.google.common.base.Optional;
@@ -397,16 +398,27 @@ public class CpRelationManager implements RelationManager {
             logger.debug( "Wrote edge {}", edge );
         }
 
-        indexService.queueNewEdge(applicationScope, memberEntity, edge);
-        //reverse
-        if(!cpHeadEntity.getId().getType().equals("application")) {
-            String pluralType =  InflectionUtils.pluralize(cpHeadEntity.getId().getType());
-            final Edge reverseEdge = createCollectionEdge(memberEntity.getId(), pluralType,
cpHeadEntity.getId());
-            gm.writeEdge(reverseEdge).toBlocking().last();
-            indexService.queueNewEdge(applicationScope, cpHeadEntity, reverseEdge);
+
+        //check if we need to reverse our edges
+
+
+        final String linkedCollection = collection.getLinkedCollection();
+
+        /**
+         * Nothing to link
+         */
+        if ( linkedCollection != null ) {
+            String pluralType = InflectionUtils.pluralize( cpHeadEntity.getId().getType()
);
+            final Edge reverseEdge = createCollectionEdge( memberEntity.getId(), pluralType,
cpHeadEntity.getId() );
+            gm.writeEdge( reverseEdge ).toBlocking().last();
         }
 
 
+        indexService.queueNewEdge( applicationScope, memberEntity, edge );
+
+
+
+
         if ( logger.isDebugEnabled() ) {
             logger.debug( "Added entity {}:{} to collection {}", new Object[] {
                 itemRef.getUuid().toString(), itemRef.getType(), collectionName

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/f7b47a84/stack/core/src/main/java/org/apache/usergrid/corepersistence/index/IndexServiceImpl.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/index/IndexServiceImpl.java
b/stack/core/src/main/java/org/apache/usergrid/corepersistence/index/IndexServiceImpl.java
index 9bb0728..b57ea92 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/index/IndexServiceImpl.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/index/IndexServiceImpl.java
@@ -102,20 +102,13 @@ public class IndexServiceImpl implements IndexService {
         //we may have to index  we're indexing from source->target here
         final Observable<IndexEdge> sourceEdgesToIndex = edgesToTarget.map( edge ->
generateScopeFromSource( edge ) );
 
-
-        //we might or might not need to index from target-> source
-        final Observable<IndexEdge> edgesToSource = getIndexEdgesAsTarget( gm, entityId
);
-
-
-        //merge the edges together
-        final Observable<IndexEdge> observable = Observable.merge( sourceEdgesToIndex,
edgesToSource);
         //do our observable for batching
         //try to send a whole batch if we can
 
 
         //do our observable for batching
         //try to send a whole batch if we can
-        final Observable<IndexOperationMessage>  batches =  observable.buffer( indexFig.getIndexBatchSize()
)
+        final Observable<IndexOperationMessage>  batches =  sourceEdgesToIndex.buffer(
indexFig.getIndexBatchSize() )
 
             //map into batches based on our buffer size
             .flatMap( buffer -> Observable.from( buffer )
@@ -182,44 +175,7 @@ public class IndexServiceImpl implements IndexService {
     }
 
 
-    /**
-     * Get index edges to the target.  Used in only certain entity types, such as roles,
users, groups etc
-     * where we doubly index on both directions of the edge
-     *
-     * @param graphManager The graph manager
-     * @param entityId The entity's id
-     */
-    private Observable<IndexEdge> getIndexEdgesAsTarget( final GraphManager graphManager,
final Id entityId ) {
-
-        final String collectionName = InflectionUtils.pluralize( entityId.getType() );
-
-
-        final CollectionInfo collection = getDefaultSchema().getCollection( Application.ENTITY_TYPE,
collectionName );
 
-        //nothing to do
-        if ( collection == null ) {
-            return Observable.empty();
-        }
-
-
-        final String linkedCollection = collection.getLinkedCollection();
-
-        /**
-         * Nothing to link
-         */
-        if ( linkedCollection == null ) {
-            return Observable.empty();
-        }
-
-
-        /**
-         * An observable of sizes as we execute batches
-         *
-         * we're indexing from target->source here
-         */
-        return edgesObservable.getEdgesFromSource( graphManager, entityId, linkedCollection
)
-                              .map( edge -> generateScopeFromTarget( edge ) );
-    }
 
 
 


Mime
View raw message