if (sortOption == SortOption.SORT_DISTINCT) { keyLength = elements.size(); } else if (!state.isExpresssionDistinct()) { if (sortOption == SortOption.SORT_DISTINCT) { index.getComparator().setDistinctIndex(expressionIndexes.length); } else if (!state.isExpresssionDistinct()) { index.getComparator().setDistinctIndex(keyLength-2); boolean sortedDistinct = sorted && !state.isExpresssionDistinct(); int sizeHint = index.getExpectedHeight(state.getRowCount()); index.setBatchInsert(sorted); if (!state.isExpresssionDistinct() && sortOption != SortOption.SORT_DISTINCT) { tuple.add(keyLength - 1, rowId++); for (int i = 0; i < reorderedSortIndex.length; i++) { int oldIndex = reorderedSortIndex[i]; this.reverseIndexes[oldIndex] = i + ((!state.isExpresssionDistinct()&&(i>=keyLength-1)&&sortOption!=SortOption.SORT_DISTINCT)?1:0); if (!state.isExpresssionDistinct() && ((!sorted && index.getComparator().isDistinct()) || (sorted && sortedDistinct))) { if (sortOption!=SortOption.SORT_DISTINCT) {
if (sortOption == SortOption.SORT_DISTINCT) { keyLength = elements.size(); } else if (!state.isExpresssionDistinct()) { if (sortOption == SortOption.SORT_DISTINCT) { index.getComparator().setDistinctIndex(expressionIndexes.length); } else if (!state.isExpresssionDistinct()) { index.getComparator().setDistinctIndex(keyLength-2); boolean sortedDistinct = sorted && !state.isExpresssionDistinct(); int sizeHint = index.getExpectedHeight(state.getRowCount()); index.setBatchInsert(sorted); if (!state.isExpresssionDistinct() && sortOption != SortOption.SORT_DISTINCT) { tuple.add(keyLength - 1, rowId++); for (int i = 0; i < reorderedSortIndex.length; i++) { int oldIndex = reorderedSortIndex[i]; this.reverseIndexes[oldIndex] = i + ((!state.isExpresssionDistinct()&&(i>=keyLength-1)&&sortOption!=SortOption.SORT_DISTINCT)?1:0); if (!state.isExpresssionDistinct() && ((!sorted && index.getComparator().isDistinct()) || (sorted && sortedDistinct))) { if (sortOption!=SortOption.SORT_DISTINCT) {
if (sortOption == SortOption.SORT_DISTINCT) { keyLength = elements.size(); } else if (!state.isExpresssionDistinct()) { if (sortOption == SortOption.SORT_DISTINCT) { index.getComparator().setDistinctIndex(expressionIndexes.length); } else if (!state.isExpresssionDistinct()) { index.getComparator().setDistinctIndex(keyLength-2); boolean sortedDistinct = sorted && !state.isExpresssionDistinct(); int sizeHint = index.getExpectedHeight(state.getRowCount()); index.setBatchInsert(sorted); if (!state.isExpresssionDistinct() && sortOption != SortOption.SORT_DISTINCT) { tuple.add(keyLength - 1, rowId++); for (int i = 0; i < reorderedSortIndex.length; i++) { int oldIndex = reorderedSortIndex[i]; this.reverseIndexes[oldIndex] = i + ((!state.isExpresssionDistinct()&&(i>=keyLength-1)&&sortOption!=SortOption.SORT_DISTINCT)?1:0); if (!state.isExpresssionDistinct() && ((!sorted && index.getComparator().isDistinct()) || (sorted && sortedDistinct))) { if (sortOption!=SortOption.SORT_DISTINCT) {
if (!target.isExpresssionDistinct()) { compare = compare(previousTuple, target.getCurrentTuple(), target.getExpressionIndexes(), target.getExpressionIndexes()); if (compare < 0) {
if (!target.isExpresssionDistinct()) { compare = compare(previousTuple, target.getCurrentTuple(), target.getExpressionIndexes(), target.getExpressionIndexes()); if (compare < 0) {
protected boolean compareToPrevious(SourceState target) throws TeiidComponentException, TeiidProcessingException { if (!target.getIterator().hasNext()) { target.setMaxProbeMatch(target.getIterator().getCurrentIndex()); return false; } List previousTuple = target.getCurrentTuple(); target.saveNext(); if (target.getMaxProbeMatch() >= target.getIterator().getCurrentIndex()) { return true; } if (previousTuple != null) { int compare = 1; if (!target.isExpresssionDistinct()) { compare = compare(previousTuple, target.getCurrentTuple(), target.getExpressionIndexes(), target.getExpressionIndexes()); if (compare < 0) { //sanity check - this means the sort order is not as expected //note this is not a complete check - it will not detect all invalid circumstances as we exit early throw new TeiidComponentException(QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31202)); } } if (compare != 0) { target.setMaxProbeMatch(target.getIterator().getCurrentIndex() - 1); return false; } } target.setMaxProbeMatch(target.getIterator().getCurrentIndex()); return true; }
dvs.setDistinct(this.joinStrategy.rightSource.isExpresssionDistinct()); this.getContext().getVariableContext().setGlobalValue(this.dependentValueSource, dvs); dvs.setDistinct(this.joinStrategy.leftSource.isExpresssionDistinct()); this.getContext().getVariableContext().setGlobalValue(this.dependentValueSource, dvs);
dvs.setDistinct(this.joinStrategy.rightSource.isExpresssionDistinct()); this.getContext().getVariableContext().setGlobalValue(this.dependentValueSource, dvs); dvs.setDistinct(this.joinStrategy.leftSource.isExpresssionDistinct()); this.getContext().getVariableContext().setGlobalValue(this.dependentValueSource, dvs);
dvs.setDistinct(this.joinStrategy.rightSource.isExpresssionDistinct()); this.getContext().getVariableContext().setGlobalValue(this.dependentValueSource, dvs); dvs.setDistinct(this.joinStrategy.leftSource.isExpresssionDistinct()); this.getContext().getVariableContext().setGlobalValue(this.dependentValueSource, dvs);
this.notSortedSource = this.rightSource; if (semiDep && this.leftSource.isExpresssionDistinct()) { this.rightSource.getTupleBuffer(); if (!this.joinNode.getDependentValueSource().isUnused()) {
this.notSortedSource = this.rightSource; if (semiDep && this.leftSource.isExpresssionDistinct()) { this.rightSource.getTupleBuffer(); if (!this.joinNode.getDependentValueSource().isUnused()) {
this.notSortedSource = this.rightSource; if (semiDep && this.leftSource.isExpresssionDistinct()) { this.rightSource.getTupleBuffer(); if (!this.joinNode.getDependentValueSource().isUnused()) {