Updated Branches: refs/heads/trunk 0ada18462 -> ae91d17d3
merge from 1.1 Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/ae91d17d Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/ae91d17d Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/ae91d17d Branch: refs/heads/trunk Commit: ae91d17d397ba2b5952c74b4f975dea9c3b72f32 Parents: 0ada184 a4c397b Author: Pavel Yaskevich <xe...@apache.org> Authored: Thu Sep 20 16:57:21 2012 +0300 Committer: Pavel Yaskevich <xe...@apache.org> Committed: Thu Sep 20 16:57:21 2012 +0300 ---------------------------------------------------------------------- CHANGES.txt | 1 + .../cassandra/cql3/statements/SelectStatement.java | 15 ++++++++------- 2 files changed, 9 insertions(+), 7 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cassandra/blob/ae91d17d/CHANGES.txt ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cassandra/blob/ae91d17d/src/java/org/apache/cassandra/cql3/statements/SelectStatement.java ---------------------------------------------------------------------- diff --cc src/java/org/apache/cassandra/cql3/statements/SelectStatement.java index 26086ad,4a013b1..4ae9e75 --- a/src/java/org/apache/cassandra/cql3/statements/SelectStatement.java +++ b/src/java/org/apache/cassandra/cql3/statements/SelectStatement.java @@@ -804,21 -819,22 +804,22 @@@ public class SelectStatement implement /** * Orders results when multiple keys are selected (using IN) */ - private void orderResults(ResultSet cqlRows) - private void orderResults(List<Pair<CFDefinition.Name, Selector>> selection, List<CqlRow> cqlRows) ++ private void orderResults(List<Pair<CFDefinition.Name, Selector>> selection, 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) + // c. key restriction is a Range or not an IN expression + if (cqlRows.size() == 0 || parameters.orderings.isEmpty() || isKeyRange || !keyIsInRelation) return; + // optimization when only *one* order condition was given // because there is no point of using composite comparator if there is only one order condition if (parameters.orderings.size() == 1) { CFDefinition.Name ordering = cfDef.get(parameters.orderings.keySet().iterator().next()); - Collections.sort(cqlRows.rows, new SingleColumnComparator(getColumnPositionInSelect(ordering), ordering.type)); - Collections.sort(cqlRows, new SingleColumnComparator(getColumnPositionInSelect(selection, ordering), ordering.type)); ++ Collections.sort(cqlRows.rows, new SingleColumnComparator(getColumnPositionInSelect(selection, ordering), ordering.type)); return; } @@@ -833,10 -849,10 +834,10 @@@ { CFDefinition.Name orderingColumn = cfDef.get(identifier); types.add(orderingColumn.type); - positions[idx++] = getColumnPositionInSelect(orderingColumn); + positions[idx++] = getColumnPositionInSelect(selection, orderingColumn); } - Collections.sort(cqlRows, new CompositeComparator(types, positions)); + Collections.sort(cqlRows.rows, new CompositeComparator(types, positions)); } // determine position of column in the select clause