it.unimi.dsi.fastutil.Arrays Java Examples
The following examples show how to use
it.unimi.dsi.fastutil.Arrays.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PathAndQuery.java From armeria with Apache License 2.0 | 5 votes |
void ensure(int numBytes) { int newCapacity = length + numBytes; if (newCapacity <= data.length) { return; } newCapacity = (int) Math.max(Math.min((long) data.length + (data.length >> 1), Arrays.MAX_ARRAY_SIZE), newCapacity); data = ByteArrays.forceCapacity(data, newCapacity, length); }
Example #2
Source File: PinotSegmentSorter.java From incubator-pinot with Apache License 2.0 | 4 votes |
/** * Sort the segment by the sort order columns. For PinotSegmentSorter, orderings are computed by comparing * dictionary ids. * * TODO: add the support for no-dictionary and multi-value columns. * * @param sortOrder a list of column names that represent the sorting order * @return an array of sorted docIds */ @Override public int[] getSortedDocIds(final List<String> sortOrder) { _sortOrder = new int[sortOrder.size()]; int index = 0; for (String dimension : sortOrder) { int dimensionId = _dimensionNames.indexOf(dimension); if (dimensionId != -1) { _sortOrder[index++] = dimensionId; } else { throw new IllegalStateException( "Passed dimension in the sorting order does not exist in the schema: " + dimension); } } final int[] sortedDocIds = new int[_numDocs]; for (int i = 0; i < _numDocs; i++) { sortedDocIds[i] = i; } Arrays.quickSort(0, _numDocs, (i1, i2) -> { int docId1 = sortedDocIds[i1]; int docId2 = sortedDocIds[i2]; int compare = 0; for (int sortIndex : _sortOrder) { String dimensionName = _dimensionNames.get(sortIndex); FieldSpec fieldSpec = _schema.getFieldSpecFor(dimensionName); PinotSegmentColumnReader columnReader = _columnReaderMap.get(dimensionName); // Multi value column or no dictionary column is not supported boolean isMultiValueColumn = !fieldSpec.isSingleValueField(); boolean isNoDictionaryColumn = !columnReader.hasDictionary(); if (isMultiValueColumn || isNoDictionaryColumn) { throw new IllegalStateException( "Multi value column or no dictionary column is not supported. ( column name: " + dimensionName + ", multi value column: " + isMultiValueColumn + ", no dictionary column: " + isNoDictionaryColumn + " )"); } // Compute the order compare = columnReader.getDictionaryId(docId1) - columnReader.getDictionaryId(docId2); if (compare != 0) { return compare; } } return compare; }, (i, j) -> { int temp = sortedDocIds[i]; sortedDocIds[i] = sortedDocIds[j]; sortedDocIds[j] = temp; }); return sortedDocIds; }