Permalink
Browse files

TEIID-2429 last refinements to sort performance

  • Loading branch information...
1 parent d69f44d commit dd6e72033da82a02eb9cfc323619add1735c9130 @shawkins shawkins committed Mar 21, 2013
@@ -59,12 +59,12 @@
public class DataTypeManager {
static final String ARRAY_SUFFIX = "[]"; //$NON-NLS-1$
- private static final boolean USE_VALUE_CACHE = PropertiesUtils.getBooleanProperty(System.getProperties(), "org.teiid.useValueCache", false); //$NON-NLS-1$
+ public static final boolean USE_VALUE_CACHE = PropertiesUtils.getBooleanProperty(System.getProperties(), "org.teiid.useValueCache", false); //$NON-NLS-1$
private static final boolean COMPARABLE_LOBS = PropertiesUtils.getBooleanProperty(System.getProperties(), "org.teiid.comparableLobs", false); //$NON-NLS-1$
private static final boolean COMPARABLE_OBJECT = PropertiesUtils.getBooleanProperty(System.getProperties(), "org.teiid.comparableObject", false); //$NON-NLS-1$
public static final boolean PAD_SPACE = PropertiesUtils.getBooleanProperty(System.getProperties(), "org.teiid.padSpace", false); //$NON-NLS-1$
- private static boolean valueCacheEnabled;
+ private static boolean valueCacheEnabled = USE_VALUE_CACHE;
private interface ValueCache<T> {
T getValue(T value);
@@ -57,10 +57,11 @@ public int getCurrentIndex() {
BlockedException, TeiidProcessingException {
if (available() > 0) {
//if (forwardOnly) {
- if (batch == null || !batch.containsRow(currentRow)) {
- batch = getBatch(currentRow);
+ int row = getCurrentIndex();
+ if (batch == null || !batch.containsRow(row)) {
+ batch = getBatch(row);
}
- return batch.getTuple(currentRow);
+ return batch.getTuple(row);
//}
//TODO: determine if we should directly hold a soft reference here
//return getRow(currentRow);
@@ -49,14 +49,15 @@
AbstractTupleSource {
private final boolean singleUse;
private boolean noBlocking;
+ private boolean reverse;
private TupleBufferTupleSource(boolean singleUse) {
this.singleUse = singleUse;
}
@Override
protected List<?> finalRow() throws TeiidComponentException, TeiidProcessingException {
- if(isFinal || noBlocking) {
+ if(isFinal || noBlocking || reverse) {
return null;
}
if (rowSourceLock == null) {
@@ -76,7 +77,10 @@ private TupleBufferTupleSource(boolean singleUse) {
@Override
public int available() {
- return rowCount - getCurrentIndex() + 1;
+ if (!reverse) {
+ return rowCount - getCurrentIndex() + 1;
+ }
+ return getCurrentIndex();
}
@Override
@@ -95,6 +99,19 @@ public void closeSource() {
public void setNoBlocking(boolean noBlocking) {
this.noBlocking = noBlocking;
}
+
+ public void setReverse(boolean reverse) {
+ this.reverse = reverse;
+ }
+
+ @Override
+ public int getCurrentIndex() {
+ if (!reverse) {
+ return super.getCurrentIndex();
+ }
+ return getRowCount() - super.getCurrentIndex() + 1;
+ }
+
}
/**
@@ -448,8 +465,8 @@ public void truncateTo(int rowLimit) throws TeiidComponentException {
/**
* Return a more accurate batch estimate or 0 if a new estimate is not available
*/
- public int getBatchMemorySizeEstimate() {
- return this.manager.getRowSizeEstimate()*this.batchSize;
+ public int getRowSizeEstimate() {
+ return this.manager.getRowSizeEstimate();
}
}
Oops, something went wrong.

0 comments on commit dd6e720

Please sign in to comment.