changes required for CASSANDRA-4327 with 1.2 changes to CQL3
Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/df8f823e Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/df8f823e Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/df8f823e Branch: refs/heads/trunk Commit: df8f823ef4c73920f2b52085c5235e214bfa3bf8 Parents: 2ff33ab Author: Pavel Yaskevich <[email protected]> Authored: Sat Jul 7 02:34:13 2012 +0300 Committer: Pavel Yaskevich <[email protected]> Committed: Sat Jul 7 02:36:32 2012 +0300 ---------------------------------------------------------------------- .../cassandra/cql3/statements/SelectStatement.java | 26 ++++++--------- src/java/org/apache/cassandra/db/SystemTable.java | 2 +- 2 files changed, 11 insertions(+), 17 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cassandra/blob/df8f823e/src/java/org/apache/cassandra/cql3/statements/SelectStatement.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/cassandra/cql3/statements/SelectStatement.java b/src/java/org/apache/cassandra/cql3/statements/SelectStatement.java index a0eb325..c74b08f 100644 --- a/src/java/org/apache/cassandra/cql3/statements/SelectStatement.java +++ b/src/java/org/apache/cassandra/cql3/statements/SelectStatement.java @@ -770,13 +770,13 @@ public class SelectStatement implements CQLStatement /** * Orders results when multiple keys are selected (using IN) */ - private void orderResults(List<CqlRow> cqlRows) + private void orderResults(ResultSet cqlRows) { // There is nothing to do if // a. there are no results, // b. no ordering information where given, // c. key restriction wasn't given or it's not an IN expression - if (cqlRows.isEmpty() || parameters.orderings.isEmpty() || keyRestriction == null || keyRestriction.eqValues.size() < 2) + if (cqlRows.size() == 0 || parameters.orderings.isEmpty() || keyRestriction == null || keyRestriction.eqValues.size() < 2) return; // optimization when only *one* order condition was given @@ -784,7 +784,7 @@ public class SelectStatement implements CQLStatement if (parameters.orderings.size() == 1) { CFDefinition.Name ordering = cfDef.get(parameters.orderings.keySet().iterator().next()); - Collections.sort(cqlRows, new SingleColumnComparator(ordering.position + 1, ordering.type)); + Collections.sort(cqlRows.rows, new SingleColumnComparator(ordering.position + 1, ordering.type)); return; } @@ -805,7 +805,7 @@ public class SelectStatement implements CQLStatement types.add(orderingColumn.type); } - Collections.sort(cqlRows, new CompositeComparator(startPosition, types)); + Collections.sort(cqlRows.rows, new CompositeComparator(startPosition, types)); } @@ -1260,7 +1260,7 @@ public class SelectStatement implements CQLStatement /** * Used in orderResults(...) method when single 'ORDER BY' condition where given */ - private static class SingleColumnComparator implements Comparator<CqlRow> + private static class SingleColumnComparator implements Comparator<List<ByteBuffer>> { private final int index; private final AbstractType<?> comparator; @@ -1271,19 +1271,16 @@ public class SelectStatement implements CQLStatement comparator = orderer; } - public int compare(CqlRow a, CqlRow b) + public int compare(List<ByteBuffer> a, List<ByteBuffer> b) { - Column columnA = a.getColumns().get(index); - Column columnB = b.getColumns().get(index); - - return comparator.compare(columnA.bufferForValue(), columnB.bufferForValue()); + return comparator.compare(a.get(index), b.get(index)); } } /** * Used in orderResults(...) method when multiple 'ORDER BY' conditions where given */ - private static class CompositeComparator implements Comparator<CqlRow> + private static class CompositeComparator implements Comparator<List<ByteBuffer>> { private final int startColumnIndex; private final List<AbstractType<?>> orderings; @@ -1294,16 +1291,13 @@ public class SelectStatement implements CQLStatement orderings = orderComparators; } - public int compare(CqlRow a, CqlRow b) + public int compare(List<ByteBuffer> a, List<ByteBuffer> b) { int currentIndex = startColumnIndex; for (AbstractType<?> comparator : orderings) { - ByteBuffer aValue = a.getColumns().get(currentIndex).bufferForValue(); - ByteBuffer bValue = b.getColumns().get(currentIndex).bufferForValue(); - - int comparison = comparator.compare(aValue, bValue); + int comparison = comparator.compare(a.get(currentIndex), b.get(currentIndex)); if (comparison != 0) return comparison; http://git-wip-us.apache.org/repos/asf/cassandra/blob/df8f823e/src/java/org/apache/cassandra/db/SystemTable.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/cassandra/db/SystemTable.java b/src/java/org/apache/cassandra/db/SystemTable.java index 44b3bb2..77e064f 100644 --- a/src/java/org/apache/cassandra/db/SystemTable.java +++ b/src/java/org/apache/cassandra/db/SystemTable.java @@ -124,7 +124,7 @@ public class SystemTable String clusterName = ByteBufferUtil.string(oldColumns.next().value()); String tokenBytes = ByteBufferUtil.bytesToHex(oldColumns.next().value()); // (assume that any node getting upgraded was bootstrapped, since that was stored in a separate row for no particular reason) - String req = "INSERT INTO system.%s (key, cluster_name, token_bytes, bootstrapped) VALUES ('%s', '%s', '%s', true)"; + String req = "INSERT INTO system.%s (key, cluster_name, token_bytes, bootstrapped) VALUES ('%s', '%s', '%s', 'true')"; processInternal(String.format(req, LOCAL_CF, LOCAL_KEY, clusterName, tokenBytes)); oldStatusCfs.truncate();
