usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From snoopd...@apache.org
Subject [13/29] usergrid git commit: Fix delete so that it doesn't return null
Date Tue, 01 Dec 2015 14:25:43 GMT
Fix delete so that it doesn't return null


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

Branch: refs/heads/USERGRID-872
Commit: 88f6feae8c8d635598954ee9a5d239eda42653bd
Parents: 9bc2241
Author: Michael Russo <michaelarusso@gmail.com>
Authored: Thu Nov 19 09:43:36 2015 -0800
Committer: Michael Russo <michaelarusso@gmail.com>
Committed: Thu Nov 19 09:43:36 2015 -0800

----------------------------------------------------------------------
 .../asyncevents/EventBuilderImpl.java           | 39 +++++++++-----------
 1 file changed, 17 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/usergrid/blob/88f6feae/stack/core/src/main/java/org/apache/usergrid/corepersistence/asyncevents/EventBuilderImpl.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/asyncevents/EventBuilderImpl.java
b/stack/core/src/main/java/org/apache/usergrid/corepersistence/asyncevents/EventBuilderImpl.java
index d819f39..9b68c4c 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/asyncevents/EventBuilderImpl.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/asyncevents/EventBuilderImpl.java
@@ -125,42 +125,37 @@ public class EventBuilderImpl implements EventBuilder {
         log.debug( "Deleting entity id from index in app scope {} with entityId {} }", applicationScope,
entityId );
 
         final EntityCollectionManager ecm = entityCollectionManagerFactory.createCollectionManager(
applicationScope );
-
         final GraphManager gm = graphManagerFactory.createEdgeManager( applicationScope );
 
+        //TODO USERGRID-1123: Implement so we don't iterate logs twice (latest DELETED version,
then to get all DELETED)
 
-        //TODO: change this to be an observable
-        //so we get these versions and loop through them until we find the MvccLogEntry that
is marked as delete.
-        //TODO: evauluate this to possibly be an observable to pass to the nextmethod.
         MvccLogEntry mostRecentlyMarked = ecm.getVersions( entityId ).toBlocking()
                                              .firstOrDefault( null,
                                                  mvccLogEntry -> mvccLogEntry.getState()
== MvccLogEntry.State.DELETED );
 
-        //If there is nothing marked then we shouldn't return any results.
-        //TODO: evaluate if we want to return null or return empty observable when we don't
have any results marked as deleted.
-        if(mostRecentlyMarked == null)
-            return null;
+        // De-indexing and entity deletes don't check log entiries.  We must do that first.
If no DELETED logs, then
+        // return an empty observable as our no-op.
+        Observable<IndexOperationMessage> deIndexObservable = Observable.empty();
+        Observable<List<MvccLogEntry>> ecmDeleteObservable = Observable.empty();
 
-        //observable of index operation messages
-        //this method will need the most recent version.
-        //When we go to compact the graph make sure you turn on the debugging mode for the
deleted nodes so
-        //we can verify that we mark them. That said that part seems kinda done. as we also
delete the mvcc buffers.
-        final Observable<IndexOperationMessage> edgeObservable =
-            indexService.deleteEntityIndexes( applicationScope, entityId, mostRecentlyMarked.getVersion()
);
+        if(mostRecentlyMarked != null){
+            deIndexObservable =
+                indexService.deleteEntityIndexes( applicationScope, entityId, mostRecentlyMarked.getVersion()
);
 
+            ecmDeleteObservable =
+                ecm.getVersions( entityId )
+                    .filter( mvccLogEntry-> mvccLogEntry.getState() == MvccLogEntry.State.DELETED)
+                    .buffer( serializationFig.getBufferSize() )
+                    .doOnNext( buffer -> ecm.delete( buffer ) );
 
-        //TODO: not sure what we need the list of versions here when we search for the mark
above
-        //observable of entries as the batches are deleted
-        final Observable<List<MvccLogEntry>> entries =
-            ecm.getVersions( entityId ).buffer( serializationFig.getBufferSize() )
-               .doOnNext( buffer -> ecm.delete( buffer ) );
 
+        }
 
-        // observable of the edge delete from graph
-        final Observable<Id> compactedNode = gm.compactNode(entityId);
 
+        // Graph compaction checks the versions inside compactNode, just build this up for
the caller to subscribe to
+        final Observable<Id> graphCompactObservable = gm.compactNode(entityId);
 
-        return new EntityDeleteResults( edgeObservable, entries, compactedNode );
+        return new EntityDeleteResults( deIndexObservable, ecmDeleteObservable, graphCompactObservable
);
     }
 
 


Mime
View raw message