Skip to content

Commit ae827cd

Browse files
committed
CNDB-15280: Address review feedback on fixing AbstractReadQuery.toCQLString
1 parent cb73a96 commit ae827cd

File tree

8 files changed

+23
-23
lines changed

8 files changed

+23
-23
lines changed

src/java/org/apache/cassandra/db/Clustering.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public default Clustering<?> clone(ByteBufferCloner cloner)
4949
ByteBuffer[] newValues = new ByteBuffer[size()];
5050
for (int i = 0; i < size(); i++)
5151
{
52-
ByteBuffer val = accessor().toBuffer(get(i));
52+
ByteBuffer val = bufferAt(i);
5353
newValues[i] = val == null ? null : cloner.clone(val);
5454
}
5555
return new BufferClustering(newValues);
@@ -84,7 +84,7 @@ public default String toCQLString(TableMetadata metadata)
8484
for (int i = 0; i < size(); i++)
8585
{
8686
ColumnMetadata c = metadata.clusteringColumns().get(i);
87-
ByteBuffer value = accessor().toBuffer(get(i));
87+
ByteBuffer value = bufferAt(i);
8888
sb.append(i == 0 ? "" : ", ").append(c.type.toCQLString(value));
8989
}
9090
return sb.toString();

src/java/org/apache/cassandra/db/ClusteringPrefix.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -358,11 +358,11 @@ default int dataSize()
358358
default ByteBuffer serializeAsPartitionKey()
359359
{
360360
if (size() == 1)
361-
return accessor().toBuffer(get(0));
361+
return bufferAt(0);
362362

363363
ByteBuffer[] values = new ByteBuffer[size()];
364364
for (int i = 0; i < size(); i++)
365-
values[i] = accessor().toBuffer(get(i));
365+
values[i] = bufferAt(i);
366366
return CompositeType.build(ByteBufferAccessor.instance, values);
367367
}
368368

@@ -752,4 +752,4 @@ public static boolean equals(ClusteringPrefix<?> prefix, Object o)
752752
return equals(prefix, (ClusteringPrefix<?>) o);
753753
}
754754

755-
}
755+
}

src/java/org/apache/cassandra/db/MultiPartitionReadQuery.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ private boolean appendRanges(CqlBuilder builder)
5656
{
5757
List<DataRange> ranges = ranges();
5858
boolean hasRangeRestrictions = false;
59-
if (ranges().size() == 1)
59+
if (ranges.size() == 1)
6060
{
6161
String rangeString = ranges.get(0).toCQLString(metadata());
6262
if (!rangeString.isEmpty())

src/java/org/apache/cassandra/db/Slices.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -611,7 +611,7 @@ public String toCQLString(TableMetadata metadata, RowFilter rowFilter)
611611
if (values.size() == 1)
612612
{
613613
sb.append(" = ").append(column.type.toCQLString(first.startValue));
614-
rowFilter = rowFilter.without(column, Operator.EQ, first.startValue);
614+
rowFilter = rowFilter.withoutFirstLevelExpression(column, Operator.EQ, first.startValue);
615615
}
616616
else
617617
{
@@ -620,7 +620,7 @@ public String toCQLString(TableMetadata metadata, RowFilter rowFilter)
620620
for (ByteBuffer value : values)
621621
{
622622
sb.append(j++ == 0 ? "" : ", ").append(column.type.toCQLString(value));
623-
rowFilter = rowFilter.without(column, Operator.EQ, value);
623+
rowFilter = rowFilter.withoutFirstLevelExpression(column, Operator.EQ, value);
624624
}
625625
sb.append(')');
626626
}
@@ -644,7 +644,7 @@ public String toCQLString(TableMetadata metadata, RowFilter rowFilter)
644644
operator = first.startInclusive ? Operator.GTE : Operator.GT;
645645
sb.append(' ').append(operator).append(' ')
646646
.append(column.type.toCQLString(first.startValue));
647-
rowFilter = rowFilter.without(column, operator, first.startValue);
647+
rowFilter = rowFilter.withoutFirstLevelExpression(column, operator, first.startValue);
648648
}
649649
if (first.endValue != null)
650650
{
@@ -658,11 +658,11 @@ public String toCQLString(TableMetadata metadata, RowFilter rowFilter)
658658
operator = first.endInclusive ? Operator.LTE : Operator.LT;
659659
sb.append(' ').append(operator).append(' ')
660660
.append(column.type.toCQLString(first.endValue));
661-
rowFilter = rowFilter.without(column, operator, first.endValue);
661+
rowFilter = rowFilter.withoutFirstLevelExpression(column, operator, first.endValue);
662662
}
663663
}
664664
}
665-
rowFilter = rowFilter.without(metadata.clusteringColumns().get(0), Operator.IN);
665+
rowFilter = rowFilter.withoutFirstLevelExpression(metadata.clusteringColumns().get(0), Operator.IN);
666666

667667
// Append the row filter.
668668
if (!rowFilter.isEmpty())

src/java/org/apache/cassandra/db/filter/AbstractClusteringIndexFilter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@
1919

2020
import java.io.IOException;
2121

22-
import org.apache.cassandra.db.marshal.ReversedType;
2322
import org.apache.cassandra.schema.ColumnMetadata;
2423
import org.apache.cassandra.schema.TableMetadata;
2524
import org.apache.cassandra.db.*;
25+
import org.apache.cassandra.db.marshal.ReversedType;
2626
import org.apache.cassandra.io.util.DataInputPlus;
2727
import org.apache.cassandra.io.util.DataOutputPlus;
2828

src/java/org/apache/cassandra/db/filter/ClusteringIndexNamesFilter.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,10 +186,10 @@ public String toCQLString(TableMetadata metadata, RowFilter rowFilter)
186186
.append(isSingleColumn ? "" : ')');
187187

188188
for (int j = 0; j < clustering.size(); j++)
189-
rowFilter = rowFilter.without(metadata.clusteringColumns().get(j), Operator.EQ, clustering.bufferAt(j));
189+
rowFilter = rowFilter.withoutFirstLevelExpression(metadata.clusteringColumns().get(j), Operator.EQ, clustering.bufferAt(j));
190190
}
191191
sb.append(isSingleClustering ? "" : ")");
192-
rowFilter = rowFilter.without(metadata.clusteringColumns().get(0), Operator.IN);
192+
rowFilter = rowFilter.withoutFirstLevelExpression(metadata.clusteringColumns().get(0), Operator.IN);
193193

194194
if (!rowFilter.isEmpty())
195195
{

src/java/org/apache/cassandra/db/filter/RowFilter.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -285,8 +285,8 @@ public boolean clusteringKeyRestrictionsAreSatisfiedBy(Clustering<?> clustering)
285285
}
286286

287287
/**
288-
* Returns this filter but without the provided expression. This method
289-
* *assumes* that the filter contains the provided expression.
288+
* Returns this filter but without the provided expression. This method *assumes* that the filter contains the
289+
* provided expression, and it looks in all the levels of the filter tree.
290290
*/
291291
public RowFilter without(Expression expression)
292292
{
@@ -298,19 +298,19 @@ public RowFilter without(Expression expression)
298298
}
299299

300300
/**
301-
* Returns a copy of this filter but without the provided first level expressions.
302-
* If this filter doesn't contain the specified expression this method will just return an identical copy of this filter.
301+
* Returns a copy of this filter but without first level expressions with the provided column, operator and value.
302+
* If this filter doesn't contain the specified expressions this method will just return an identical copy of this filter.
303303
*/
304-
public RowFilter without(ColumnMetadata column, Operator op, ByteBuffer value)
304+
public RowFilter withoutFirstLevelExpression(ColumnMetadata column, Operator op, ByteBuffer value)
305305
{
306306
return restrictFirstLevel(e -> !(e.column.equals(column) && e.operator == op && e.value.equals(value)));
307307
}
308308

309309
/**
310-
* Returns a copy of this filter but without the provided first level expressions.
311-
* If this filter doesn't contain the specified expression this method will just return an identical copy of this filter.
310+
* Returns a copy of this filter but without first level expressions with the provided column and operator.
311+
* If this filter doesn't contain the specified expressions this method will just return an identical copy of this filter.
312312
*/
313-
public RowFilter without(ColumnMetadata column, Operator op)
313+
public RowFilter withoutFirstLevelExpression(ColumnMetadata column, Operator op)
314314
{
315315
return restrictFirstLevel(e -> !(e.column.equals(column) && e.operator == op));
316316
}

src/java/org/apache/cassandra/schema/ColumnMetadata.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -594,7 +594,7 @@ public static String toCQLString(Iterator<ColumnMetadata> defs)
594594
StringBuilder sb = new StringBuilder();
595595
sb.append(defs.next().name.toCQLString());
596596
while (defs.hasNext())
597-
sb.append(", ").append(defs.next().name);
597+
sb.append(", ").append(defs.next().name.toCQLString());
598598
return sb.toString();
599599
}
600600

0 commit comments

Comments
 (0)