usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdun...@apache.org
Subject [02/15] usergrid git commit: USERGRID-1056 - Move the filtering of older entity versions on index deletes to Usergrid and not in the Elasticsearch query.
Date Thu, 22 Oct 2015 18:29:31 GMT
USERGRID-1056 - Move the filtering of older entity versions on index deletes to Usergrid and
not in the Elasticsearch query.


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

Branch: refs/heads/2.1-release
Commit: 2c1147e49f76702dcf03ecaef6ece1f30306aa5f
Parents: c417099
Author: Michael Russo <michaelarusso@gmail.com>
Authored: Wed Oct 21 14:07:18 2015 -0700
Committer: Michael Russo <michaelarusso@gmail.com>
Committed: Wed Oct 21 14:07:18 2015 -0700

----------------------------------------------------------------------
 .../index/impl/EsEntityIndexImpl.java           | 45 +++++++++++++++-----
 1 file changed, 35 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/usergrid/blob/2c1147e4/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java
b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java
index f6ebce2..9be591e 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java
@@ -460,7 +460,7 @@ public class EsEntityIndexImpl implements EntityIndex,VersionedData {
 
             while(true){
                 //add search result hits to some sort of running tally of hits.
-                candidates = aggregateScrollResults( candidates, searchResponse );
+                candidates = aggregateScrollResults( candidates, searchResponse, null );
 
                 SearchScrollRequestBuilder ssrb = searchRequestBuilderStrategyV2
                     .getScrollBuilder( searchResponse.getScrollId() )
@@ -510,11 +510,7 @@ public class EsEntityIndexImpl implements EntityIndex,VersionedData {
         FilterBuilder entityIdFilter = FilterBuilders.termFilter(IndexingUtils.ENTITY_ID_FIELDNAME,
             IndexingUtils.entityId(entityId));
 
-        FilterBuilder entityVersionFilter = FilterBuilders.rangeFilter( IndexingUtils.ENTITY_VERSION_FIELDNAME
).lte(markedVersion);
-
-        FilterBuilder andFilter = FilterBuilders.andFilter(entityIdFilter, entityVersionFilter);
-
-        srb.setPostFilter(andFilter);
+        srb.setPostFilter(entityIdFilter);
 
 
 
@@ -536,7 +532,7 @@ public class EsEntityIndexImpl implements EntityIndex,VersionedData {
 
             while(true){
                 //add search result hits to some sort of running tally of hits.
-                candidates = aggregateScrollResults( candidates, searchResponse );
+                candidates = aggregateScrollResults( candidates, searchResponse, markedVersion);
 
                 SearchScrollRequestBuilder ssrb = searchRequestBuilderStrategyV2
                     .getScrollBuilder( searchResponse.getScrollId() )
@@ -649,8 +645,8 @@ public class EsEntityIndexImpl implements EntityIndex,VersionedData {
         return candidateResults;
     }
 
-    private List<CandidateResult> aggregateScrollResults( List<CandidateResult>
candidates,
-                                                          final SearchResponse searchResponse
){
+    private List<CandidateResult> aggregateScrollResults(List<CandidateResult>
candidates,
+                                                         final SearchResponse searchResponse,
final UUID markedVersion){
 
         final SearchHits searchHits = searchResponse.getHits();
         final SearchHit[] hits = searchHits.getHits();
@@ -659,7 +655,36 @@ public class EsEntityIndexImpl implements EntityIndex,VersionedData {
 
             final CandidateResult candidateResult = parseIndexDocId( hit.getId() );
 
-            candidates.add( candidateResult );
+            // if comparing against the latestVersion, make sure we only add the candidateResult
if it's
+            // older than or equal to the latest marked version
+            if (markedVersion != null) {
+
+                if(candidateResult.getVersion().timestamp() <= markedVersion.timestamp()){
+
+                    if(logger.isDebugEnabled()){
+                        logger.debug("Candidate version {} is <= provided entity version
{} for entityId {}",
+                            candidateResult.getVersion(),
+                            markedVersion,
+                            candidateResult.getId()
+                            );
+                    }
+
+                    candidates.add(candidateResult);
+
+                }else{
+                    if(logger.isDebugEnabled()){
+                        logger.debug("Candidate version {} is > provided entity version
{} for entityId {}. Not" +
+                                "adding to candidate results",
+                            candidateResult.getVersion(),
+                            markedVersion,
+                            candidateResult.getId()
+                        );
+                    }
+                }
+
+            }else{
+                candidates.add(candidateResult);
+            }
         }
 
         logger.debug( "Aggregated {} out of {} hits ",candidates.size(),searchHits.getTotalHits()
);


Mime
View raw message