You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by dc...@apache.org on 2025/01/08 01:49:27 UTC

(cassandra) branch trunk updated (8fcbe3ff6e -> 6843514597)

This is an automated email from the ASF dual-hosted git repository.

dcapwell pushed a change to branch trunk
in repository https://gitbox.apache.org/repos/asf/cassandra.git


    from 8fcbe3ff6e Merge branch 'cassandra-5.0' into trunk
     new 4fc8bb29fc IndexOutOfBoundsException when accessing partition where the column was deleted
     new 4da92af589 Merge branch 'cassandra-4.0' into cassandra-4.1
     new 8125a69480 Merge branch 'cassandra-4.1' into cassandra-5.0
     new 6843514597 Merge branch 'cassandra-5.0' into trunk

The 4 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 CHANGES.txt                                        |  1 +
 .../org/apache/cassandra/db/filter/RowFilter.java  | 29 +++++++++++----------
 .../cql3/validation/operations/SelectTest.java     | 30 ++++++++++++++++++++++
 .../cassandra/index/sai/plan/OperationTest.java    |  2 +-
 .../cassandra/index/sasi/plan/OperationTest.java   |  2 +-
 5 files changed, 49 insertions(+), 15 deletions(-)


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


(cassandra) 01/01: Merge branch 'cassandra-5.0' into trunk

Posted by dc...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

dcapwell pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/cassandra.git

commit 68435145978a3d20f02f47dde7e9a6adcf594419
Merge: 8fcbe3ff6e 8125a69480
Author: David Capwell <dc...@apache.org>
AuthorDate: Tue Jan 7 17:46:32 2025 -0800

    Merge branch 'cassandra-5.0' into trunk

 CHANGES.txt                                        |  1 +
 .../org/apache/cassandra/db/filter/RowFilter.java  | 29 +++++++++++----------
 .../cql3/validation/operations/SelectTest.java     | 30 ++++++++++++++++++++++
 .../cassandra/index/sai/plan/OperationTest.java    |  2 +-
 .../cassandra/index/sasi/plan/OperationTest.java   |  2 +-
 5 files changed, 49 insertions(+), 15 deletions(-)

diff --cc CHANGES.txt
index 8ef3443886,8eb1fba300..18b0bf3ded
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@@ -136,18 -46,7 +136,19 @@@ Merged from 5.0
   * Prioritize built indexes in IndexStatusManager (CASSANDRA-19400)
   * Add java.base/java.lang.reflect among opens for jvm11-client.options (CASSANDRA-19780)
  Merged from 4.1:
 + * Fix race condition in DecayingEstimatedHistogramReservoir during rescale (CASSANDRA-19365)
  Merged from 4.0:
++ * IndexOutOfBoundsException when accessing partition where the column was deleted (CASSANDRA-20108)
 + * Enhance CQLSSTableWriter to notify clients on sstable production (CASSANDRA-19800)
 + * Change the resolution of AbstractCommitLogService#lastSyncedAt to nanos to be aligned with later comparisons (CASSANDRA-20074)
 + * Support UDTs and vectors as clustering keys in descending order (CASSANDRA-20050)
 + * Fix CQL in snapshot's schema which did not contained UDTs used as reverse clustering columns (CASSANDRA-20036)
 + * Add configurable batchlog endpoint strategies: random_remote, prefer_local, dynamic_remote, and dynamic (CASSANDRA-18120)
 + * Fix bash-completion for debian distro (CASSANDRA-19999)
 + * Ensure thread-safety for CommitLogArchiver in CommitLog (CASSANDRA-19960)
 + * Fix text containing "/*" being interpreted as multiline comment in cqlsh (CASSANDRA-17667)
 + * Fix indexing of a frozen collection that is the clustering key and reversed (CASSANDRA-19889)
 + * Emit error when altering a table with non-frozen UDTs with nested non-frozen collections the same way as done upon table creation (CASSANDRA-19925)
   * Safer handling of out-of-range tokens (CASSANDRA-13704)
   * Fix memory leak in BTree.FastBuilder (CASSANDRA-19785)
   * Fix millisecond and microsecond precision for commit log replay (CASSANDRA-19448)
diff --cc src/java/org/apache/cassandra/db/filter/RowFilter.java
index 066f32a49b,0742f4ee9f..e26888e341
--- a/src/java/org/apache/cassandra/db/filter/RowFilter.java
+++ b/src/java/org/apache/cassandra/db/filter/RowFilter.java
@@@ -690,48 -704,109 +690,49 @@@ public class RowFilter implements Itera
              super(column, operator, value);
          }
  
-         public boolean isSatisfiedBy(TableMetadata metadata, DecoratedKey partitionKey, Row row)
++        @Override
+         public boolean isSatisfiedBy(TableMetadata metadata, DecoratedKey partitionKey, Row row, long nowInSec)
          {
              // We support null conditions for LWT (in ColumnCondition) but not for RowFilter.
              // TODO: we should try to merge both code someday.
              assert value != null;
  
 -            switch (operator)
 +            if (operator.appliesToColumnValues())
              {
 -                case EQ:
 -                case IN:
 -                case LT:
 -                case LTE:
 -                case GTE:
 -                case GT:
 -                    {
 -                        assert !column.isComplex() : "Only CONTAINS and CONTAINS_KEY are supported for collection types";
 -
 -                        // In order to support operators on Counter types, their value has to be extracted from internal
 -                        // representation. See CASSANDRA-11629
 -                        if (column.type.isCounter())
 -                        {
 -                            ByteBuffer foundValue = getValue(metadata, partitionKey, row, nowInSec);
 -                            if (foundValue == null)
 -                                return false;
 -
 -                            ByteBuffer counterValue = LongType.instance.decompose(CounterContext.instance().total(foundValue, ByteBufferAccessor.instance));
 -                            return operator.isSatisfiedBy(LongType.instance, counterValue, value);
 -                        }
 -                        else
 -                        {
 -                            // Note that CQL expression are always of the form 'x < 4', i.e. the tested value is on the left.
 -                            ByteBuffer foundValue = getValue(metadata, partitionKey, row, nowInSec);
 -                            return foundValue != null && operator.isSatisfiedBy(column.type, foundValue, value);
 -                        }
 -                    }
 -                case NEQ:
 -                case LIKE_PREFIX:
 -                case LIKE_SUFFIX:
 -                case LIKE_CONTAINS:
 -                case LIKE_MATCHES:
 -                case ANN:
 -                    {
 -                        assert !column.isComplex() : "Only CONTAINS and CONTAINS_KEY are supported for collection types";
 -                        ByteBuffer foundValue = getValue(metadata, partitionKey, row, nowInSec);
 -                        // Note that CQL expression are always of the form 'x < 4', i.e. the tested value is on the left.
 -                        return foundValue != null && operator.isSatisfiedBy(column.type, foundValue, value);
 -                    }
 -                case CONTAINS:
 -                    assert column.type.isCollection();
 -                    CollectionType<?> type = (CollectionType<?>)column.type;
 -                    if (column.isComplex())
 -                    {
 -                        ComplexColumnData complexData = row.getComplexColumnData(column);
 -                        if (complexData != null)
 -                        {
 -                            for (Cell<?> cell : complexData)
 -                            {
 -                                if (type.kind == CollectionType.Kind.SET)
 -                                {
 -                                    if (type.nameComparator().compare(cell.path().get(0), value) == 0)
 -                                        return true;
 -                                }
 -                                else
 -                                {
 -                                    if (type.valueComparator().compare(cell.buffer(), value) == 0)
 -                                        return true;
 -                                }
 -                            }
 -                        }
 +                assert !column.isComplex() : "Only CONTAINS and CONTAINS_KEY are supported for 'complex' types";
 +
 +                // In order to support operators on Counter types, their value has to be extracted from internal
 +                // representation. See CASSANDRA-11629
 +                if (column.type.isCounter())
 +                {
-                     ByteBuffer foundValue = getValue(metadata, partitionKey, row);
++                    ByteBuffer foundValue = getValue(metadata, partitionKey, row, nowInSec);
 +                    if (foundValue == null)
                          return false;
 -                    }
 -                    else
 -                    {
 -                        ByteBuffer foundValue = getValue(metadata, partitionKey, row, nowInSec);
 -                        if (foundValue == null)
 -                            return false;
 -
 -                        switch (type.kind)
 -                        {
 -                            case LIST:
 -                                ListType<?> listType = (ListType<?>)type;
 -                                return listType.compose(foundValue).contains(listType.getElementsType().compose(value));
 -                            case SET:
 -                                SetType<?> setType = (SetType<?>)type;
 -                                return setType.compose(foundValue).contains(setType.getElementsType().compose(value));
 -                            case MAP:
 -                                MapType<?,?> mapType = (MapType<?, ?>)type;
 -                                return mapType.compose(foundValue).containsValue(mapType.getValuesType().compose(value));
 -                        }
 -                        throw new AssertionError();
 -                    }
 -                case CONTAINS_KEY:
 -                    assert column.type.isCollection() && column.type instanceof MapType;
 -                    MapType<?, ?> mapType = (MapType<?, ?>)column.type;
 -                    if (column.isComplex())
 -                    {
 -                         return row.getCell(column, CellPath.create(value)) != null;
 -                    }
 -                    else
 -                    {
 -                        ByteBuffer foundValue = getValue(metadata, partitionKey, row, nowInSec);
 -                        return foundValue != null && mapType.getSerializer().getSerializedValue(foundValue, value, mapType.getKeysType()) != null;
 -                    }
 +
 +                    ByteBuffer counterValue = LongType.instance.decompose(CounterContext.instance().total(foundValue, ByteBufferAccessor.instance));
 +                    return operator.isSatisfiedBy(LongType.instance, counterValue, value);
 +                }
 +                else
 +                {
 +                    // Note that CQL expression are always of the form 'x < 4', i.e. the tested value is on the left.
-                     ByteBuffer foundValue = getValue(metadata, partitionKey, row);
++                    ByteBuffer foundValue = getValue(metadata, partitionKey, row, nowInSec);
 +                    return foundValue != null && operator.isSatisfiedBy(column.type, foundValue, value);
 +                }
 +            }
 +            else if (operator.appliesToCollectionElements() || operator.appliesToMapKeys())
 +            {
 +                assert column.type.isCollection();
 +                CollectionType<?> type = (CollectionType<?>) column.type;
 +                if (column.isComplex())
 +                {
 +                    ComplexColumnData complexData = row.getComplexColumnData(column);
 +                    return complexData != null && operator.isSatisfiedBy(type, complexData, value);
 +                }
 +                else
 +                {
-                     ByteBuffer foundValue = getValue(metadata, partitionKey, row);
++                    ByteBuffer foundValue = getValue(metadata, partitionKey, row, nowInSec);
 +                    return foundValue != null && operator.isSatisfiedBy(column.type, foundValue, value);
 +                }
              }
              throw new AssertionError();
          }
diff --cc test/unit/org/apache/cassandra/cql3/validation/operations/SelectTest.java
index 5bdff0f831,4c7a7c1c2a..cac9131976
--- a/test/unit/org/apache/cassandra/cql3/validation/operations/SelectTest.java
+++ b/test/unit/org/apache/cassandra/cql3/validation/operations/SelectTest.java
@@@ -2554,6 -2326,36 +2554,36 @@@ public class SelectTest extends CQLTest
          });
      }
  
+     @Test
+     public void filteringOnDeletedStaticColumnValue() throws Throwable
+     {
+         // Create table with int-only columns
+         createTable("CREATE TABLE %s (pk0 int, pk1 int, ck0 int, ck1 int, s0 tinyint static, v0 int, v1 int, PRIMARY KEY ((pk0, pk1), ck0, ck1))");
+ 
+         // Insert rows
+         execute("INSERT INTO %s (pk0, pk1, s0, ck0, ck1, v0, v1) VALUES (?, ?, ?, ?, ?, ?, ?)", 1000, 2000, (byte) 126, 100, 1, 20, 30);
+         execute("INSERT INTO %s (pk0, pk1, s0, ck0, ck1, v0, v1) VALUES (?, ?, ?, ?, ?, ?, ?)", 1000, 2000, (byte) 125, 200, 2, 40, 50);
+         execute("INSERT INTO %s (pk0, pk1, s0, ck0, ck1, v0, v1) VALUES (?, ?, ?, ?, ?, ?, ?)", 1000, 3000, (byte) 122, 300, 3, 60, 70);
+         execute("DELETE s0,v0,v1 FROM %s WHERE pk0=1000 AND pk1=2000 and ck0=100 and ck1=1");
+ 
+         beforeAndAfterFlush(() -> {
+             // Verify the columns are deleted
+             assertRows(execute("SELECT pk0, pk1, s0, ck0, ck1, v0, v1 FROM %s WHERE s0=? ALLOW FILTERING", (byte) 122),
 -                    row(1000, 3000, (byte) 122, 300, 3, 60, 70));
++                       row(1000, 3000, (byte) 122, 300, 3, 60, 70));
+         });
+ 
+         execute("DELETE v0 FROM %s WHERE pk0=1000 AND pk1=3000 AND ck0=300 AND ck1=3");
+ 
+         beforeAndAfterFlush(() -> {
+             assertRows(execute("SELECT pk0, pk1, s0, ck0, ck1, v0, v1 FROM %s WHERE s0=? ALLOW FILTERING", (byte) 122),
 -                    row(1000, 3000, (byte) 122, 300, 3, null, 70));
++                       row(1000, 3000, (byte) 122, 300, 3, null, 70));
+ 
+             assertRows(execute("SELECT pk0, pk1, s0, ck0, ck1, v0, v1 FROM %s WHERE pk0=1000 AND pk1=3000 AND ck0=300 AND ck1=3"),
 -                    row(1000, 3000, (byte) 122, 300, 3, null, 70));
++                       row(1000, 3000, (byte) 122, 300, 3, null, 70));
+         });
+ 
+     }
+ 
      @Test
      public void containsFilteringOnNonClusteringColumn() throws Throwable {
          createTable("CREATE TABLE %s (a int, b int, c int, d list<int>, PRIMARY KEY (a, b, c))");


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