You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@usergrid.apache.org by sf...@apache.org on 2015/03/16 01:25:02 UTC

[07/11] incubator-usergrid git commit: [USERGRID-396] Added ability to short circuit if not unique id's are found.

[USERGRID-396] Added ability to short circuit if not unique id's are found.


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

Branch: refs/heads/two-dot-o
Commit: a6929ab249e88d85c6025660f44392ed2b9c93a7
Parents: c872b69
Author: GERey <gr...@apigee.com>
Authored: Thu Mar 12 12:07:46 2015 -0700
Committer: GERey <gr...@apigee.com>
Committed: Thu Mar 12 12:07:46 2015 -0700

----------------------------------------------------------------------
 .../impl/EntityCollectionManagerImpl.java           | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/a6929ab2/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/impl/EntityCollectionManagerImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/impl/EntityCollectionManagerImpl.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/impl/EntityCollectionManagerImpl.java
index d95183d..7db34aa 100644
--- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/impl/EntityCollectionManagerImpl.java
+++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/impl/EntityCollectionManagerImpl.java
@@ -287,6 +287,12 @@ public class EntityCollectionManagerImpl implements EntityCollectionManager {
         } );
     }
 
+
+    /**
+     * Retrieves all entities that correspond to each field given in the Collection.
+     * @param fields
+     * @return
+     */
     @Override
     public Observable<FieldSet> getAllEntities(final Collection<Field> fields) {
         return rx.Observable.just(fields).map( new Func1<Collection<Field>, FieldSet>() {
@@ -296,8 +302,14 @@ public class EntityCollectionManagerImpl implements EntityCollectionManager {
 
                     final UUID startTime = UUIDGenerator.newTimeUUID();
 
+                    //Get back set of unique values that correspond to collection of fields
                     UniqueValueSet set = uniqueValueSerializationStrategy.load( collectionScope, fields );
 
+                    //Short circut if we don't have any uniqueValues from the given fields.
+                    if(!set.iterator().hasNext()){
+                        return new FieldSetImpl( 0 );
+                    }
+
 
                     //loop through each field, and construct an entity load
                     List<Id> entityIds = new ArrayList<>(fields.size());
@@ -311,6 +323,7 @@ public class EntityCollectionManagerImpl implements EntityCollectionManager {
                         uniqueValues.add(value);
                     }
 
+                    //Load a entity for each entityId we retrieved.
                     final EntitySet entitySet = entitySerializationStrategy.load(collectionScope, entityIds, startTime);
 
                     //now loop through and ensure the entities are there.
@@ -334,7 +347,8 @@ public class EntityCollectionManagerImpl implements EntityCollectionManager {
 
                     }
 
-                    //fire and forget, we don't care.  We'll repair it again if we have to
+                    //TODO: explore making this an Async process
+                    //We'll repair it again if we have to
                     deleteBatch.execute();
 
                     return response;