summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian S. O'Neill <bronee@gmail.com>2007-01-13 20:01:54 +0000
committerBrian S. O'Neill <bronee@gmail.com>2007-01-13 20:01:54 +0000
commit526c529f4ab9d7be1604d573efbcc8b478f6c8ba (patch)
tree5c7f6ffcf0251fda793e38bb7468b68e16b40a31
parent0947834ac950fb4dd59b719cbdddc1726e68674b (diff)
Fix for getting supplied filter values when duplicate property filters exist.
-rw-r--r--src/main/java/com/amazon/carbonado/filter/FilterValues.java20
1 files changed, 15 insertions, 5 deletions
diff --git a/src/main/java/com/amazon/carbonado/filter/FilterValues.java b/src/main/java/com/amazon/carbonado/filter/FilterValues.java
index b9d3f5a..331ee3f 100644
--- a/src/main/java/com/amazon/carbonado/filter/FilterValues.java
+++ b/src/main/java/com/amazon/carbonado/filter/FilterValues.java
@@ -525,14 +525,15 @@ public class FilterValues<S extends Storable> implements Appender {
}
FilterValues<S> prevValues = mPrevValues;
- int blankCount;
- if (prevValues == null || (blankCount= prevValues.mCurrentProperty.getBlankCount()) == 0) {
+ if (prevValues == null) {
return NO_VALUES;
}
int i = list.getPreviousRemaining() + 1;
- int valuesPos = Math.min(i, blankCount);
+ // Array is sized assuming that no constants are encountered and all
+ // filters are assigned values. Array is trimmed later if necessary.
+ int valuesPos = i;
Object[] values = new Object[valuesPos];
FilterValues filterValues = this;
@@ -588,8 +589,17 @@ public class FilterValues<S extends Storable> implements Appender {
}
values[--valuesPos] = value;
- if (valuesPos <= 0) {
- break;
+ }
+
+ if (valuesPos != 0) {
+ // Trim array.
+ int newValuesSize = values.length - valuesPos;
+ if (newValuesSize == 0) {
+ values = NO_VALUES;
+ } else {
+ Object[] newValues = new Object[newValuesSize];
+ System.arraycopy(values, valuesPos, newValues, 0, newValuesSize);
+ values = newValues;
}
}