private boolean shouldIndex(SourceState possibleIndex, SourceState other) throws TeiidComponentException, TeiidProcessingException { long size = joinNode.getBatchSize(); long indexSize = possibleIndex.hasBuffer()?possibleIndex.getRowCount():-1; long otherSize = other.hasBuffer()?other.getRowCount():-1; int schemaSize = this.joinNode.getBufferManager().getSchemaSize(other.getSource().getOutputElements()); int toReserve = this.joinNode.getBufferManager().getMaxProcessingSize(); if (indexSize == -1 && (possibleIndex.rowCountLE((int)size) || possibleIndex.hasBuffer())) { indexSize = possibleIndex.getRowCount(); if (otherSize == -1 && (other.rowCountLE((int)size) || other.hasBuffer())) { otherSize = other.getRowCount(); if (other.hasBuffer() && ((other.getRowCount() <= this.joinNode.getBatchSize()) || (possibleIndex.getRowCount() > this.joinNode.getBatchSize() && other.rowCountLE(minSize)))) { return false; //just use a merge join if (other.hasBuffer()) { other.getTupleBuffer().setForwardOnly(true);
private boolean shouldIndex(SourceState possibleIndex, SourceState other) throws TeiidComponentException, TeiidProcessingException { long size = joinNode.getBatchSize(); long indexSize = possibleIndex.hasBuffer()?possibleIndex.getRowCount():-1; long otherSize = other.hasBuffer()?other.getRowCount():-1; int schemaSize = this.joinNode.getBufferManager().getSchemaSize(other.getSource().getOutputElements()); int toReserve = this.joinNode.getBufferManager().getMaxProcessingSize(); if (indexSize == -1 && (possibleIndex.rowCountLE((int)size) || possibleIndex.hasBuffer())) { indexSize = possibleIndex.getRowCount(); if (otherSize == -1 && (other.rowCountLE((int)size) || other.hasBuffer())) { otherSize = other.getRowCount(); if (other.hasBuffer() && ((other.getRowCount() <= this.joinNode.getBatchSize()) || (possibleIndex.getRowCount() > this.joinNode.getBatchSize() && other.rowCountLE(minSize)))) { return false; //just use a merge join if (other.hasBuffer()) { other.getTupleBuffer().setForwardOnly(true);
private boolean shouldIndex(SourceState possibleIndex, SourceState other) throws TeiidComponentException, TeiidProcessingException { long size = joinNode.getBatchSize(); long indexSize = possibleIndex.hasBuffer()?possibleIndex.getRowCount():-1; long otherSize = other.hasBuffer()?other.getRowCount():-1; int schemaSize = this.joinNode.getBufferManager().getSchemaSize(other.getSource().getOutputElements()); int toReserve = this.joinNode.getBufferManager().getMaxProcessingSize(); if (indexSize == -1 && (possibleIndex.rowCountLE((int)size) || possibleIndex.hasBuffer())) { indexSize = possibleIndex.getRowCount(); if (otherSize == -1 && (other.rowCountLE((int)size) || other.hasBuffer())) { otherSize = other.getRowCount(); if (other.hasBuffer() && ((other.getRowCount() <= this.joinNode.getBatchSize()) || (possibleIndex.getRowCount() > this.joinNode.getBatchSize() && other.rowCountLE(minSize)))) { return false; //just use a merge join if (other.hasBuffer()) { other.getTupleBuffer().setForwardOnly(true);
} else if (!this.leftSource.hasBuffer() && processingSortLeft == SortOption.SORT && shouldIndexIfSmall(this.rightSource)) { this.processingSortLeft = SortOption.NOT_SORTED; } else { if (!this.rightSource.hasBuffer() && processingSortRight == SortOption.SORT && this.joinNode.getJoinType() != JoinType.JOIN_LEFT_OUTER && shouldIndexIfSmall(this.leftSource)) { this.processingSortRight = SortOption.NOT_SORTED; } else if (processingSortRight == SortOption.SORT && this.joinNode.getJoinType() != JoinType.JOIN_LEFT_OUTER && ((!this.rightSource.hasBuffer() && processingSortLeft != SortOption.SORT) || shouldIndex(this.leftSource, this.rightSource))) { this.processingSortRight = SortOption.NOT_SORTED; } else if (processingSortLeft == SortOption.SORT && ((!joinNode.isDependent() && !this.leftSource.hasBuffer() && (!this.rightSource.hasBuffer() || processingSortRight == SortOption.ALREADY_SORTED)) || shouldIndex(this.rightSource, this.leftSource))) { this.processingSortLeft = SortOption.NOT_SORTED;
} else if (!this.leftSource.hasBuffer() && processingSortLeft == SortOption.SORT && shouldIndexIfSmall(this.rightSource)) { this.processingSortLeft = SortOption.NOT_SORTED; } else { if (!this.rightSource.hasBuffer() && processingSortRight == SortOption.SORT && this.joinNode.getJoinType() != JoinType.JOIN_LEFT_OUTER && shouldIndexIfSmall(this.leftSource)) { this.processingSortRight = SortOption.NOT_SORTED; } else if (processingSortRight == SortOption.SORT && this.joinNode.getJoinType() != JoinType.JOIN_LEFT_OUTER && ((!this.rightSource.hasBuffer() && processingSortLeft != SortOption.SORT) || shouldIndex(this.leftSource, this.rightSource))) { this.processingSortRight = SortOption.NOT_SORTED; } else if (processingSortLeft == SortOption.SORT && shouldIndex(this.rightSource, this.leftSource)) {
} else if (!this.leftSource.hasBuffer() && processingSortLeft == SortOption.SORT && shouldIndexIfSmall(this.rightSource)) { this.processingSortLeft = SortOption.NOT_SORTED; } else { if (!this.rightSource.hasBuffer() && processingSortRight == SortOption.SORT && this.joinNode.getJoinType() != JoinType.JOIN_LEFT_OUTER && shouldIndexIfSmall(this.leftSource)) { this.processingSortRight = SortOption.NOT_SORTED; } else if (processingSortRight == SortOption.SORT && this.joinNode.getJoinType() != JoinType.JOIN_LEFT_OUTER && ((!this.rightSource.hasBuffer() && processingSortLeft != SortOption.SORT) || shouldIndex(this.leftSource, this.rightSource))) { this.processingSortRight = SortOption.NOT_SORTED; } else if (processingSortLeft == SortOption.SORT && shouldIndex(this.rightSource, this.leftSource)) {