Refine search
/** * Returns a new LongColumn containing a value for each value in this column * * A widening primitive conversion from int to long does not lose any information at all; * the numeric value is preserved exactly. * * A missing value in the receiver is converted to a missing value in the result */ @Override public LongColumn asLongColumn() { LongArrayList values = new LongArrayList(); for (int f : data) { values.add(f); } values.trim(); return LongColumn.create(this.name(), values.elements()); }
private void initLongValues() { if (predicate != null) { return; } synchronized (initLock) { if (predicate != null) { return; } LongArrayList longs = new LongArrayList(values.size()); for (String value : values) { final Long longValue = DimensionHandlerUtils.getExactLongFromDecimalString(value); if (longValue != null) { longs.add(longValue); } } if (longs.size() > NUMERIC_HASHING_THRESHOLD) { final LongOpenHashSet longHashSet = new LongOpenHashSet(longs); predicate = input -> longHashSet.contains(input); } else { final long[] longArray = longs.toLongArray(); Arrays.sort(longArray); predicate = input -> Arrays.binarySearch(longArray, input) >= 0; } } }
public void appendTo(int channel, int position, BlockBuilder output) { long pageAddress = valueAddresses.getLong(position); Type type = types.get(channel); Block block = channels[channel].get(decodeSliceIndex(pageAddress)); int blockPosition = decodePosition(pageAddress); type.appendTo(block, blockPosition, output); }
protected LongIterator beginFpMerge() { newFps = new LongArrayList((int) (allFps.size()+(pending()/2))); return allFps.iterator(); }
/** * Creates a new Transaction. This method only get called from start transaction, which is already * synchronized. */ private Transaction createTransaction(long writePointer, TransactionType type) { // For holding the first in progress short transaction Id (with timeout >= 0). long firstShortTx = Transaction.NO_TX_IN_PROGRESS; LongArrayList inProgressIds = new LongArrayList(inProgress.size()); for (Map.Entry<Long, InProgressTx> entry : inProgress.entrySet()) { long txId = entry.getKey(); inProgressIds.add(txId); // add any checkpointed write pointers to the in-progress list LongArrayList childIds = entry.getValue().getCheckpointWritePointers(); if (childIds != null) { for (int i = 0; i < childIds.size(); i++) { inProgressIds.add(childIds.get(i)); } } if (firstShortTx == Transaction.NO_TX_IN_PROGRESS && !entry.getValue().isLongRunning()) { firstShortTx = txId; } } return new Transaction(readPointer, writePointer, invalidArray, inProgressIds.toLongArray(), firstShortTx, type); }
/** * Creates a new Transaction. This method only get called from start transaction, which is already * synchronized. */ private Transaction createTransaction(long writePointer, TransactionType type) { // For holding the first in progress short transaction Id (with timeout >= 0). long firstShortTx = Transaction.NO_TX_IN_PROGRESS; LongArrayList inProgressIds = new LongArrayList(inProgress.size()); for (Map.Entry<Long, InProgressTx> entry : inProgress.entrySet()) { long txId = entry.getKey(); inProgressIds.add(txId); if (firstShortTx == Transaction.NO_TX_IN_PROGRESS && !entry.getValue().isLongRunning()) { firstShortTx = txId; } } return new Transaction(readPointer, writePointer, invalidTxList.toSortedArray(), inProgressIds.toLongArray(), firstShortTx, type); }
@Override public LongColumn bottom(final int n) { final LongArrayList bottom = new LongArrayList(); final long[] values = data.toLongArray(); LongArrays.parallelQuickSort(values); for (int i = 0; i < n && i < values.length; i++) { bottom.add(values[i]); } return new LongColumn(name() + "[Bottoms " + n + "]", bottom); }
@Override public void open() { tempOut = new LongArrayList(); }
/** Broadcast the trace events to all of the policy actors. */ private void broadcast() { try (LongStream events = eventStream()) { LongArrayList batch = new LongArrayList(batchSize); for (PrimitiveIterator.OfLong i = events.iterator(); i.hasNext();) { batch.add(i.nextLong()); if (batch.size() == batchSize) { router.route(batch, self()); batch = new LongArrayList(batchSize); } } router.route(batch, self()); router.route(FINISH, self()); } catch (Exception e) { context().system().log().error(e, ""); context().stop(self()); } }
private static LongArrayList addresses() { LongArrayList addresses = new LongArrayList(); for (int i = 0; i < TEST_PAGE.getPositionCount(); ++i) { addresses.add(encodeSyntheticAddress(0, i)); } return addresses; } }
public void addPage(Page page) { // ignore empty pages if (page.getPositionCount() == 0) { return; } positionCount += page.getPositionCount(); int pageIndex = (channels.length > 0) ? channels[0].size() : 0; for (int i = 0; i < channels.length; i++) { Block block = page.getBlock(i); if (eagerCompact) { block = block.copyRegion(0, block.getPositionCount()); } channels[i].add(block); pagesMemorySize += block.getRetainedSizeInBytes(); } for (int position = 0; position < page.getPositionCount(); position++) { long sliceAddress = encodeSyntheticAddress(pageIndex, position); valueAddresses.add(sliceAddress); } estimatedSize = calculateEstimatedSize(); }
@Override public LongColumn lag(int n) { final int srcPos = n >= 0 ? 0 : 0 - n; final long[] dest = new long[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] = LongColumnType.missingValueIndicator(); } long[] array = data.toLongArray(); System.arraycopy(array, srcPos, dest, destPos, length); return new LongColumn(name() + " lag(" + n + ")", new LongArrayList(dest)); }
public boolean getBoolean(int channel, int position) { long pageAddress = valueAddresses.getLong(position); Block block = channels[channel].get(decodeSliceIndex(pageAddress)); int blockPosition = decodePosition(pageAddress); return types.get(channel).getBoolean(block, blockPosition); }