You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jackrabbit.apache.org by "fabriziofortino (via GitHub)" <gi...@apache.org> on 2023/10/12 16:17:24 UTC

[PR] OAK-10487: replaced lsm estimator with cacheable count [jackrabbit-oak]

fabriziofortino opened a new pull request, #1149:
URL: https://github.com/apache/jackrabbit-oak/pull/1149

   (no comment)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@jackrabbit.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] OAK-10487: replaced lsm estimator with cacheable count [jackrabbit-oak]

Posted by "fabriziofortino (via GitHub)" <gi...@apache.org>.
fabriziofortino commented on code in PR #1149:
URL: https://github.com/apache/jackrabbit-oak/pull/1149#discussion_r1363811448


##########
oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticIndexStatistics.java:
##########
@@ -251,26 +264,33 @@ static class StatsRequestDescriptor {
         final String index;
         @Nullable
         final String field;
+        @Nullable
+        final Query query;
 
         StatsRequestDescriptor(@NotNull ElasticConnection connection,
                                @NotNull String index) {
-            this(connection, index, null);
+            this(connection, index, null, null);
         }
 
         StatsRequestDescriptor(@NotNull ElasticConnection connection,
-                               @NotNull String index, @Nullable String field) {
+                               @NotNull String index, @Nullable String field, @Nullable Query query) {
             this.connection = connection;
             this.index = index;
             this.field = field;
+            this.query = query;
         }
 
         @Override
         public boolean equals(Object o) {
             if (this == o) return true;
             if (o == null || getClass() != o.getClass()) return false;
             StatsRequestDescriptor that = (StatsRequestDescriptor) o;
+            String thisInternalQuery = query != null ? query.toString() : null;
+            String thatInternalQuery = that.query != null ? that.query.toString() : null;
             return index.equals(that.index) &&
-                    Objects.equals(field, that.field);
+                    Objects.equals(field, that.field) &&
+                    // ES Query objects are not comparable, so we need to compare their string representations
+                    Objects.equals(thisInternalQuery, thatInternalQuery);
         }

Review Comment:
   good catch! Done.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@jackrabbit.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] OAK-10487: replaced lsm estimator with cacheable count [jackrabbit-oak]

Posted by "nfsantos (via GitHub)" <gi...@apache.org>.
nfsantos commented on code in PR #1149:
URL: https://github.com/apache/jackrabbit-oak/pull/1149#discussion_r1363734389


##########
oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticIndexStatistics.java:
##########
@@ -251,26 +264,33 @@ static class StatsRequestDescriptor {
         final String index;
         @Nullable
         final String field;
+        @Nullable
+        final Query query;
 
         StatsRequestDescriptor(@NotNull ElasticConnection connection,
                                @NotNull String index) {
-            this(connection, index, null);
+            this(connection, index, null, null);
         }
 
         StatsRequestDescriptor(@NotNull ElasticConnection connection,
-                               @NotNull String index, @Nullable String field) {
+                               @NotNull String index, @Nullable String field, @Nullable Query query) {
             this.connection = connection;
             this.index = index;
             this.field = field;
+            this.query = query;
         }
 
         @Override
         public boolean equals(Object o) {
             if (this == o) return true;
             if (o == null || getClass() != o.getClass()) return false;
             StatsRequestDescriptor that = (StatsRequestDescriptor) o;
+            String thisInternalQuery = query != null ? query.toString() : null;
+            String thatInternalQuery = that.query != null ? that.query.toString() : null;
             return index.equals(that.index) &&
-                    Objects.equals(field, that.field);
+                    Objects.equals(field, that.field) &&
+                    // ES Query objects are not comparable, so we need to compare their string representations
+                    Objects.equals(thisInternalQuery, thatInternalQuery);
         }

Review Comment:
   Maybe you should also update hashCode to consider the query string. I think having hashCode consider only a subset of fields from equals does not violate the contract for hashCode, but might not be optimal as it will increase the chance of collisions (two different objects with the same values in index and field will have the same hash code).



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@jackrabbit.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] OAK-10487: replaced lsm estimator with cacheable count [jackrabbit-oak]

Posted by "fabriziofortino (via GitHub)" <gi...@apache.org>.
fabriziofortino merged PR #1149:
URL: https://github.com/apache/jackrabbit-oak/pull/1149


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@jackrabbit.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org