You are viewing a plain text version of this content. The canonical link for it is here.
Posted to pr@cassandra.apache.org by "maedhroz (via GitHub)" <gi...@apache.org> on 2025/02/10 22:30:49 UTC

[PR] CASSANDRA-20313 Avoid indexing empty values for non-literals and types that do not allow them [cassandra]

maedhroz opened a new pull request, #3884:
URL: https://github.com/apache/cassandra/pull/3884

   patch by Caleb Rackliffe; reviewed by ? for CASSANDRA-20313


-- 
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: pr-unsubscribe@cassandra.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


Re: [PR] CASSANDRA-20313 Avoid indexing empty values for non-literals and types that do not allow them [cassandra]

Posted by "maedhroz (via GitHub)" <gi...@apache.org>.
maedhroz closed pull request #3884: CASSANDRA-20313 Avoid indexing empty values for non-literals and types that do not allow them
URL: https://github.com/apache/cassandra/pull/3884


-- 
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: pr-unsubscribe@cassandra.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


Re: [PR] CASSANDRA-20313 Avoid indexing empty values for non-literals and types that do not allow them [cassandra]

Posted by "dcapwell (via GitHub)" <gi...@apache.org>.
dcapwell commented on code in PR #3884:
URL: https://github.com/apache/cassandra/pull/3884#discussion_r1950004238


##########
src/java/org/apache/cassandra/index/sai/utils/IndexTermType.java:
##########
@@ -541,6 +549,9 @@ else if (isBigDecimal())
 
     public ByteSource asComparableBytes(ByteBuffer value, ByteComparable.Version version)
     {
+        if (value.remaining() == 0)
+            return ByteSource.EMPTY;

Review Comment:
   is this safe though in general?  shouldn't we check for the expected types?



-- 
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: pr-unsubscribe@cassandra.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


Re: [PR] CASSANDRA-20313 Avoid indexing empty values for non-literals and types that do not allow them [cassandra]

Posted by "maedhroz (via GitHub)" <gi...@apache.org>.
maedhroz commented on PR #3884:
URL: https://github.com/apache/cassandra/pull/3884#issuecomment-2652125322

   Committed as https://github.com/apache/cassandra/commit/d77ac1a3258197e18f864d080d06e795037993bf


-- 
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: pr-unsubscribe@cassandra.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


Re: [PR] CASSANDRA-20313 Avoid indexing empty values for non-literals and types that do not allow them [cassandra]

Posted by "maedhroz (via GitHub)" <gi...@apache.org>.
maedhroz commented on code in PR #3884:
URL: https://github.com/apache/cassandra/pull/3884#discussion_r1949995884


##########
src/java/org/apache/cassandra/index/sai/utils/IndexTermType.java:
##########
@@ -541,6 +549,9 @@ else if (isBigDecimal())
 
     public ByteSource asComparableBytes(ByteBuffer value, ByteComparable.Version version)
     {
+        if (value.remaining() == 0)
+            return ByteSource.EMPTY;

Review Comment:
   boolean and a couple other types will return `null` from their implementations of `asComparableBytes()` if we don't do this



-- 
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: pr-unsubscribe@cassandra.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


Re: [PR] CASSANDRA-20313 Avoid indexing empty values for non-literals and types that do not allow them [cassandra]

Posted by "maedhroz (via GitHub)" <gi...@apache.org>.
maedhroz commented on code in PR #3884:
URL: https://github.com/apache/cassandra/pull/3884#discussion_r1949998349


##########
src/java/org/apache/cassandra/index/sai/utils/IndexTermType.java:
##########
@@ -275,6 +275,14 @@ public boolean isValid(ByteBuffer term)
         }
     }
 
+    /**
+     * @return {@code true} if the empty values of the given type should be excluded from indexing
+     */
+    public boolean skipsEmptyValue()
+    {
+        return !indexType.allowsEmpty() || !isLiteral();

Review Comment:
   The alternative here is to use `isEmptyValueMeaningless()` instead of `!isLiteral()`, which would mean empty values for boolean and a few other things would no longer be indexed. This makes sense if you don't believe querying on empty values for non-string types is useful, but it obviously diverges from what non-index filtering queries seem to do right now.



-- 
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: pr-unsubscribe@cassandra.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


Re: [PR] CASSANDRA-20313 Avoid indexing empty values for non-literals and types that do not allow them [cassandra]

Posted by "maedhroz (via GitHub)" <gi...@apache.org>.
maedhroz commented on code in PR #3884:
URL: https://github.com/apache/cassandra/pull/3884#discussion_r1950008516


##########
src/java/org/apache/cassandra/index/sai/utils/IndexTermType.java:
##########
@@ -541,6 +549,9 @@ else if (isBigDecimal())
 
     public ByteSource asComparableBytes(ByteBuffer value, ByteComparable.Version version)
     {
+        if (value.remaining() == 0)
+            return ByteSource.EMPTY;

Review Comment:
   Possibly...I'll think this one over a bit. Keep in mind that these values only have to be consistent in index space. i.e. As long as this is the value queries would use for empty, it should be fine.



-- 
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: pr-unsubscribe@cassandra.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


Re: [PR] CASSANDRA-20313 Avoid indexing empty values for non-literals and types that do not allow them [cassandra]

Posted by "adelapena (via GitHub)" <gi...@apache.org>.
adelapena commented on code in PR #3884:
URL: https://github.com/apache/cassandra/pull/3884#discussion_r1950783404


##########
src/java/org/apache/cassandra/index/sai/utils/IndexTermType.java:
##########
@@ -275,6 +275,14 @@ public boolean isValid(ByteBuffer term)
         }
     }
 
+    /**
+     * @return {@code true} if the empty values of the given type should be excluded from indexing
+     */
+    public boolean skipsEmptyValue()
+    {
+        return !indexType.allowsEmpty() || !isLiteral();

Review Comment:
   I think it's better to keep indexing boolean and frozen multicells, so we keep previous not-broken behaviour, and because probably in the long run we'll want to index all types of empty values. Fortunately, all the types that are indexed as literals have a meaningless empty value.



-- 
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: pr-unsubscribe@cassandra.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org