From 3fad738c13c12f0be3cf4e453b559427e7f420d9 Mon Sep 17 00:00:00 2001 From: "Brian S. O'Neill" Date: Fri, 9 May 2008 03:36:30 +0000 Subject: Clustered index selection fixes. --- src/main/java/com/amazon/carbonado/info/StorableIndex.java | 1 + src/main/java/com/amazon/carbonado/qe/IndexedQueryExecutor.java | 2 +- src/main/java/com/amazon/carbonado/qe/OrderingScore.java | 6 +++++- .../java/com/amazon/carbonado/repo/indexed/IndexedStorage.java | 7 +++---- 4 files changed, 10 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/main/java/com/amazon/carbonado/info/StorableIndex.java b/src/main/java/com/amazon/carbonado/info/StorableIndex.java index 9806c61..387e9cf 100644 --- a/src/main/java/com/amazon/carbonado/info/StorableIndex.java +++ b/src/main/java/com/amazon/carbonado/info/StorableIndex.java @@ -603,6 +603,7 @@ public class StorableIndex implements Appender { if (obj instanceof StorableIndex) { StorableIndex other = (StorableIndex) obj; return isUnique() == other.isUnique() + && isClustered() == other.isClustered() && Arrays.equals(mProperties, other.mProperties) && Arrays.equals(mDirections, other.mDirections); } diff --git a/src/main/java/com/amazon/carbonado/qe/IndexedQueryExecutor.java b/src/main/java/com/amazon/carbonado/qe/IndexedQueryExecutor.java index 0599b00..8954ed6 100644 --- a/src/main/java/com/amazon/carbonado/qe/IndexedQueryExecutor.java +++ b/src/main/java/com/amazon/carbonado/qe/IndexedQueryExecutor.java @@ -310,7 +310,7 @@ public class IndexedQueryExecutor extends AbstractQueryExecu indent(app, indentLevel); app.append("...covering filter: "); mCoveringFilter.appendTo(app, values); - + newline(app); } return true; } diff --git a/src/main/java/com/amazon/carbonado/qe/OrderingScore.java b/src/main/java/com/amazon/carbonado/qe/OrderingScore.java index 9bfcde1..32f6936 100644 --- a/src/main/java/com/amazon/carbonado/qe/OrderingScore.java +++ b/src/main/java/com/amazon/carbonado/qe/OrderingScore.java @@ -526,7 +526,11 @@ public class OrderingScore { // Choose index with any handled properties over the one with // neither handled nor remainder properties. if (Double.isNaN(firstRatio)) { - if (!Double.isNaN(otherRatio)) { + if (Double.isNaN(otherRatio)) { + // Order checks are not really applicable. The query does + // not have an ordering applied to it. + return 0; + } else { return 1; } } else if (Double.isNaN(otherRatio)) { diff --git a/src/main/java/com/amazon/carbonado/repo/indexed/IndexedStorage.java b/src/main/java/com/amazon/carbonado/repo/indexed/IndexedStorage.java index 6409da7..9ff204f 100644 --- a/src/main/java/com/amazon/carbonado/repo/indexed/IndexedStorage.java +++ b/src/main/java/com/amazon/carbonado/repo/indexed/IndexedStorage.java @@ -99,6 +99,9 @@ class IndexedStorage implements Storage, StorageAccess { desiredIndexSet = IndexAnalysis.gatherDesiredIndexes(info); desiredIndexSet.reduce(Direction.ASCENDING); + if (mRepository.isAllClustered()) { + desiredIndexSet.markClustered(true); + } } // The set of indexes that are populated and available for use. This is @@ -225,10 +228,6 @@ class IndexedStorage implements Storage, StorageAccess // Add the indexes we get for free. queryableIndexSet.addAll(freeIndexSet); - - if (mRepository.isAllClustered()) { - queryableIndexSet.markClustered(true); - } } // The set of indexes that should be kept up-to-date. If index repair -- cgit v1.2.3