private BTree.Builder<Row> builder(int initialCapacity) { return BTree.<Row>builder(metadata.comparator, initialCapacity) .setQuickResolver((a, b) -> Rows.merge(a, b, createdAtInSec)); }
private BTree.Builder<Row> builder(int initialCapacity) { return BTree.<Row>builder(metadata.comparator, initialCapacity) .setQuickResolver((a, b) -> Rows.merge(a, b, createdAtInSec)); }
public static Row merge(Row row1, Row row2, int nowInSec) { Row.Builder builder = BTreeRow.sortedBuilder(); merge(row1, row2, builder, nowInSec); return builder.build(); }
public static Row merge(Row row1, Row row2, int nowInSec) { Row.Builder builder = BTreeRow.sortedBuilder(); merge(row1, row2, builder, nowInSec); return builder.build(); }
private BTree.Builder<Row> builder(int initialCapacity) { return BTree.<Row>builder(metadata.comparator, initialCapacity) .setQuickResolver((a, b) -> Rows.merge(a, b, createdAtInSec)); }
private BTree.Builder<Row> builder(int initialCapacity) { return BTree.<Row>builder(metadata.comparator, initialCapacity) .setQuickResolver((a, b) -> Rows.merge(a, b, createdAtInSec)); }
public static Row merge(Row row1, Row row2, int nowInSec) { Row.Builder builder = BTreeRow.sortedBuilder(); merge(row1, row2, builder, nowInSec); return builder.build(); }
public static Row merge(Row row1, Row row2, int nowInSec) { Row.Builder builder = BTreeRow.sortedBuilder(); merge(row1, row2, builder, nowInSec); return builder.build(); }
/** * Given an existing base row and the update that we're going to apply to this row, generate the modifications * to apply to MVs using the provided {@code ViewUpdateGenerator}s. * * @param existingBaseRow the base table row as it is before an update. * @param updateBaseRow the newly updates made to {@code existingBaseRow}. * @param generators the view update generators to add the new changes to. * @param nowInSec the current time in seconds. Used to decide if data is live or not. */ private static void addToViewUpdateGenerators(Row existingBaseRow, Row updateBaseRow, Collection<ViewUpdateGenerator> generators, int nowInSec) { // Having existing empty is useful, it just means we'll insert a brand new entry for updateBaseRow, // but if we have no update at all, we shouldn't get there. assert !updateBaseRow.isEmpty(); // We allow existingBaseRow to be null, which we treat the same as being empty as an small optimization // to avoid allocating empty row objects when we know there was nothing existing. Row mergedBaseRow = existingBaseRow == null ? updateBaseRow : Rows.merge(existingBaseRow, updateBaseRow, nowInSec); for (ViewUpdateGenerator generator : generators) generator.addBaseTableUpdate(existingBaseRow, mergedBaseRow); }
/** * Given an existing base row and the update that we're going to apply to this row, generate the modifications * to apply to MVs using the provided {@code ViewUpdateGenerator}s. * * @param existingBaseRow the base table row as it is before an update. * @param updateBaseRow the newly updates made to {@code existingBaseRow}. * @param generators the view update generators to add the new changes to. * @param nowInSec the current time in seconds. Used to decide if data is live or not. */ private static void addToViewUpdateGenerators(Row existingBaseRow, Row updateBaseRow, Collection<ViewUpdateGenerator> generators, int nowInSec) { // Having existing empty is useful, it just means we'll insert a brand new entry for updateBaseRow, // but if we have no update at all, we shouldn't get there. assert !updateBaseRow.isEmpty(); // We allow existingBaseRow to be null, which we treat the same as being empty as an small optimization // to avoid allocating empty row objects when we know there was nothing existing. Row mergedBaseRow = existingBaseRow == null ? updateBaseRow : Rows.merge(existingBaseRow, updateBaseRow, nowInSec); for (ViewUpdateGenerator generator : generators) generator.addBaseTableUpdate(existingBaseRow, mergedBaseRow); }
/** * Given an existing base row and the update that we're going to apply to this row, generate the modifications * to apply to MVs using the provided {@code ViewUpdateGenerator}s. * * @param existingBaseRow the base table row as it is before an update. * @param updateBaseRow the newly updates made to {@code existingBaseRow}. * @param generators the view update generators to add the new changes to. * @param nowInSec the current time in seconds. Used to decide if data is live or not. */ private static void addToViewUpdateGenerators(Row existingBaseRow, Row updateBaseRow, Collection<ViewUpdateGenerator> generators, int nowInSec) { // Having existing empty is useful, it just means we'll insert a brand new entry for updateBaseRow, // but if we have no update at all, we shouldn't get there. assert !updateBaseRow.isEmpty(); // We allow existingBaseRow to be null, which we treat the same as being empty as an small optimization // to avoid allocating empty row objects when we know there was nothing existing. Row mergedBaseRow = existingBaseRow == null ? updateBaseRow : Rows.merge(existingBaseRow, updateBaseRow, nowInSec); for (ViewUpdateGenerator generator : generators) generator.addBaseTableUpdate(existingBaseRow, mergedBaseRow); }
public Row apply(Row existing, Row update) { Row.Builder builder = builder(existing.clustering()); colUpdateTimeDelta = Math.min(colUpdateTimeDelta, Rows.merge(existing, update, builder, nowInSec)); Row reconciled = builder.build(); indexer.onUpdated(existing, reconciled); dataSize += reconciled.dataSize() - existing.dataSize(); heapSize += reconciled.unsharedHeapSizeExcludingData() - existing.unsharedHeapSizeExcludingData(); if (inserted == null) inserted = new ArrayList<>(); inserted.add(reconciled); return reconciled; }
public Row apply(Row existing, Row update) { Row.Builder builder = builder(existing.clustering()); colUpdateTimeDelta = Math.min(colUpdateTimeDelta, Rows.merge(existing, update, builder, nowInSec)); Row reconciled = builder.build(); indexer.onUpdated(existing, reconciled); dataSize += reconciled.dataSize() - existing.dataSize(); heapSize += reconciled.unsharedHeapSizeExcludingData() - existing.unsharedHeapSizeExcludingData(); if (inserted == null) inserted = new ArrayList<>(); inserted.add(reconciled); return reconciled; }
public Row apply(Row existing, Row update) { Row.Builder builder = builder(existing.clustering()); colUpdateTimeDelta = Math.min(colUpdateTimeDelta, Rows.merge(existing, update, builder, nowInSec)); Row reconciled = builder.build(); indexer.onUpdated(existing, reconciled); dataSize += reconciled.dataSize() - existing.dataSize(); heapSize += reconciled.unsharedHeapSizeExcludingData() - existing.unsharedHeapSizeExcludingData(); if (inserted == null) inserted = new ArrayList<>(); inserted.add(reconciled); return reconciled; }
public Row apply(Row existing, Row update) { Row.Builder builder = builder(existing.clustering()); colUpdateTimeDelta = Math.min(colUpdateTimeDelta, Rows.merge(existing, update, builder, nowInSec)); Row reconciled = builder.build(); indexer.onUpdated(existing, reconciled); dataSize += reconciled.dataSize() - existing.dataSize(); heapSize += reconciled.unsharedHeapSizeExcludingData() - existing.unsharedHeapSizeExcludingData(); if (inserted == null) inserted = new ArrayList<>(); inserted.add(reconciled); return reconciled; }
private synchronized void build() { if (isBuilt) return; Holder holder = this.holder; Object[] cur = holder.tree; Object[] add = rowBuilder.build(); Object[] merged = BTree.<Row>merge(cur, add, metadata.comparator, UpdateFunction.Simple.of((a, b) -> Rows.merge(a, b, createdAtInSec))); assert deletionInfo == holder.deletionInfo; EncodingStats newStats = EncodingStats.Collector.collect(holder.staticRow, BTree.<Row>iterator(merged), deletionInfo); this.holder = new Holder(holder.columns, merged, holder.deletionInfo, holder.staticRow, newStats); rowBuilder = null; isBuilt = true; }
private synchronized void build() { if (isBuilt) return; Holder holder = this.holder; Object[] cur = holder.tree; Object[] add = rowBuilder.build(); Object[] merged = BTree.<Row>merge(cur, add, metadata.comparator, UpdateFunction.Simple.of((a, b) -> Rows.merge(a, b, createdAtInSec))); assert deletionInfo == holder.deletionInfo; EncodingStats newStats = EncodingStats.Collector.collect(holder.staticRow, BTree.<Row>iterator(merged), deletionInfo); this.holder = new Holder(holder.columns, merged, holder.deletionInfo, holder.staticRow, newStats); rowBuilder = null; isBuilt = true; }
private synchronized void build() { if (isBuilt) return; Holder holder = this.holder; Object[] cur = holder.tree; Object[] add = rowBuilder.build(); Object[] merged = BTree.<Row>merge(cur, add, metadata.comparator, UpdateFunction.Simple.of((a, b) -> Rows.merge(a, b, createdAtInSec))); assert deletionInfo == holder.deletionInfo; EncodingStats newStats = EncodingStats.Collector.collect(holder.staticRow, BTree.<Row>iterator(merged), deletionInfo); this.holder = new Holder(holder.columns, merged, holder.deletionInfo, holder.staticRow, newStats); rowBuilder = null; isBuilt = true; }
private synchronized void build() { if (isBuilt) return; Holder holder = this.holder; Object[] cur = holder.tree; Object[] add = rowBuilder.build(); Object[] merged = BTree.<Row>merge(cur, add, metadata.comparator, UpdateFunction.Simple.of((a, b) -> Rows.merge(a, b, createdAtInSec))); assert deletionInfo == holder.deletionInfo; EncodingStats newStats = EncodingStats.Collector.collect(holder.staticRow, BTree.<Row>iterator(merged), deletionInfo); this.holder = new Holder(holder.columns, merged, holder.deletionInfo, holder.staticRow, newStats); rowBuilder = null; isBuilt = true; }
@Override public Unfiltered next() { Unfiltered next = nextToOffer != null ? nextToOffer : wrapped.next(); if (next.isRow()) { while (wrapped.hasNext()) { Unfiltered peek = wrapped.next(); if (!peek.isRow() || !next.clustering().equals(peek.clustering())) { nextToOffer = peek; // Offer peek in next call return next; } // Duplicate row, merge it. next = Rows.merge((Row) next, (Row) peek, FBUtilities.nowInSeconds()); } } nextToOffer = null; return next; } }