public void sortValueSet(boolean direction, NullOrder nullOrder) { int size = getValueSet().get(0).size(); int[] sortOn = new int[size]; for (int i = 0; i <sortOn.length; i++) { sortOn[i] = i; } Collections.sort(getValueSet(), new ListNestedSortComparator(sortOn, direction).defaultNullOrder(nullOrder)); }
@Override public int compareTo(SortedSublist o) { //reverse the comparison, so that removal of the lowest is a low cost operation return -comparator.compare(this.tuple, o.tuple); }
public void removeRowIdFromKey() { this.keyLength--; int[] sortParameters = this.comparator.getSortParameters(); sortParameters = Arrays.copyOf(sortParameters, sortParameters.length - 1); this.comparator.setSortParameters(sortParameters); }
private void init(TupleSource sourceID, Mode mode, BufferManager bufferMgr, String groupName, List<? extends Expression> schema, List<Boolean> sortTypes, List<NullOrdering> nullOrderings, int[] cols) { this.source = sourceID; this.mode = mode; this.bufferManager = bufferMgr; this.groupName = groupName; this.schema = schema; this.schemaSize = bufferManager.getSchemaSize(this.schema); this.batchSize = bufferManager.getProcessorBatchSize(this.schema); this.targetRowCount = Math.max(bufferManager.getMaxProcessingSize()/this.schemaSize, 2)*this.batchSize; this.comparator = new ListNestedSortComparator(cols, sortTypes).defaultNullOrder(bufferMgr.getOptions().getDefaultNullOrder()); int distinctIndex = cols.length - 1; this.comparator.setDistinctIndex(distinctIndex); this.comparator.setNullOrdering(nullOrderings); }
tree.getComparator().setNullOrdering(nullOrdering); tree.getComparator().setOrderTypes(sortTypes);
@Test public void testComparatorNullOrdering() { ListNestedSortComparator<Integer> comparator = new ListNestedSortComparator<Integer>(new int[] {0}, OrderBy.DESC); comparator.setNullOrdering(Arrays.asList(NullOrdering.FIRST)); List<Integer>[] data = new List[3]; data[0] = Arrays.asList(1); data[1] = Arrays.asList((Integer)null); data[2] = Arrays.asList(2); Arrays.sort(data, comparator); assertNull(data[0].get(0)); comparator.setNullOrdering(Arrays.asList(NullOrdering.LAST)); Arrays.sort(data, comparator); assertNull(data[2].get(0)); comparator = new ListNestedSortComparator<Integer>(new int[] {0}, OrderBy.ASC); Arrays.sort(data, comparator); assertNull(data[0].get(0)); comparator.setNullOrdering(Arrays.asList(NullOrdering.LAST)); Arrays.sort(data, comparator); assertNull(data[2].get(0)); }
index.setPreferMemory(true); if (sortOption == SortOption.SORT_DISTINCT) { index.getComparator().setDistinctIndex(expressionIndexes.length); } else if (!state.isExpresssionDistinct()) { index.getComparator().setDistinctIndex(keyLength-2); && ((!sorted && index.getComparator().isDistinct()) || (sorted && sortedDistinct))) { if (sortOption!=SortOption.SORT_DISTINCT) { this.index.removeRowIdFromKey();
ListNestedSortComparator<Integer> comparator = new ListNestedSortComparator<Integer>(new int[] {0}, OrderBy.DESC);
public boolean isDistinct() { return this.comparator.isDistinct(); }
nullOrderings, cols); if (distinctIndex != -1) { this.comparator.setDistinctIndex(distinctIndex);
NullOrdering no = getNullOrdering(k); if (no == NullOrdering.FIRST) { return -1; NullOrdering no = getNullOrdering(k); if (no == NullOrdering.FIRST) { return 1;
private void init(TupleSource sourceID, Mode mode, BufferManager bufferMgr, String groupName, List<? extends Expression> schema, List<Boolean> sortTypes, List<NullOrdering> nullOrderings, int[] cols) { this.source = sourceID; this.mode = mode; this.bufferManager = bufferMgr; this.groupName = groupName; this.schema = schema; this.schemaSize = bufferManager.getSchemaSize(this.schema); this.batchSize = bufferManager.getProcessorBatchSize(this.schema); this.targetRowCount = Math.max(bufferManager.getMaxProcessingSize()/this.schemaSize, 2)*this.batchSize; this.comparator = new ListNestedSortComparator(cols, sortTypes).defaultNullOrder(bufferMgr.getOptions().getDefaultNullOrder()); int distinctIndex = cols.length - 1; this.comparator.setDistinctIndex(distinctIndex); this.comparator.setNullOrdering(nullOrderings); }
tree.getComparator().setNullOrdering(nullOrdering); tree.getComparator().setOrderTypes(sortTypes);
index.setPreferMemory(true); if (sortOption == SortOption.SORT_DISTINCT) { index.getComparator().setDistinctIndex(expressionIndexes.length); } else if (!state.isExpresssionDistinct()) { index.getComparator().setDistinctIndex(keyLength-2); && ((!sorted && index.getComparator().isDistinct()) || (sorted && sortedDistinct))) { if (sortOption!=SortOption.SORT_DISTINCT) { this.index.removeRowIdFromKey();
public boolean isDistinct() { return this.comparator.isDistinct(); }
nullOrderings, cols); if (distinctIndex != -1) { this.comparator.setDistinctIndex(distinctIndex);
NullOrdering no = getNullOrdering(k); if (no == NullOrdering.FIRST) { return -1; NullOrdering no = getNullOrdering(k); if (no == NullOrdering.FIRST) { return 1;
private void init(TupleSource sourceID, Mode mode, BufferManager bufferMgr, String groupName, List<? extends Expression> schema, List<Boolean> sortTypes, List<NullOrdering> nullOrderings, int[] cols) { this.source = sourceID; this.mode = mode; this.bufferManager = bufferMgr; this.groupName = groupName; this.schema = schema; this.schemaSize = bufferManager.getSchemaSize(this.schema); this.batchSize = bufferManager.getProcessorBatchSize(this.schema); this.targetRowCount = Math.max(bufferManager.getMaxProcessingSize()/this.schemaSize, 2)*this.batchSize; this.comparator = new ListNestedSortComparator(cols, sortTypes).defaultNullOrder(bufferMgr.getOptions().getDefaultNullOrder()); int distinctIndex = cols.length - 1; this.comparator.setDistinctIndex(distinctIndex); this.comparator.setNullOrdering(nullOrderings); }
public void sortValueSet(boolean direction, NullOrder nullOrder) { int size = getValueSet().get(0).size(); int[] sortOn = new int[size]; for (int i = 0; i <sortOn.length; i++) { sortOn[i] = i; } Collections.sort(getValueSet(), new ListNestedSortComparator(sortOn, direction).defaultNullOrder(nullOrder)); }
tree.getComparator().setNullOrdering(nullOrdering); tree.getComparator().setOrderTypes(sortTypes);