private static Block[] createKeyValueBlock(int positionCount, Block keys, Block values, int[] lengths) { if (!hasNull(keys)) { return new Block[] {keys, values}; } // // Map entries with a null key are skipped in the Hive ORC reader, so skip them here also // IntArrayList nonNullPositions = new IntArrayList(keys.getPositionCount()); int position = 0; for (int mapIndex = 0; mapIndex < positionCount; mapIndex++) { int length = lengths[mapIndex]; for (int entryIndex = 0; entryIndex < length; entryIndex++) { if (keys.isNull(position)) { // key is null, so remove this entry from the map lengths[mapIndex]--; } else { nonNullPositions.add(position); } position++; } } Block newKeys = keys.copyPositions(nonNullPositions.elements(), 0, nonNullPositions.size()); Block newValues = values.copyPositions(nonNullPositions.elements(), 0, nonNullPositions.size()); return new Block[] {newKeys, newValues}; }
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; } } }
@Override public void load(LazyBlock lazyBlock) { if (block == null) { return; } lazyBlock.setBlock(block.getPositions(rowsToKeep.elements(), 0, rowsToKeep.size())); // clear reference to loader to free resources, since load was successful block = null; } }
public DynamicLifespanScheduler(BucketNodeMap bucketNodeMap, List<Node> allNodes, List<ConnectorPartitionHandle> partitionHandles, OptionalInt concurrentLifespansPerTask) { this.bucketNodeMap = requireNonNull(bucketNodeMap, "bucketNodeMap is null"); this.allNodes = requireNonNull(allNodes, "allNodes is null"); this.partitionHandles = unmodifiableList(new ArrayList<>( requireNonNull(partitionHandles, "partitionHandles is null"))); this.concurrentLifespansPerTask = requireNonNull(concurrentLifespansPerTask, "concurrentLifespansPerTask is null"); concurrentLifespansPerTask.ifPresent(lifespansPerTask -> checkArgument(lifespansPerTask >= 1, "concurrentLifespansPerTask must be great or equal to 1 if present")); int bucketCount = partitionHandles.size(); verify(bucketCount > 0); this.driverGroups = new IntArrayList(IntStream.range(0, bucketCount).toArray()).iterator(); }
IntArrayList selectedPositions = new IntArrayList(); for (int position = 0; position < block.getPositionCount(); position++) { long value = block.getLong(position, 0); verifyPositive(value); if (sequential && !selectedPositions.isEmpty()) { sequential = (position == selectedPositions.getInt(selectedPositions.size() - 1) + 1); selectedPositions.add(position); if (selectedPositions.isEmpty()) { return SelectedPositions.positionsRange(0, 0); return SelectedPositions.positionsRange(selectedPositions.getInt(0), selectedPositions.size()); selectedPositions.add(0, -1); selectedPositions.add(-1); return SelectedPositions.positionsList(selectedPositions.elements(), 3, selectedPositions.size() - 6);
private IntArrayList generatePositionList(int numRows, int numPositions) { IntArrayList positions = new IntArrayList(numPositions); for (int i = 0; i < numPositions; i++) { positions.add((7 * i + 3) % numRows); } Collections.sort(positions); return positions; } }
/** * Returns a new IntColumn containing a value for each value in this column, truncating if necessary. * * A narrowing primitive conversion such as this one may lose information about the overall magnitude of a * numeric value and may also lose precision and range. Specifically, if the value is too small (a negative value * of large magnitude or negative infinity), the result is the smallest representable value of type int. * * Similarly, if the value is too large (a positive value of large magnitude or positive infinity), the result is the * largest representable value of type int. * * Despite the fact that overflow, underflow, or other loss of information may occur, a narrowing primitive * conversion never results in a run-time exception. * * A missing value in the receiver is converted to a missing value in the result */ @Override public IntColumn asIntColumn() { IntArrayList values = new IntArrayList(); for (double d : data) { values.add((int) d); } values.trim(); return IntColumn.create(this.name(), values.elements()); }
private void constructColumnIndices(RowSequentialAccessSparseMatrix rowMatrix) { IntArrayList[] columnIndicesList = new IntArrayList[rowMatrix.columnSize()]; for (int columnIndex = 0; columnIndex < rowMatrix.columnSize(); columnIndex++) { columnIndicesList[columnIndex] = new IntArrayList(); } for (MatrixEntry matrixEntry : rowMatrix) { int rowIndex = matrixEntry.row(); int columnIndex = matrixEntry.column(); columnIndicesList[columnIndex].add(rowIndex); } columnIndices = new int[rowMatrix.columnSize()][]; for (int columnIndex = 0; columnIndex < rowMatrix.columnSize(); columnIndex++) { int size = columnIndicesList[columnIndex].size(); columnIndices[columnIndex] = new int[size]; Collections.sort(columnIndicesList[columnIndex]); for (int position = 0; position < size; position++) { columnIndices[columnIndex][position] = columnIndicesList[columnIndex].getInt(position); } } }
IntArrayList labelToMerge = new IntArrayList(); IntArrayList tempIntArrayList = new IntArrayList(); TokenizerFactory tf = new DefaultTokenizerFactory(); WordVectors wv = WordVectorProvider.getWordVectors(config, wordVectorsPath); tempIntArrayList.clear(); for(String token : tokens){ if(wv.hasWord(token)){ tempIntArrayList.add(wv.indexOf(token)); if(tempIntArrayList.size() >= maxSequenceLength){ break; if(tempIntArrayList.size() < minTokens){ countSkippedOnSize++; continue; toMerge.add(tempIntArrayList.toIntArray()); labelToMerge.add(labelIdx); writtenBytes += 4; out.writeInt(-labelToMerge.get(i)); exampleCount++; writtenBytes += 4; labelToMerge.clear();
@Override public void sortDescending() { int[] elements = values.toIntArray(); IntArrays.parallelQuickSort(elements, reverseDictionarySortComparator); this.values = new IntArrayList(elements); }
WordVectors wv = WordVectorProvider.getWordVectors(conf, wordVectorsPath); IntArrayList content = new IntArrayList(); List<int[]> examples = new ArrayList<>(); IntArrayList labels = new IntArrayList(); int maxLength = -1; int minLength = Integer.MAX_VALUE; if(i < 0){ int[] example = content.toIntArray(); examples.add(example); labels.add(i); content.clear(); maxLength = Math.max(maxLength, example.length); minLength = Math.min(minLength, example.length); } else { content.add(i); l.putScalar(i, Math.abs(labels.getInt(i)), 1.0);
if (probeGeometryBlock.isNull(probePosition)) { return EMPTY_ADDRESSES; Slice slice = probeGeometryBlock.getSlice(probePosition, 0, probeGeometryBlock.getSliceLength(probePosition)); OGCGeometry probeGeometry = deserialize(slice); verify(probeGeometry != null); IntArrayList matchingPositions = new IntArrayList(); if (radiusChannel == -1) { if (spatialRelationshipTest.apply(buildGeometry, probeGeometry, OptionalDouble.empty())) { matchingPositions.add(geometryWithPosition.getPosition()); matchingPositions.add(geometryWithPosition.getPosition()); return matchingPositions.toIntArray(null);
public static IntList toIntList(IntIterator iterator) { final IntList integers = new IntArrayList(); while (iterator.hasNext()) { integers.add(iterator.nextInt()); } return IntLists.unmodifiable(integers); }
@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); }
private static int[] filterInts(IntSet intSet, int[] source) { IntList intList = new IntArrayList(); for (int value : source) { if (intSet.contains(value)) { intList.add(value); } } if (intList.size() == source.length) { return source; } else { return intList.toIntArray(); } }
int previousPosition = probeIndexBuilder.isEmpty() ? -1 : probeIndexBuilder.get(probeIndexBuilder.size() - 1); probeIndexBuilder.add(position); estimatedProbeBlockBytes += Integer.BYTES; Block block = probe.getPage().getBlock(index); estimatedProbeBlockBytes += block.getSizeInBytes() / block.getPositionCount();
public TypedSet(Type elementType, BlockBuilder blockBuilder, int expectedSize, String functionName) { checkArgument(expectedSize >= 0, "expectedSize must not be negative"); this.elementType = requireNonNull(elementType, "elementType must not be null"); this.elementBlock = requireNonNull(blockBuilder, "blockBuilder must not be null"); this.functionName = functionName; initialElementBlockOffset = elementBlock.getPositionCount(); initialElementBlockSizeInBytes = elementBlock.getSizeInBytes(); this.size = 0; this.hashCapacity = arraySize(expectedSize, FILL_RATIO); this.maxFill = calculateMaxFill(hashCapacity); this.hashMask = hashCapacity - 1; blockPositionByHash = new IntArrayList(hashCapacity); blockPositionByHash.size(hashCapacity); for (int i = 0; i < hashCapacity; i++) { blockPositionByHash.set(i, EMPTY_SLOT); } this.containsNullElement = false; }
@Override public int[] getMatchingDictIds() { if (_matchingDictIds == null) { IntList matchingDictIds = new IntArrayList(); int dictionarySize = _dictionary.length(); for (int dictId = 0; dictId < dictionarySize; dictId++) { if (applySV(dictId)) { matchingDictIds.add(dictId); } } _matchingDictIds = matchingDictIds.toIntArray(); } return _matchingDictIds; } }