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/10/09 21:36:18 UTC

git commit: Fixes implementation of observables to be lazy load

Repository: incubator-usergrid
Updated Branches:
  refs/heads/collection_multiget 7af7e702e -> b3515f45c


Fixes implementation of observables to be lazy load


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

Branch: refs/heads/collection_multiget
Commit: b3515f45cdfdcc0eedd6e667701f69eccad37a7d
Parents: 7af7e70
Author: Todd Nine <to...@apache.org>
Authored: Thu Oct 9 13:36:12 2014 -0600
Committer: Todd Nine <to...@apache.org>
Committed: Thu Oct 9 13:36:12 2014 -0600

----------------------------------------------------------------------
 .../impl/EntityCollectionManagerImpl.java       | 45 ++++++++++++++++----
 1 file changed, 37 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/b3515f45/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 c47bf1a..32f214f 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
@@ -59,6 +59,7 @@ import com.google.inject.Inject;
 import com.google.inject.assistedinject.Assisted;
 
 import rx.Observable;
+import rx.Subscriber;
 import rx.functions.Action1;
 import rx.functions.Func1;
 import rx.schedulers.Schedulers;
@@ -212,10 +213,25 @@ public class EntityCollectionManagerImpl implements EntityCollectionManager {
 
         Preconditions.checkNotNull( entityIds, "entityIds cannot be null" );
 
-        final EntitySet results =
-                entitySerializationStrategy.load( collectionScope, entityIds, UUIDGenerator.newTimeUUID() );
+        return Observable.create( new Observable.OnSubscribe<EntitySet>() {
+
+            @Override
+            public void call( final Subscriber<? super EntitySet> subscriber ) {
+                try {
+                    final EntitySet results =
+                                   entitySerializationStrategy.load( collectionScope, entityIds, UUIDGenerator.newTimeUUID() );
+
+                    subscriber.onNext( results );
+                    subscriber.onCompleted();
+                }
+                catch ( Exception e ) {
+                    subscriber.onError( e );
+                }
+            }
+        } );
+
+
 
-        return Observable.just( results );
     }
 
 
@@ -284,13 +300,26 @@ public class EntityCollectionManagerImpl implements EntityCollectionManager {
 
 
     @Override
-    public Observable<VersionSet> getLatestVersion(
-            Collection<Id> entityIds ) {
+    public Observable<VersionSet> getLatestVersion( final Collection<Id> entityIds ) {
+
+        return Observable.create( new Observable.OnSubscribe<VersionSet>() {
+
+                  @Override
+                  public void call( final Subscriber<? super VersionSet> subscriber ) {
+                      try {
+                          final  VersionSet logEntries = mvccLogEntrySerializationStrategy.load( collectionScope, entityIds,
+                                          UUIDGenerator.newTimeUUID() );
+
+                          subscriber.onNext( logEntries );
+                          subscriber.onCompleted();
+                      }
+                      catch ( Exception e ) {
+                          subscriber.onError( e );
+                      }
+                  }
+              } );
 
-        VersionSet logEntries = mvccLogEntrySerializationStrategy.load( collectionScope, entityIds,
-                UUIDGenerator.newTimeUUID() );
 
 
-        return Observable.just(logEntries);
     }
 }