You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by ad...@apache.org on 2021/03/10 17:36:22 UTC

[cassandra] branch cassandra-3.11 updated (4a804eb -> dc82d48)

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

adelapena pushed a change to branch cassandra-3.11
in repository https://gitbox.apache.org/repos/asf/cassandra.git.


    from 4a804eb  Merge branch 'cassandra-3.0' into cassandra-3.11 (including c8d2394, 6524903, cf0be97)
     new 9c7b69e  Fix ColumnFilter::toString not returning a valid CQL fragment
     new dc82d48  Merge branch 'cassandra-3.0' into cassandra-3.11

The 2 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 +
 src/java/org/apache/cassandra/db/ReadCommand.java  |  4 +--
 .../apache/cassandra/db/filter/ColumnFilter.java   | 40 ++++++++++++++++------
 .../cassandra/db/filter/ColumnFilterTest.java      | 40 ++++++++++++++++++++++
 4 files changed, 72 insertions(+), 13 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-3.0' into cassandra-3.11

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

adelapena pushed a commit to branch cassandra-3.11
in repository https://gitbox.apache.org/repos/asf/cassandra.git

commit dc82d481d94e38b41dc3de1a07eb18c77d34ad1e
Merge: 4a804eb 9c7b69e
Author: Andrés de la Peña <a....@gmail.com>
AuthorDate: Wed Mar 10 17:27:03 2021 +0000

    Merge branch 'cassandra-3.0' into cassandra-3.11

 CHANGES.txt                                        |  1 +
 src/java/org/apache/cassandra/db/ReadCommand.java  |  4 +--
 .../apache/cassandra/db/filter/ColumnFilter.java   | 40 ++++++++++++++++------
 .../cassandra/db/filter/ColumnFilterTest.java      | 40 ++++++++++++++++++++++
 4 files changed, 72 insertions(+), 13 deletions(-)

diff --cc CHANGES.txt
index 3b4b8fd,25f938b..b959a43
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@@ -1,6 -1,5 +1,7 @@@
 -3.0.25:
 +3.11.11
 + * Upgrade jackson-databind to 2.9.10.8 (CASSANDRA-16462)
 +Merged from 3.0:
+  * Fix ColumnFilter::toString not returning a valid CQL fragment (CASSANDRA-16483)
   * Fix ColumnFilter behaviour to prevent digest mitmatches during upgrades (CASSANDRA-16415)
   * Avoid pushing schema mutations when setting up distributed system keyspaces locally (CASSANDRA-16387)
  Merged from 2.2:
diff --cc src/java/org/apache/cassandra/db/filter/ColumnFilter.java
index f405431,cbc8871..dfbce4a
--- a/src/java/org/apache/cassandra/db/filter/ColumnFilter.java
+++ b/src/java/org/apache/cassandra/db/filter/ColumnFilter.java
@@@ -405,29 -306,43 +405,47 @@@ public class ColumnFilte
      @Override
      public String toString()
      {
-         String prefix = "";
 -        if (isFetchAll)
 +        if (isFetchAll && queried == null)
              return "*/*";
  
++        String prefix = "";
 +        if (isFetchAll)
 +            prefix = "*/";
 +
          if (queried.isEmpty())
 -            return "[]";
 +            return prefix + "[]";
  
-         StringJoiner joiner = new StringJoiner(", ", "[", "]");
-         Iterator<ColumnDefinition> it = queried.selectOrderIterator();
-         while (it.hasNext())
 -        return toString(false);
++        return prefix + toString(false);
+     }
+ 
+     public String toCQLString()
+     {
+         if (queried == null || queried.isEmpty())
+             return "*";
+ 
+         return toString(true);
+     }
+ 
+     private String toString(boolean cql)
+     {
+         Iterator<ColumnDefinition> columns = queried.selectOrderIterator();
+         StringJoiner joiner = cql ? new StringJoiner(", ") : new StringJoiner(", ", "[", "]");
+ 
+         while (columns.hasNext())
          {
-             ColumnDefinition column = it.next();
-             SortedSet<ColumnSubselection> s = subSelections != null ? subSelections.get(column.name) : Collections.emptySortedSet();
+             ColumnDefinition column = columns.next();
+             String columnName = cql ? column.name.toCQLString() : String.valueOf(column.name);
+ 
+             SortedSet<ColumnSubselection> s = subSelections != null
+                                             ? subSelections.get(column.name)
+                                             : Collections.emptySortedSet();
  
              if (s.isEmpty())
-                 joiner.add(String.valueOf(column.name));
+                 joiner.add(columnName);
              else
-                 s.forEach(subSel -> joiner.add(String.format("%s%s", column.name , subSel)));
+                 s.forEach(subSel -> joiner.add(String.format("%s%s", columnName, subSel)));
          }
-         return prefix + joiner.toString();
+         return joiner.toString();
      }
  
      public static class Serializer
diff --cc test/unit/org/apache/cassandra/db/filter/ColumnFilterTest.java
index 1ddf039,7977c6b..adf074f
--- a/test/unit/org/apache/cassandra/db/filter/ColumnFilterTest.java
+++ b/test/unit/org/apache/cassandra/db/filter/ColumnFilterTest.java
@@@ -33,7 -27,7 +33,8 @@@ import org.junit.runners.Parameterized
  
  import org.apache.cassandra.config.CFMetaData;
  import org.apache.cassandra.config.ColumnDefinition;
 +import org.apache.cassandra.config.DatabaseDescriptor;
+ import org.apache.cassandra.cql3.ColumnIdentifier;
  import org.apache.cassandra.db.PartitionColumns;
  import org.apache.cassandra.db.marshal.Int32Type;
  import org.apache.cassandra.db.marshal.SetType;
@@@ -287,20 -289,12 +319,22 @@@ public class ColumnFilterTes
          Consumer<ColumnFilter> check = filter -> {
              testRoundTrips(filter);
              assertFetchedQueried(true, true, filter, v1);
 -
 -            assertEquals("*/*", filter.toString());
 -            assertEquals("v1", filter.toCQLString());
 -            assertFetchedQueried(true, true, filter, s1, s2, v2);
 -            assertCellFetchedQueried(true, true, filter, v2, path0, path1, path2, path3, path4);
 -            assertCellFetchedQueried(true, true, filter, s2, path0, path1, path2, path3, path4);
 +            if (anyNodeOn30)
 +            {
 +                assertEquals("*/*", filter.toString());
++                assertEquals("*", filter.toCQLString());
 +                assertFetchedQueried(true, true, filter, s1, s2, v2);
 +                assertCellFetchedQueried(true, true, filter, v2, path0, path1, path2, path3, path4);
 +                assertCellFetchedQueried(true, true, filter, s2, path0, path1, path2, path3, path4);
 +            }
 +            else
 +            {
 +                assertEquals("*/[v1]", filter.toString());
++                assertEquals("v1", filter.toCQLString());
 +                assertFetchedQueried(true, false, filter, s1, s2, v2);
 +                assertCellFetchedQueried(true, false, filter, v2, path0, path1, path2, path3, path4);
 +                assertCellFetchedQueried(true, false, filter, s2, path0, path1, path2, path3, path4);
 +            }
          };
  
          check.accept(ColumnFilter.selection(metadata, PartitionColumns.builder().add(v1).build()));
@@@ -313,20 -307,12 +347,22 @@@
          Consumer<ColumnFilter> check = filter -> {
              testRoundTrips(filter);
              assertFetchedQueried(true, true, filter, s1);
 -
 -            assertEquals("*/*", filter.toString());
 -            assertEquals("s1", filter.toCQLString());
 -            assertFetchedQueried(true, true, filter, v1, v2, s2);
 -            assertCellFetchedQueried(true, true, filter, v2, path0, path1, path2, path3, path4);
 -            assertCellFetchedQueried(true, true, filter, s2, path0, path1, path2, path3, path4);
 +            if (anyNodeOn30)
 +            {
 +                assertEquals("*/*", filter.toString());
++                assertEquals("*", filter.toCQLString());
 +                assertFetchedQueried(true, true, filter, v1, v2, s2);
 +                assertCellFetchedQueried(true, true, filter, v2, path0, path1, path2, path3, path4);
 +                assertCellFetchedQueried(true, true, filter, s2, path0, path1, path2, path3, path4);
 +            }
 +            else
 +            {
 +                assertEquals("*/[s1]", filter.toString());
++                assertEquals("s1", filter.toCQLString());
 +                assertFetchedQueried(true, false, filter, v1, v2, s2);
 +                assertCellFetchedQueried(true, false, filter, v2, path0, path1, path2, path3, path4);
 +                assertCellFetchedQueried(false, false, filter, s2, path0, path1, path2, path3, path4);
 +            }
          };
  
          check.accept(ColumnFilter.selection(metadata, PartitionColumns.builder().add(s1).build()));
@@@ -339,22 -325,13 +375,24 @@@
          ColumnFilter filter = ColumnFilter.allColumnsBuilder(metadata).select(v2, path1).build();
          testRoundTrips(filter);
          assertFetchedQueried(true, true, filter, v2);
 -
 -        assertEquals("*/*", filter.toString());
 -        assertEquals("v2[1]", filter.toCQLString());
 -        assertFetchedQueried(true, true, filter, s1, s2, v1);
 -        assertCellFetchedQueried(true, true, filter, v2, path1);
 -        assertCellFetchedQueried(true, false, filter, v2, path0, path2, path3, path4);
 -        assertCellFetchedQueried(true, true, filter, s2, path0, path1, path2, path3, path4);
 +        if (anyNodeOn30)
 +        {
 +            assertEquals("*/*", filter.toString());
++            assertEquals("*", filter.toCQLString());
 +            assertFetchedQueried(true, true, filter, s1, s2, v1);
 +            assertCellFetchedQueried(true, true, filter, v2, path1);
 +            assertCellFetchedQueried(true, false, filter, v2, path0, path2, path3, path4);
 +            assertCellFetchedQueried(true, true, filter, s2, path0, path1, path2, path3, path4);
 +        }
 +        else
 +        {
 +            assertEquals("*/[v2[1]]", filter.toString());
++            assertEquals("v2[1]", filter.toCQLString());
 +            assertFetchedQueried(true, false, filter, s1, s2, v1);
 +            assertCellFetchedQueried(true, true, filter, v2, path1);
 +            assertCellFetchedQueried(true, false, filter, v2, path0, path2, path3, path4);
 +            assertCellFetchedQueried(true, false, filter, s2, path0, path1, path2, path3, path4);
 +        }
      }
  
      @Test
@@@ -363,22 -340,13 +401,24 @@@
          ColumnFilter filter = ColumnFilter.allColumnsBuilder(metadata).select(s2, path1).build();
          testRoundTrips(filter);
          assertFetchedQueried(true, true, filter, s2);
 -
 -        assertEquals("*/*", filter.toString());
 -        assertEquals("s2[1]", filter.toCQLString());
 -        assertFetchedQueried(true, true, filter, v1, v2, s1);
 -        assertCellFetchedQueried(true, true, filter, v2, path0, path1, path2, path3, path4);
 -        assertCellFetchedQueried(true, true, filter, s2, path1);
 -        assertCellFetchedQueried(true, false, filter, s2, path0, path2, path3, path4);
 +        if (anyNodeOn30)
 +        {
 +            assertEquals("*/*", filter.toString());
++            assertEquals("*", filter.toCQLString());
 +            assertFetchedQueried(true, true, filter, v1, v2, s1);
 +            assertCellFetchedQueried(true, true, filter, v2, path0, path1, path2, path3, path4);
 +            assertCellFetchedQueried(true, true, filter, s2, path1);
 +            assertCellFetchedQueried(true, false, filter, s2, path0, path2, path3, path4);
 +        }
 +        else
 +        {
 +            assertEquals("*/[s2[1]]", filter.toString());
++            assertEquals("s2[1]", filter.toCQLString());
 +            assertFetchedQueried(true, false, filter, v1, v2, s1);
 +            assertCellFetchedQueried(true, false, filter, v2, path0, path1, path2, path3, path4);
 +            assertCellFetchedQueried(true, true, filter, s2, path1);
 +            assertCellFetchedQueried(true, false, filter, s2, path0, path2, path3, path4);
 +        }
      }
  
      private void testRoundTrips(ColumnFilter cf)


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