private void addMarksForRow(Row row, List<CounterMark> marks) { for (Cell cell : row.cells()) { if (cell.isCounterCell()) marks.add(new CounterMark(row, cell.column(), cell.path())); } }
private void updateWithCurrentValuesFromCache(List<PartitionUpdate.CounterMark> marks, ColumnFamilyStore cfs) { Iterator<PartitionUpdate.CounterMark> iter = marks.iterator(); while (iter.hasNext()) { PartitionUpdate.CounterMark mark = iter.next(); ClockAndCount cached = cfs.getCachedCounter(key().getKey(), mark.clustering(), mark.column(), mark.path()); if (cached != null) { updateWithCurrentValue(mark, cached, cfs); iter.remove(); } } }
private void updateWithCurrentValuesFromCFS(List<PartitionUpdate.CounterMark> marks, ColumnFamilyStore cfs) { ColumnFilter.Builder builder = ColumnFilter.selectionBuilder(); BTreeSet.Builder<Clustering> names = BTreeSet.builder(cfs.metadata.comparator); for (PartitionUpdate.CounterMark mark : marks) { if (mark.clustering() != Clustering.STATIC_CLUSTERING) names.add(mark.clustering()); if (mark.path() == null) builder.add(mark.column()); else builder.select(mark.column(), mark.path()); } int nowInSec = FBUtilities.nowInSeconds(); ClusteringIndexNamesFilter filter = new ClusteringIndexNamesFilter(names.build(), false); SinglePartitionReadCommand cmd = SinglePartitionReadCommand.create(cfs.metadata, nowInSec, key(), builder.build(), filter); PeekingIterator<PartitionUpdate.CounterMark> markIter = Iterators.peekingIterator(marks.iterator()); try (ReadExecutionController controller = cmd.executionController(); RowIterator partition = UnfilteredRowIterators.filter(cmd.queryMemtableAndDisk(cfs, controller), nowInSec)) { updateForRow(markIter, partition.staticRow(), cfs); while (partition.hasNext()) { if (!markIter.hasNext()) return; updateForRow(markIter, partition.next(), cfs); } } }
private void updateWithCurrentValuesFromCFS(List<PartitionUpdate.CounterMark> marks, ColumnFamilyStore cfs) { ColumnFilter.Builder builder = ColumnFilter.selectionBuilder(); BTreeSet.Builder<Clustering> names = BTreeSet.builder(cfs.metadata.comparator); for (PartitionUpdate.CounterMark mark : marks) { if (mark.clustering() != Clustering.STATIC_CLUSTERING) names.add(mark.clustering()); if (mark.path() == null) builder.add(mark.column()); else builder.select(mark.column(), mark.path()); } int nowInSec = FBUtilities.nowInSeconds(); ClusteringIndexNamesFilter filter = new ClusteringIndexNamesFilter(names.build(), false); SinglePartitionReadCommand cmd = SinglePartitionReadCommand.create(cfs.metadata, nowInSec, key(), builder.build(), filter); PeekingIterator<PartitionUpdate.CounterMark> markIter = Iterators.peekingIterator(marks.iterator()); try (ReadExecutionController controller = cmd.executionController(); RowIterator partition = UnfilteredRowIterators.filter(cmd.queryMemtableAndDisk(cfs, controller), nowInSec)) { updateForRow(markIter, partition.staticRow(), cfs); while (partition.hasNext()) { if (!markIter.hasNext()) return; updateForRow(markIter, partition.next(), cfs); } } }
private void updateWithCurrentValuesFromCFS(List<PartitionUpdate.CounterMark> marks, ColumnFamilyStore cfs) { ColumnFilter.Builder builder = ColumnFilter.selectionBuilder(); BTreeSet.Builder<Clustering> names = BTreeSet.builder(cfs.metadata.comparator); for (PartitionUpdate.CounterMark mark : marks) { if (mark.clustering() != Clustering.STATIC_CLUSTERING) names.add(mark.clustering()); if (mark.path() == null) builder.add(mark.column()); else builder.select(mark.column(), mark.path()); } int nowInSec = FBUtilities.nowInSeconds(); ClusteringIndexNamesFilter filter = new ClusteringIndexNamesFilter(names.build(), false); SinglePartitionReadCommand cmd = SinglePartitionReadCommand.create(cfs.metadata, nowInSec, key(), builder.build(), filter); PeekingIterator<PartitionUpdate.CounterMark> markIter = Iterators.peekingIterator(marks.iterator()); try (ReadExecutionController controller = cmd.executionController(); RowIterator partition = UnfilteredRowIterators.filter(cmd.queryMemtableAndDisk(cfs, controller), nowInSec)) { updateForRow(markIter, partition.staticRow(), cfs); while (partition.hasNext()) { if (!markIter.hasNext()) return; updateForRow(markIter, partition.next(), cfs); } } }
private void updateForRow(PeekingIterator<PartitionUpdate.CounterMark> markIter, Row row, ColumnFamilyStore cfs) { int cmp = 0; // If the mark is before the row, we have no value for this mark, just consume it while (markIter.hasNext() && (cmp = compare(markIter.peek().clustering(), row.clustering(), cfs)) < 0) markIter.next(); if (!markIter.hasNext()) return; while (cmp == 0) { PartitionUpdate.CounterMark mark = markIter.next(); Cell cell = mark.path() == null ? row.getCell(mark.column()) : row.getCell(mark.column(), mark.path()); if (cell != null) { updateWithCurrentValue(mark, CounterContext.instance().getLocalClockAndCount(cell.value()), cfs); markIter.remove(); } if (!markIter.hasNext()) return; cmp = compare(markIter.peek().clustering(), row.clustering(), cfs); } }
private void updateForRow(PeekingIterator<PartitionUpdate.CounterMark> markIter, Row row, ColumnFamilyStore cfs) { int cmp = 0; // If the mark is before the row, we have no value for this mark, just consume it while (markIter.hasNext() && (cmp = compare(markIter.peek().clustering(), row.clustering(), cfs)) < 0) markIter.next(); if (!markIter.hasNext()) return; while (cmp == 0) { PartitionUpdate.CounterMark mark = markIter.next(); Cell cell = mark.path() == null ? row.getCell(mark.column()) : row.getCell(mark.column(), mark.path()); if (cell != null) { updateWithCurrentValue(mark, CounterContext.instance().getLocalClockAndCount(cell.value()), cfs); markIter.remove(); } if (!markIter.hasNext()) return; cmp = compare(markIter.peek().clustering(), row.clustering(), cfs); } }
private void updateForRow(PeekingIterator<PartitionUpdate.CounterMark> markIter, Row row, ColumnFamilyStore cfs) { int cmp = 0; // If the mark is before the row, we have no value for this mark, just consume it while (markIter.hasNext() && (cmp = compare(markIter.peek().clustering(), row.clustering(), cfs)) < 0) markIter.next(); if (!markIter.hasNext()) return; while (cmp == 0) { PartitionUpdate.CounterMark mark = markIter.next(); Cell cell = mark.path() == null ? row.getCell(mark.column()) : row.getCell(mark.column(), mark.path()); if (cell != null) { updateWithCurrentValue(mark, CounterContext.instance().getLocalClockAndCount(cell.value()), cfs); markIter.remove(); } if (!markIter.hasNext()) return; cmp = compare(markIter.peek().clustering(), row.clustering(), cfs); } }
private void updateWithCurrentValuesFromCache(List<PartitionUpdate.CounterMark> marks, ColumnFamilyStore cfs) { Iterator<PartitionUpdate.CounterMark> iter = marks.iterator(); while (iter.hasNext()) { PartitionUpdate.CounterMark mark = iter.next(); ClockAndCount cached = cfs.getCachedCounter(key().getKey(), mark.clustering(), mark.column(), mark.path()); if (cached != null) { updateWithCurrentValue(mark, cached, cfs); iter.remove(); } } }
private void updateWithCurrentValuesFromCache(List<PartitionUpdate.CounterMark> marks, ColumnFamilyStore cfs) { Iterator<PartitionUpdate.CounterMark> iter = marks.iterator(); while (iter.hasNext()) { PartitionUpdate.CounterMark mark = iter.next(); ClockAndCount cached = cfs.getCachedCounter(key().getKey(), mark.clustering(), mark.column(), mark.path()); if (cached != null) { updateWithCurrentValue(mark, cached, cfs); iter.remove(); } } }
private void addMarksForRow(Row row, List<CounterMark> marks) { for (Cell cell : row.cells()) { if (cell.isCounterCell()) marks.add(new CounterMark(row, cell.column(), cell.path())); } }
private void addMarksForRow(Row row, List<CounterMark> marks) { for (Cell cell : row.cells()) { if (cell.isCounterCell()) marks.add(new CounterMark(row, cell.column(), cell.path())); } }
private void updateWithCurrentValue(PartitionUpdate.CounterMark mark, ClockAndCount currentValue, ColumnFamilyStore cfs) { long clock = Math.max(FBUtilities.timestampMicros(), currentValue.clock + 1L); long count = currentValue.count + CounterContext.instance().total(mark.value()); mark.setValue(CounterContext.instance().createGlobal(CounterId.getLocalId(), clock, count)); // Cache the newly updated value cfs.putCachedCounter(key().getKey(), mark.clustering(), mark.column(), mark.path(), ClockAndCount.create(clock, count)); }
private void updateWithCurrentValue(PartitionUpdate.CounterMark mark, ClockAndCount currentValue, ColumnFamilyStore cfs) { long clock = Math.max(FBUtilities.timestampMicros(), currentValue.clock + 1L); long count = currentValue.count + CounterContext.instance().total(mark.value()); mark.setValue(CounterContext.instance().createGlobal(CounterId.getLocalId(), clock, count)); // Cache the newly updated value cfs.putCachedCounter(key().getKey(), mark.clustering(), mark.column(), mark.path(), ClockAndCount.create(clock, count)); }
private void addMarksForRow(Row row, List<CounterMark> marks) { for (Cell cell : row.cells()) { if (cell.isCounterCell()) marks.add(new CounterMark(row, cell.column(), cell.path())); } }
private void updateWithCurrentValue(PartitionUpdate.CounterMark mark, ClockAndCount currentValue, ColumnFamilyStore cfs) { long clock = Math.max(FBUtilities.timestampMicros(), currentValue.clock + 1L); long count = currentValue.count + CounterContext.instance().total(mark.value()); mark.setValue(CounterContext.instance().createGlobal(CounterId.getLocalId(), clock, count)); // Cache the newly updated value cfs.putCachedCounter(key().getKey(), mark.clustering(), mark.column(), mark.path(), ClockAndCount.create(clock, count)); }