Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CASSANDRA-20100 Interpret int, bigint, varint, and decimal as non-reversed types for query construction and post-filtering #3702

Open
wants to merge 1 commit into
base: trunk
Choose a base branch
from

Conversation

maedhroz
Copy link
Contributor

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

@maedhroz maedhroz force-pushed the CASSANDRA-20100-trunk branch 3 times, most recently from cf17000 to f82ab98 Compare November 21, 2024 02:15
@@ -141,20 +141,24 @@ private IndexTermType(ColumnMetadata columnMetadata, List<ColumnMetadata> partit
this.indexTargetType = indexTargetType;
this.capabilities = calculateCapabilities(columnMetadata, partitionColumns, indexTargetType);
this.indexType = calculateIndexType(columnMetadata.type, capabilities, indexTargetType);
if (indexType.subTypes().isEmpty())

AbstractType<?> baseType = indexType.unwrap();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This bit isn't part of the issue described in the Jira, but it's just...clearly wrong, so I cleaned it up.

// Override comparisons for frozen collections and composite types (map entries)
else if (isLong() || isBigDecimal() || isBigInteger())
return indexType.unwrap().compare(requestedValue.raw, columnValue.raw);
// Override comparisons for frozen collections and composite types (map entries)
else if (isComposite() || isFrozen())
return FastByteOperations.compareUnsigned(requestedValue.raw, columnValue.raw);

Copy link
Contributor Author

@maedhroz maedhroz Nov 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The question I would have as a reviewer here is why, since we're just post-filtering, we don't unwrap on the next line, when we've fallen through the other cases. The bounds from Expression are used to generate queries for the memtable index, the on-disk indexes, and also to do post-filtering. Because of the first two, and the fact that we currently index reversed byte-comparable for most reversed types, we reverse the bounds on Expression as well. In those cases, post-filtering uses the reversed compare() to "undo" that. Ultimately, we should fix this, especially if we want to change the on-disk format and memtable-adjacent index to always use the base type byte-comparable, but it would be more invasive (i.e. require making changes to query generation for both of those if we don't change the disk format).

I think for now what I'd like to do is simply comment this next line to explain ^

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

took a bit for my brain to process, and you dumping in slack... data on disk is backwards due to ReverseType reversing the bytes, so we need to live with this behavior which is a pain... :sigh:

}

if (reversed)
capabilities.add(Capability.REVERSED);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These will now have isReversed() return false during Expression creation to align w/ the fact we don't actually index reversed byte-comparables for these types.

@@ -26,7 +30,7 @@
public class DescClusteringRangeQueryTest extends SAITester
{
@Test
public void testReverseAndBetweenMemtable()
public void testReversedIntBetween() throws Throwable
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Notes: int behaves the same as all the other non-long primitive numerics, and UUID is EQ-only ATM

…query construction and post-filtering

patch by Caleb Rackliffe; reviewed by ? for CASSANDRA-20100
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants