/** * Returns the largest ("top") n values in the column. Does not change the order in this column * * @param n The maximum number of records to return. The actual number will be smaller if n is greater than the * number of observations in the column * @return A list, possibly empty, of the largest observations */ public List<LocalTime> top(int n) { List<LocalTime> top = new ArrayList<>(); int[] values = data.toIntArray(); IntArrays.parallelQuickSort(values, descendingIntComparator); for (int i = 0; i < n && i < values.length; i++) { top.add(PackedLocalTime.asLocalTime(values[i])); } return top; }
/** * Returns the smallest ("bottom") n values in the column * * @param n The maximum number of records to return. The actual number will be smaller if n is greater than the * number of observations in the column * @return A list, possibly empty, of the smallest n observations */ public List<LocalDate> bottom(int n) { List<LocalDate> bottom = new ArrayList<>(); int[] values = data.toIntArray(); IntArrays.parallelQuickSort(values); for (int i = 0; i < n && i < values.length; i++) { bottom.add(PackedLocalDate.asLocalDate(values[i])); } return bottom; }
@Override public void sortDescending() { int[] elements = values.toIntArray(); IntArrays.parallelQuickSort(elements, reverseDictionarySortComparator); this.values = new IntArrayList(elements); }
@Override public void sortAscending() { int[] sorted = data.toIntArray(); Arrays.parallelSort(sorted); this.data = new IntArrayList(sorted); }
@Override public void sortAscending() { int[] elements = values.toIntArray(); IntArrays.parallelQuickSort(elements, dictionarySortComparator); this.values = new IntArrayList(elements); }
private void initFloatValues() { if (predicate != null) { return; } synchronized (initLock) { if (predicate != null) { return; } IntArrayList floatBits = new IntArrayList(values.size()); for (String value : values) { Float floatValue = Floats.tryParse(value); if (floatValue != null) { floatBits.add(Float.floatToIntBits(floatValue)); } } if (floatBits.size() > NUMERIC_HASHING_THRESHOLD) { final IntOpenHashSet floatBitsHashSet = new IntOpenHashSet(floatBits); predicate = input -> floatBitsHashSet.contains(Float.floatToIntBits(input)); } else { final int[] floatBitsArray = floatBits.toIntArray(); Arrays.sort(floatBitsArray); predicate = input -> Arrays.binarySearch(floatBitsArray, Float.floatToIntBits(input)) >= 0; } } }
/** * Returns the largest ("top") n values in the column * * @param n The maximum number of records to return. The actual number will be smaller if n is greater than the * number of observations in the column * @return A list, possibly empty, of the largest observations */ public List<LocalDate> top(int n) { List<LocalDate> top = new ArrayList<>(); int[] values = data.toIntArray(); IntArrays.parallelQuickSort(values, DescendingIntComparator.instance()); for (int i = 0; i < n && i < values.length; i++) { top.add(PackedLocalDate.asLocalDate(values[i])); } return top; }
/** * Returns the smallest ("bottom") n values in the column, Does not change the order in this column * * @param n The maximum number of records to return. The actual number will be smaller if n is greater than the * number of observations in the column * @return A list, possibly empty, of the smallest n observations */ public List<LocalTime> bottom(int n) { List<LocalTime> bottom = new ArrayList<>(); int[] values = data.toIntArray(); IntArrays.parallelQuickSort(values); int rowCount = 0; int validCount = 0; while (validCount < n && rowCount < size()) { int value = values[rowCount]; if (value != TimeColumnType.missingValueIndicator()) { bottom.add(PackedLocalTime.asLocalTime(value)); validCount++; } rowCount++; } return bottom; }
@Override public IntColumn top(int n) { final IntArrayList top = new IntArrayList(); final int[] values = data.toIntArray(); IntArrays.parallelQuickSort(values, descendingComparator); for (int i = 0; i < n && i < values.length; i++) { top.add(values[i]); } return new IntColumn(name() + "[Top " + n + "]", top); }
@Override public IntColumn bottom(final int n) { final IntArrayList bottom = new IntArrayList(); final int[] values = data.toIntArray(); IntArrays.parallelQuickSort(values); for (int i = 0; i < n && i < values.length; i++) { bottom.add(values[i]); } return new IntColumn(name() + "[Bottoms " + n + "]", bottom); }
toMerge.add(tempIntArrayList.toIntArray()); labelToMerge.add(labelIdx);
if(i < 0){ int[] example = content.toIntArray(); examples.add(example); labels.add(i);
@Override public IntColumn lag(int n) { final int srcPos = n >= 0 ? 0 : 0 - n; final int[] dest = new int[size()]; final int destPos = n <= 0 ? 0 : n; final int length = n >= 0 ? size() - n : size() + n; for (int i = 0; i < size(); i++) { dest[i] = IntColumnType.missingValueIndicator(); } int[] array = data.toIntArray(); System.arraycopy(array, srcPos, dest, destPos, length); return new IntColumn(name() + " lag(" + n + ")", new IntArrayList(dest)); }
@Override public DateColumn lag(int n) { int srcPos = n >= 0 ? 0 : 0 - n; int[] dest = new int[size()]; int destPos = n <= 0 ? 0 : n; int length = n >= 0 ? size() - n : size() + n; for (int i = 0; i < size(); i++) { dest[i] = DateColumnType.missingValueIndicator(); } System.arraycopy(data.toIntArray(), srcPos, dest, destPos, length); DateColumn copy = emptyCopy(size()); copy.data = new IntArrayList(dest); copy.setName(name() + " lag(" + n + ")"); return copy; }
@Override public TimeColumn lag(int n) { int srcPos = n >= 0 ? 0 : 0 - n; int[] dest = new int[size()]; int destPos = n <= 0 ? 0 : n; int length = n >= 0 ? size() - n : size() + n; for (int i = 0; i < size(); i++) { dest[i] = TimeColumnType.missingValueIndicator(); } System.arraycopy(data.toIntArray(), srcPos, dest, destPos, length); TimeColumn copy = emptyCopy(size()); copy.data = new IntArrayList(dest); copy.setName(name() + " lag(" + n + ")"); return copy; }
private void testWith(List<Type> fieldTypes, List<Object>[] expectedValues) { BlockBuilder blockBuilder = createBlockBuilderWithValues(fieldTypes, expectedValues); assertBlock(blockBuilder, () -> blockBuilder.newBlockBuilderLike(null), expectedValues); assertBlock(blockBuilder.build(), () -> blockBuilder.newBlockBuilderLike(null), expectedValues); IntArrayList positionList = generatePositionList(expectedValues.length, expectedValues.length / 2); assertBlockFilteredPositions(expectedValues, blockBuilder, () -> blockBuilder.newBlockBuilderLike(null), positionList.toIntArray()); assertBlockFilteredPositions(expectedValues, blockBuilder.build(), () -> blockBuilder.newBlockBuilderLike(null), positionList.toIntArray()); }
return matchingPositions.toIntArray(null);
public Page build(JoinProbe probe) int[] probeIndices = probeIndexBuilder.toIntArray(); int length = probeIndices.length; verify(buildPageBuilder.getPositionCount() == length);
/** Returns the positions of an index iterator as an array. * * <p>Note that this method just iterates {@link IndexIterator#nextPosition()}. If the * method has already been called, the positions that have been already returned will be missing. * * @return an array containing the positions obtained by repeatedly calling {@link IndexIterator#nextPosition()}. */ public static int[] positionArray( final IndexIterator indexIterator ) throws IOException { IntArrayList l = new IntArrayList(); for( int p; ( p = indexIterator.nextPosition() ) != IndexIterator.END_OF_POSITIONS; ) l.add( p ); return l.toIntArray(); }
/** Returns an array containing the variables in increasing order. * * <p>Mainly for debugging purposes. * * @return an array containing the variables in increasing order. */ public int[] variables() { final IntArrayList variables = new IntArrayList(); for(int i = 0; i < bitVector.length(); i++) if (bitVector.getBoolean(i)) variables.add(i); return variables.toIntArray(); }