/** * Similar to bounds(), but returns one ByteBuffer per-component in the bound instead of a single * ByteBuffer to represent the entire bound. * @param b the bound type * @param options the query options * @return one ByteBuffer per-component in the bound */ private List<ByteBuffer> componentBounds(Bound b, QueryOptions options) { if (!slice.hasBound(b)) return Collections.emptyList(); Terminal terminal = slice.bound(b).bind(options); if (terminal instanceof Tuples.Value) { return ((Tuples.Value) terminal).getElements(); } return Collections.singletonList(terminal.get(options.getProtocolVersion())); }
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 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()); } }
/** * Similar to bounds(), but returns one ByteBuffer per-component in the bound instead of a single * ByteBuffer to represent the entire bound. * @param b the bound type * @param options the query options * @return one ByteBuffer per-component in the bound */ private List<ByteBuffer> componentBounds(Bound b, QueryOptions options) { if (!slice.hasBound(b)) return Collections.emptyList(); Terminal terminal = slice.bound(b).bind(options); if (terminal instanceof Tuples.Value) { return ((Tuples.Value) terminal).getElements(); } return Collections.singletonList(terminal.get(options.getProtocolVersion())); }
static void doPut(Term.Terminal value, ColumnDefinition column, UpdateParameters params) throws InvalidRequestException { if (column.type.isMultiCell()) { if (value == null) return; Map<ByteBuffer, ByteBuffer> elements = ((Value) value).map; for (Map.Entry<ByteBuffer, ByteBuffer> entry : elements.entrySet()) params.addCell(column, CellPath.create(entry.getKey()), entry.getValue()); } else { // for frozen maps, we're overwriting the whole cell if (value == null) params.addTombstone(column); else params.addCell(column, value.get(ProtocolVersion.CURRENT)); } } }
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 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 void execute(ByteBuffer rowKey, ColumnFamily cf, Composite prefix, UpdateParameters params) throws InvalidRequestException { assert column.type.isMultiCell() : "Attempted to remove items from a frozen set"; Term.Terminal value = t.bind(params.options); if (value == null) return; // This can be either a set or a single element Set<ByteBuffer> toDiscard = value instanceof Sets.Value ? ((Sets.Value)value).elements : Collections.singleton(value.get(params.options)); for (ByteBuffer bb : toDiscard) { cf.addColumn(params.makeTombstone(cf.getComparator().create(prefix, column, bb))); } } }
/** * Similar to bounds(), but returns one ByteBuffer per-component in the bound instead of a single * ByteBuffer to represent the entire bound. * @param b the bound type * @param options the query options * @return one ByteBuffer per-component in the bound */ private List<ByteBuffer> componentBounds(Bound b, QueryOptions options) { if (!slice.hasBound(b)) return Collections.emptyList(); Terminal terminal = slice.bound(b).bind(options); if (terminal instanceof Tuples.Value) { return ((Tuples.Value) terminal).getElements(); } return Collections.singletonList(terminal.get(options.getProtocolVersion())); }
public void execute(ByteBuffer rowKey, ColumnFamily cf, Composite prefix, 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"); List<Cell> existingList = params.getPrefetchedList(rowKey, column.name); int idx = ByteBufferUtil.toInt(index.get(params.options)); if (existingList == null || existingList.size() == 0) throw new InvalidRequestException("Attempted to delete an element from a list which is null"); if (idx < 0 || idx >= existingList.size()) throw new InvalidRequestException(String.format("List index %d out of bound, list has size %d", idx, existingList.size())); CellName elementName = existingList.get(idx).name(); cf.addColumn(params.makeTombstone(elementName)); } }
public void execute(DecoratedKey partitionKey, UpdateParameters params) throws InvalidRequestException { // we should not get here for frozen UDTs assert column.type.isMultiCell() : "Attempted to set an individual field on a frozen UDT"; Term.Terminal value = t.bind(params.options); if (value == UNSET_VALUE) return; CellPath fieldPath = ((UserType) column.type).cellPathForField(field); if (value == null) params.addTombstone(column, fieldPath); else params.addCell(column, fieldPath, value.get(params.options.getProtocolVersion())); } }
public void execute(DecoratedKey partitionKey, UpdateParameters params) throws InvalidRequestException { assert column.type.isMultiCell() : "Attempted to remove items from a frozen set"; Term.Terminal value = t.bind(params.options); if (value == null || value == UNSET_VALUE) return; // This can be either a set or a single element Set<ByteBuffer> toDiscard = value instanceof Sets.Value ? ((Sets.Value)value).elements : Collections.singleton(value.get(params.options.getProtocolVersion())); for (ByteBuffer bb : toDiscard) params.addTombstone(column, CellPath.create(bb)); } }
public void execute(DecoratedKey partitionKey, UpdateParameters params) throws InvalidRequestException { assert column.type.isMultiCell() : "Attempted to remove items from a frozen set"; Term.Terminal value = t.bind(params.options); if (value == null || value == UNSET_VALUE) return; // This can be either a set or a single element Set<ByteBuffer> toDiscard = value instanceof Sets.Value ? ((Sets.Value)value).elements : Collections.singleton(value.get(params.options.getProtocolVersion())); for (ByteBuffer bb : toDiscard) params.addTombstone(column, CellPath.create(bb)); } }
public void execute(DecoratedKey partitionKey, UpdateParameters params) throws InvalidRequestException { assert column.type.isMultiCell() : "Attempted to remove items from a frozen set"; Term.Terminal value = t.bind(params.options); if (value == null || value == UNSET_VALUE) return; // This can be either a set or a single element Set<ByteBuffer> toDiscard = value instanceof Sets.Value ? ((Sets.Value)value).elements : Collections.singleton(value.get(params.options.getProtocolVersion())); for (ByteBuffer bb : toDiscard) params.addTombstone(column, CellPath.create(bb)); } }
public void execute(DecoratedKey partitionKey, UpdateParameters params) throws InvalidRequestException { // we should not get here for frozen UDTs assert column.type.isMultiCell() : "Attempted to set an individual field on a frozen UDT"; Term.Terminal value = t.bind(params.options); if (value == UNSET_VALUE) return; CellPath fieldPath = ((UserType) column.type).cellPathForField(field); if (value == null) params.addTombstone(column, fieldPath); else params.addCell(column, fieldPath, value.get(params.options.getProtocolVersion())); } }
public void execute(DecoratedKey partitionKey, UpdateParameters params) throws InvalidRequestException { assert column.type.isMultiCell() : "Attempted to remove items from a frozen set"; Term.Terminal value = t.bind(params.options); if (value == null || value == UNSET_VALUE) return; // This can be either a set or a single element Set<ByteBuffer> toDiscard = value instanceof Sets.Value ? ((Sets.Value)value).elements : Collections.singleton(value.get(params.options.getProtocolVersion())); for (ByteBuffer bb : toDiscard) params.addTombstone(column, CellPath.create(bb)); } }
public void execute(DecoratedKey partitionKey, UpdateParameters params) throws InvalidRequestException { // we should not get here for frozen UDTs assert column.type.isMultiCell() : "Attempted to set an individual field on a frozen UDT"; Term.Terminal value = t.bind(params.options); if (value == UNSET_VALUE) return; CellPath fieldPath = ((UserType) column.type).cellPathForField(field); if (value == null) params.addTombstone(column, fieldPath); else params.addCell(column, fieldPath, value.get(params.options.getProtocolVersion())); } }
public void execute(DecoratedKey partitionKey, UpdateParameters params) throws InvalidRequestException { // we should not get here for frozen UDTs assert column.type.isMultiCell() : "Attempted to set an individual field on a frozen UDT"; Term.Terminal value = t.bind(params.options); if (value == UNSET_VALUE) return; CellPath fieldPath = ((UserType) column.type).cellPathForField(field); if (value == null) params.addTombstone(column, fieldPath); else params.addCell(column, fieldPath, value.get(params.options.getProtocolVersion())); } }
public ByteBuffer bindAndGet(QueryOptions options) throws InvalidRequestException { return get(options.getProtocolVersion()); } }
public void execute(ByteBuffer rowKey, ColumnFamily cf, Composite prefix, UpdateParameters params) throws InvalidRequestException { assert column.type.isMultiCell() : "Attempted to delete a single key in a frozen map"; Term.Terminal key = t.bind(params.options); if (key == null) throw new InvalidRequestException("Invalid null map key"); CellName cellName = cf.getComparator().create(prefix, column, key.get(params.options)); cf.addColumn(params.makeTombstone(cellName)); } }