private ComplexColumnData transformAndFilter(DeletionTime newDeletion, Function<? super Cell, ? extends Cell> function) { Object[] transformed = BTree.transformAndFilter(cells, function); if (cells == transformed && newDeletion == complexDeletion) return this; if (newDeletion == DeletionTime.LIVE && BTree.isEmpty(transformed)) return null; return new ComplexColumnData(column, transformed, newDeletion); }
public ColumnDataReducer(int size, int nowInSec, boolean hasComplex) { this.nowInSec = nowInSec; this.versions = new ArrayList<>(size); this.complexBuilder = hasComplex ? ComplexColumnData.builder() : null; this.complexCells = hasComplex ? new ArrayList<>(size) : null; this.cellReducer = new CellReducer(nowInSec); }
private long sizeOfComplexColumn(ComplexColumnData data, ColumnDefinition column, boolean hasComplexDeletion, LivenessInfo rowLiveness, SerializationHeader header) { long size = 0; if (hasComplexDeletion) size += header.deletionTimeSerializedSize(data.complexDeletion()); size += TypeSizes.sizeofUnsignedVInt(data.cellsCount()); for (Cell cell : data) size += Cell.serializer.serializedSize(cell, column, rowLiveness, header); return size; }
private Iterator<Cell> makeComplexIterator(Object complexData) { ComplexColumnData ccd = (ComplexColumnData)complexData; return reversed ? ccd.reverseIterator() : ccd.iterator(); }
@Override public int hashCode() { return Objects.hash(column(), complexDeletion(), cells); }
if (cd.complexDeletion().supersedes(complexDeletion)) complexDeletion = cd.complexDeletion(); complexCells.add(cd.iterator());
collector.update(complexData.complexDeletion()); if (complexData.hasCells())
private static Iterator<Cell> getCells(Row row, ColumnDefinition column) { // If we're asking for a complex cells, and we didn't got any row from our read, it's // the same as not having any cells for that column. if (row == null) return Collections.<Cell>emptyIterator(); ComplexColumnData complexData = row.getComplexColumnData(column); return complexData == null ? Collections.<Cell>emptyIterator() : complexData.iterator(); }
private static int minDeletionTime(ComplexColumnData cd) { int min = minDeletionTime(cd.complexDeletion()); for (Cell cell : cd) { min = Math.min(min, minDeletionTime(cell)); if (min == Integer.MIN_VALUE) break; } return min; }
public void execute(DecoratedKey partitionKey, UpdateParameters params) throws InvalidRequestException { assert column.type.isMultiCell() : "Attempted to delete an item by index from a frozen list"; Term.Terminal index = t.bind(params.options); if (index == null) throw new InvalidRequestException("Invalid null value for list index"); if (index == Constants.UNSET_VALUE) return; Row existingRow = params.getPrefetchedRow(partitionKey, params.currentClustering()); int existingSize = existingSize(existingRow, column); int idx = ByteBufferUtil.toInt(index.get(params.options.getProtocolVersion())); if (existingSize == 0) throw new InvalidRequestException("Attempted to delete an element from a list which is null"); if (idx < 0 || idx >= existingSize) throw new InvalidRequestException(String.format("List index %d out of bound, list has size %d", idx, existingSize)); params.addTombstone(column, existingRow.getComplexColumnData(column).getCellByIndex(idx).path()); } }
public Cell getCell(ColumnDefinition c, CellPath path) { assert c.isComplex(); ComplexColumnData cd = getComplexColumnData(c); if (cd == null) return null; return cd.getCell(path); }
private static int existingSize(Row row, ColumnDefinition column) { if (row == null) return 0; ComplexColumnData complexData = row.getComplexColumnData(column); return complexData == null ? 0 : complexData.cellsCount(); }
return ((ComplexColumnData) cd).filter(filter, mayHaveShadowed ? activeDeletion : DeletionTime.LIVE, dropped, rowLiveness);
@Override public int hashCode() { return Objects.hash(column(), complexDeletion(), BTree.hashCode(cells)); }
if (cd.complexDeletion().supersedes(complexDeletion)) complexDeletion = cd.complexDeletion(); complexCells.add(cd.iterator());
private Iterator<Cell> makeComplexIterator(Object complexData) { ComplexColumnData ccd = (ComplexColumnData)complexData; return reversed ? ccd.reverseIterator() : ccd.iterator(); }
collector.update(complexData.complexDeletion()); if (complexData.hasCells())
private static Iterator<Cell> getCells(Row row, ColumnDefinition column) { // If we're asking for a complex cells, and we didn't got any row from our read, it's // the same as not having any cells for that column. if (row == null) return Collections.<Cell>emptyIterator(); ComplexColumnData complexData = row.getComplexColumnData(column); return complexData == null ? Collections.<Cell>emptyIterator() : complexData.iterator(); }
private static int minDeletionTime(ComplexColumnData cd) { int min = minDeletionTime(cd.complexDeletion()); for (Cell cell : cd) { min = Math.min(min, minDeletionTime(cell)); if (min == Integer.MIN_VALUE) break; } return min; }
public void execute(DecoratedKey partitionKey, UpdateParameters params) throws InvalidRequestException { assert column.type.isMultiCell() : "Attempted to delete an item by index from a frozen list"; Term.Terminal index = t.bind(params.options); if (index == null) throw new InvalidRequestException("Invalid null value for list index"); if (index == Constants.UNSET_VALUE) return; Row existingRow = params.getPrefetchedRow(partitionKey, params.currentClustering()); int existingSize = existingSize(existingRow, column); int idx = ByteBufferUtil.toInt(index.get(params.options.getProtocolVersion())); if (existingSize == 0) throw new InvalidRequestException("Attempted to delete an element from a list which is null"); if (idx < 0 || idx >= existingSize) throw new InvalidRequestException(String.format("List index %d out of bound, list has size %d", idx, existingSize)); params.addTombstone(column, existingRow.getComplexColumnData(column).getCellByIndex(idx).path()); } }