public DateTimeColumn appendInternal(long dateTime) { data.add(dateTime); return this; }
public LongColumn append(long i) { data.add(i); return this; }
protected void addNewFp(long currFp) { newFps.add(currFp); }
private void initDoubleValues() { if (predicate != null) { return; } synchronized (initLock) { if (predicate != null) { return; } LongArrayList doubleBits = new LongArrayList(values.size()); for (String value : values) { Double doubleValue = Doubles.tryParse(value); if (doubleValue != null) { doubleBits.add(Double.doubleToLongBits((doubleValue))); } } if (doubleBits.size() > NUMERIC_HASHING_THRESHOLD) { final LongOpenHashSet doubleBitsHashSet = new LongOpenHashSet(doubleBits); predicate = input -> doubleBitsHashSet.contains(Double.doubleToLongBits(input)); } else { final long[] doubleBitsArray = doubleBits.toLongArray(); Arrays.sort(doubleBitsArray); predicate = input -> Arrays.binarySearch(doubleBitsArray, Double.doubleToLongBits(input)) >= 0; } } } @Override
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; } } }
private static LongArrayList addresses() { LongArrayList addresses = new LongArrayList(); for (int i = 0; i < TEST_PAGE.getPositionCount(); ++i) { addresses.add(encodeSyntheticAddress(0, i)); } return addresses; } }
@Override public LongColumn top(int n) { final LongArrayList top = new LongArrayList(); final long[] values = data.toLongArray(); LongArrays.parallelQuickSort(values, descendingComparator); for (int i = 0; i < n && i < values.length; i++) { top.add(values[i]); } return new LongColumn(name() + "[Top " + n + "]", top); }
@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); }
/** * Returns a new LongColumn containing a value for each value in this column * * A widening primitive conversion from short 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()); }
/** * 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()); }
/** * Returns a new LongColumn 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 long. * * 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 long. * * 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 LongColumn asLongColumn() { LongArrayList values = new LongArrayList(); for (double d : data) { values.add((long) d); } values.trim(); return LongColumn.create(this.name(), values.elements()); }
/** * Returns a new LongColumn 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 long. * * 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 long. * * 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 LongColumn asLongColumn() { LongArrayList values = new LongArrayList(); for (float f : data) { values.add((long) f); } values.trim(); return LongColumn.create(this.name(), values.elements()); }
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(); }
/** 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()); } }
@Override public boolean add(long k) { ensureCanInsert(k); if (fullImpl != null) { return fullImpl.add(k); } else { assert compactImpl != null; return compactImpl.add((int) k); } }
@Override public void add(int index, long k) { ensureCanInsert(k); if (fullImpl != null) { fullImpl.add(index, k); } else { assert compactImpl != null; compactImpl.add(index, (int) k); } }
/** * Get an index for a key, generating a new one if necessary. * * @param key The key. * @return The index for <var>key</var>. If the key has already been added to the index, * the old index is returned; otherwise, a new index is generated and returned. */ public int internId(long key) { int idx = tryGetIndex(key); if (idx < 0) { idx = keyList.size(); keyList.add(key); indexMap.put(key, idx); } return idx; }
private void decompact() { assert compactImpl != null && fullImpl == null; fullImpl = new LongArrayList(compactImpl.elements().length); for (IntIterator iter = compactImpl.iterator(); iter.hasNext();) { final int value = iter.nextInt(); fullImpl.add(value); } compactImpl = null; }
private static Long2DoubleMap extractVector(Iterator<? extends Rating> ratings, IdExtractor dimension, int n) { LongArrayList ids = new LongArrayList(n > 0 ? n : LongArrayList.DEFAULT_INITIAL_CAPACITY); DoubleArrayList values = new DoubleArrayList(n > 0 ? n : DoubleArrayList.DEFAULT_INITIAL_CAPACITY); while (ratings.hasNext()) { Rating r = ratings.next(); assert ids.size() == values.size(); long id = dimension.getId(r); ids.add(id); values.add(r.getValue()); } ids.trim(); values.trim(); assert ids.elements().length == ids.size(); assert values.elements().length == values.size(); return Long2DoubleSortedArrayMap.wrapUnsorted(ids.elements(), values.elements()); }
/** * Compute the intersection of two sets. * * @param a The first set. * @param b The second set. * @return The elements present in both sets. */ public static LongSortedSet setIntersect(LongSet a, LongSet b) { if (a instanceof LongSortedSet && b instanceof LongSortedSet) { return setIntersect((LongSortedSet) a, (LongSortedSet) b); } else if (a.size() <= b.size()) { LongArrayList longs = new LongArrayList(Math.min(a.size(), b.size())); LongIterator iter = a.iterator(); while (iter.hasNext()) { long key = iter.nextLong(); if (b.contains(key)) { longs.add(key); } } return LongUtils.packedSet(longs); } else { return setIntersect(b, a); } }