summaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
authorBrian S. O'Neill <bronee@gmail.com>2007-04-02 14:15:27 +0000
committerBrian S. O'Neill <bronee@gmail.com>2007-04-02 14:15:27 +0000
commit44d92c8a53c286f288bc0d97b706f44ef8aa1068 (patch)
treebfe5bca8dfd9d7afbf8509292348f30fa7bf8bc3 /src/main
parent641a7812d439daca3045e7471b604beb807c1891 (diff)
Weak matches changed to extra matches.
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/com/amazon/carbonado/qe/FilteringScore.java83
1 files changed, 44 insertions, 39 deletions
diff --git a/src/main/java/com/amazon/carbonado/qe/FilteringScore.java b/src/main/java/com/amazon/carbonado/qe/FilteringScore.java
index 1af294c..5ea6009 100644
--- a/src/main/java/com/amazon/carbonado/qe/FilteringScore.java
+++ b/src/main/java/com/amazon/carbonado/qe/FilteringScore.java
@@ -206,17 +206,23 @@ public class FilteringScore<S extends Storable> {
indexProperties[indexPropPos].getDirection() == Direction.DESCENDING;
}
- List<PropertyFilter<S>> weakMatchFilters = null;
- if (!filterList.isEmpty()) {
- // Any remainder property which is provided by the index is a weak match.
+ List<PropertyFilter<S>> extraMatchFilters = null;
+
+ boolean checkForExtraMatches = !filterList.isEmpty()
+ && (identityFilters.size() > 0
+ || rangeStartFilters.size() > 0
+ || rangeEndFilters.size() > 0);
+
+ if (checkForExtraMatches) {
+ // Any remainder property which is provided by the index is an extra match.
for (PropertyFilter<S> subFilter : filterList) {
ChainedProperty<S> filterProp = subFilter.getChainedProperty();
for (OrderedProperty<S> indexProp : indexProperties) {
if (indexProp.getChainedProperty().equals(filterProp)) {
- if (weakMatchFilters == null) {
- weakMatchFilters = new ArrayList<PropertyFilter<S>>();
+ if (extraMatchFilters == null) {
+ extraMatchFilters = new ArrayList<PropertyFilter<S>>();
}
- weakMatchFilters.add(subFilter);
+ extraMatchFilters.add(subFilter);
}
}
}
@@ -231,7 +237,7 @@ public class FilteringScore<S extends Storable> {
arrangementScore,
preferenceScore,
filterList,
- weakMatchFilters,
+ extraMatchFilters,
shouldReverseRange);
}
@@ -292,14 +298,14 @@ public class FilteringScore<S extends Storable> {
private final BigInteger mPreferenceScore;
private final List<PropertyFilter<S>> mRemainderFilters;
- private final List<PropertyFilter<S>> mWeakMatchFilters;
+ private final List<PropertyFilter<S>> mExtraMatchFilters;
private final boolean mShouldReverseRange;
private transient Filter<S> mIdentityFilter;
private transient Filter<S> mRemainderFilter;
- private transient Filter<S> mWeakMatchFilter;
- private transient Filter<S> mWeakMatchRemainderFilter;
+ private transient Filter<S> mExtraMatchFilter;
+ private transient Filter<S> mExtraMatchRemainderFilter;
private FilteringScore(boolean indexClustered,
boolean indexUnique,
@@ -310,7 +316,7 @@ public class FilteringScore<S extends Storable> {
int arrangementScore,
BigInteger preferenceScore,
List<PropertyFilter<S>> remainderFilters,
- List<PropertyFilter<S>> weakMatchFilters,
+ List<PropertyFilter<S>> extraMatchFilters,
boolean shouldReverseRange)
{
mIndexClustered = indexClustered;
@@ -322,7 +328,7 @@ public class FilteringScore<S extends Storable> {
mArrangementScore = arrangementScore;
mPreferenceScore = preferenceScore;
mRemainderFilters = prepareList(remainderFilters);
- mWeakMatchFilters = prepareList(weakMatchFilters);
+ mExtraMatchFilters = prepareList(extraMatchFilters);
mShouldReverseRange = shouldReverseRange;
}
@@ -541,45 +547,46 @@ public class FilteringScore<S extends Storable> {
}
/**
- * Returns number of property filters which are weakly supported by the
- * evaluated index. This count is no more than the remainder count.
+ * Returns number of extra property filters which are supported by the
+ * evaluated index. This count is no more than the remainder count. If
+ * hasAnyMatches returns false, then the extra match count is zero.
*/
- public int getWeakMatchCount() {
- return mWeakMatchFilters.size();
+ public int getExtraMatchCount() {
+ return mExtraMatchFilters.size();
}
/**
- * Returns the filters which are weakly supported by the evaluated index,
+ * Returns the extra filters which are supported by the evaluated index,
* which is a subset of the remainder filters.
*/
- public List<PropertyFilter<S>> getWeakMatchFilters() {
- return mWeakMatchFilters;
+ public List<PropertyFilter<S>> getExtraMatchFilters() {
+ return mExtraMatchFilters;
}
/**
- * Returns the composite weak match filter supported by the evaluated
- * index, or null if no weak match.
+ * Returns the composite extra match filter supported by the evaluated
+ * index, or null if no extra match.
*/
- public Filter<S> getWeakMatchFilter() {
- if (mWeakMatchFilter == null) {
- mWeakMatchFilter = buildCompositeFilter(getWeakMatchFilters());
+ public Filter<S> getExtraMatchFilter() {
+ if (mExtraMatchFilter == null) {
+ mExtraMatchFilter = buildCompositeFilter(getExtraMatchFilters());
}
- return mWeakMatchFilter;
+ return mExtraMatchFilter;
}
/**
- * Returns the composite remainder filter without including the weak match
+ * Returns the composite remainder filter without including the extra match
* filter. Returns null if no remainder.
*/
- public Filter<S> getWeakMatchRemainderFilter() {
- if (mWeakMatchRemainderFilter == null) {
+ public Filter<S> getExtraMatchRemainderFilter() {
+ if (mExtraMatchRemainderFilter == null) {
List<PropertyFilter<S>> remainderFilters = mRemainderFilters;
- List<PropertyFilter<S>> weakMatchFilters = mWeakMatchFilters;
- if (weakMatchFilters.size() < remainderFilters.size()) {
+ List<PropertyFilter<S>> extraMatchFilters = mExtraMatchFilters;
+ if (extraMatchFilters.size() < remainderFilters.size()) {
Filter<S> composite = null;
for (int i=0; i<remainderFilters.size(); i++) {
Filter<S> subFilter = remainderFilters.get(i);
- if (!weakMatchFilters.contains(subFilter)) {
+ if (!extraMatchFilters.contains(subFilter)) {
if (composite == null) {
composite = subFilter;
} else {
@@ -587,10 +594,10 @@ public class FilteringScore<S extends Storable> {
}
}
}
- mWeakMatchRemainderFilter = composite;
+ mExtraMatchRemainderFilter = composite;
}
}
- return mWeakMatchRemainderFilter;
+ return mExtraMatchRemainderFilter;
}
/**
@@ -664,7 +671,7 @@ public class FilteringScore<S extends Storable> {
", hasRangeStart=" + hasRangeStart() +
", hasRangeEnd=" + hasRangeEnd() +
", remainderCount=" + getRemainderCount() +
- ", weakMatchCount=" + getWeakMatchCount() +
+ ", extraMatchCount=" + getExtraMatchCount() +
'}';
}
@@ -796,15 +803,13 @@ public class FilteringScore<S extends Storable> {
return 1;
}
- /* FIXME: utilize weak matches in index scans
- // Favor index which contains more weak matches.
- if (first.getWeakMatchCount() > second.getWeakMatchCount()) {
+ // Favor index which contains more extra matches.
+ if (first.getExtraMatchCount() > second.getExtraMatchCount()) {
return -1;
}
- if (first.getWeakMatchCount() < second.getWeakMatchCount()) {
+ if (first.getExtraMatchCount() < second.getExtraMatchCount()) {
return 1;
}
- */
// Favor index with fewer properties, under the assumption that fewer
// properties means smaller sized records that need to be read in.