Refine search
/** * {@inheritDoc} */ @Override public <N> Mutator<K> addDeletion(K key, String cf, N columnName, Serializer<N> nameSerializer, long clock) { Deletion d; if ( columnName != null ) { SlicePredicate sp = new SlicePredicate(); sp.addToColumn_names(nameSerializer.toByteBuffer(columnName)); d = new Deletion().setTimestamp(clock).setPredicate(sp); } else { d = new Deletion().setTimestamp(clock); } getPendingMutations().addDeletion(key, Arrays.asList(cf), d); return this; }
@Test public void getSizeForMutationWithDeletionContainingSuperColumn() { long nonEmptyDeletionSize = Long.BYTES + TEST_NAME.getBytes().length + NULL_SIZE; assertThat(ThriftObjectSizeUtils.getMutationSize(new Mutation() .setDeletion(new Deletion().setSuper_column(TEST_NAME.getBytes())))) .isEqualTo(NULL_SIZE + nonEmptyDeletionSize); }
private static long getDeletionSize(Deletion deletion) { if (deletion == null) { return getNullSize(); } return getTimestampSize() + getByteArraySize(deletion.getSuper_column()) + getSlicePredicateSize(deletion.getPredicate()); }
Deletion d = new Deletion(); SlicePredicate sp = new SlicePredicate(); sp.addToColumn_names(buf.as(StaticBuffer.BB_FACTORY)); d.setPredicate(sp); d.setTimestamp(commitTime.getDeletionTime(times)); org.apache.cassandra.thrift.Mutation m = new org.apache.cassandra.thrift.Mutation(); m.setDeletion(d); thriftMutation.add(m); org.apache.cassandra.thrift.Mutation m = new org.apache.cassandra.thrift.Mutation(); m.setColumn_or_supercolumn(cosc); thriftMutation.add(m);
public static Mutation rangeTombstoneForColumn( byte[] columnName, long maxAtlasTimestampExclusive, long timestampForRangeTombstone) { Deletion deletion = new Deletion() .setTimestamp(timestampForRangeTombstone) .setPredicate(SlicePredicates.rangeTombstoneForColumn(columnName, maxAtlasTimestampExclusive)); return new Mutation().setDeletion(deletion); }
cellVersions.getKey().getColumnName(), ts); SlicePredicate pred = new SlicePredicate(); pred.setColumn_names(Collections.singletonList(colName)); Deletion del = new Deletion(); del.setPredicate(pred); del.setTimestamp(deleteTimestampGetter.applyAsLong(ts)); Mutation mutation = new Mutation(); mutation.setDeletion(del);
@Override public ColumnListMutation<C> deleteColumn(C columnName) { Preconditions.checkNotNull(columnName, "Column name cannot be null"); // Create a reusable predicate for deleting columns and insert only once if (null == lastDeletion || lastDeletion.getTimestamp() != timestamp) { lastDeletion = new Deletion().setPredicate(new SlicePredicate()).setTimestamp(timestamp); mutationList.add(new Mutation().setDeletion(lastDeletion)); } ByteBuffer bb = this.columnSerializer.toByteBuffer(columnName); if (!bb.hasRemaining()) { throw new RuntimeException("Column name cannot be empty"); } lastDeletion.getPredicate().addToColumn_names(bb); return this; }
/** * {@inheritDoc} */ @Override public <N> Mutator<K> addDeletion(K key, String cf, N columnNameStart, N columnNameFinish, Serializer<N> nameSerializer, long clock) { SlicePredicate sp = new SlicePredicate(); sp.setSlice_range(new SliceRange(nameSerializer.toByteBuffer(columnNameStart), nameSerializer.toByteBuffer(columnNameFinish), false, Integer.MAX_VALUE)); Deletion d = new Deletion().setTimestamp(clock).setPredicate(sp); getPendingMutations().addDeletion(key, Arrays.asList(cf), d); return this; }
@Test public void getSizeForMutationWithColumnOrSuperColumnAndDeletion() { long emptyDeletionSize = Long.BYTES + 2 * NULL_SIZE; assertThat(ThriftObjectSizeUtils.getMutationSize(new Mutation() .setColumn_or_supercolumn(EMPTY_COLUMN_OR_SUPERCOLUMN) .setDeletion(new Deletion()))) .isEqualTo(EMPTY_COLUMN_OR_SUPERCOLUMN_SIZE + emptyDeletionSize); }
/** compose Cassandra mutation from tuple */ private Mutation mutationFromTuple(Tuple t) throws IOException { Mutation mutation = new Mutation(); if (t.get(1) == null) { if (allow_deletes) { mutation.deletion = new Deletion(); mutation.deletion.predicate = new org.apache.cassandra.thrift.SlicePredicate(); mutation.deletion.predicate.column_names = Arrays.asList(objToBB(t.get(0))); mutation.deletion.setTimestamp(FBUtilities.timestampMicros()); } else throw new IOException("null found but deletes are disabled, set " + PIG_ALLOW_DELETES + "=true in environment or allow_deletes=true in URL to enable"); } else { org.apache.cassandra.thrift.Column column = new org.apache.cassandra.thrift.Column(); column.setName(objToBB(t.get(0))); column.setValue(objToBB(t.get(1))); column.setTimestamp(FBUtilities.timestampMicros()); mutation.column_or_supercolumn = new ColumnOrSuperColumn(); mutation.column_or_supercolumn.column = column; } return mutation; }
@Override public <SN> Mutator<K> addSuperDelete(K key, String cf, SN sColumnName, Serializer<SN> sNameSerializer) { Deletion d = new Deletion().setTimestamp(keyspace.createClock()); d.setSuper_column(sNameSerializer.toByteBuffer(sColumnName)); getPendingMutations().addDeletion(key, Arrays.asList(cf), d); return this; }
@Test public void getSizeForMutationWithEmptyDeletion() { long emptyDeletionSize = Long.BYTES + 2 * NULL_SIZE; assertThat(ThriftObjectSizeUtils.getMutationSize(new Mutation() .setDeletion(new Deletion()))) .isEqualTo(NULL_SIZE + emptyDeletionSize); }
public void setFieldValue(_Fields field, Object value) { switch (field) { case TIMESTAMP: if (value == null) { unsetTimestamp(); } else { setTimestamp((Long)value); } break; case SUPER_COLUMN: if (value == null) { unsetSuper_column(); } else { setSuper_column((ByteBuffer)value); } break; case PREDICATE: if (value == null) { unsetPredicate(); } else { setPredicate((SlicePredicate)value); } break; } }
for (Mutation mutation : mutationList) { if (mutation.isSetDeletion()) { Deletion deletion = mutation.getDeletion(); SlicePredicate predicate = deletion.getPredicate(); if (predicate.isSetColumn_names()) { List<ByteBuffer> colNames = predicate.getColumn_names(); StringBuilder buffer = new StringBuilder(); for (ByteBuffer colName : colNames) { SliceRange sliceRange = predicate.getSlice_range(); logger.trace(" Deleted: {} to {}", Utils.deWhite(sliceRange.getStart()), ColumnOrSuperColumn cosc = mutation.getColumn_or_supercolumn(); if (cosc.isSetCounter_column()) {
@Override public void read(org.apache.thrift.protocol.TProtocol prot, Mutation struct) throws org.apache.thrift.TException { TTupleProtocol iprot = (TTupleProtocol) prot; BitSet incoming = iprot.readBitSet(2); if (incoming.get(0)) { struct.column_or_supercolumn = new ColumnOrSuperColumn(); struct.column_or_supercolumn.read(iprot); struct.setColumn_or_supercolumnIsSet(true); } if (incoming.get(1)) { struct.deletion = new Deletion(); struct.deletion.read(iprot); struct.setDeletionIsSet(true); } } }
@Override public void write(org.apache.thrift.protocol.TProtocol prot, Deletion struct) throws org.apache.thrift.TException { TTupleProtocol oprot = (TTupleProtocol) prot; BitSet optionals = new BitSet(); if (struct.isSetTimestamp()) { optionals.set(0); } if (struct.isSetSuper_column()) { optionals.set(1); } if (struct.isSetPredicate()) { optionals.set(2); } oprot.writeBitSet(optionals, 3); if (struct.isSetTimestamp()) { oprot.writeI64(struct.timestamp); } if (struct.isSetSuper_column()) { oprot.writeBinary(struct.super_column); } if (struct.isSetPredicate()) { struct.predicate.write(oprot); } }
/** * Performs a deep copy on <i>other</i>. */ public Mutation(Mutation other) { if (other.isSetColumn_or_supercolumn()) { this.column_or_supercolumn = new ColumnOrSuperColumn(other.column_or_supercolumn); } if (other.isSetDeletion()) { this.deletion = new Deletion(other.deletion); } }
/** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ public boolean isSet(_Fields field) { if (field == null) { throw new IllegalArgumentException(); } switch (field) { case TIMESTAMP: return isSetTimestamp(); case SUPER_COLUMN: return isSetSuper_column(); case PREDICATE: return isSetPredicate(); } throw new IllegalStateException(); }
public Object getFieldValue(_Fields field) { switch (field) { case TIMESTAMP: return Long.valueOf(getTimestamp()); case SUPER_COLUMN: return getSuper_column(); case PREDICATE: return getPredicate(); } throw new IllegalStateException(); }
public boolean equals(Deletion that) { if (that == null) return false; boolean this_present_timestamp = true && this.isSetTimestamp(); boolean that_present_timestamp = true && that.isSetTimestamp(); if (this_present_timestamp || that_present_timestamp) { if (!(this_present_timestamp && that_present_timestamp)) return false; if (this.timestamp != that.timestamp) return false; } boolean this_present_super_column = true && this.isSetSuper_column(); boolean that_present_super_column = true && that.isSetSuper_column(); if (this_present_super_column || that_present_super_column) { if (!(this_present_super_column && that_present_super_column)) return false; if (!this.super_column.equals(that.super_column)) return false; } boolean this_present_predicate = true && this.isSetPredicate(); boolean that_present_predicate = true && that.isSetPredicate(); if (this_present_predicate || that_present_predicate) { if (!(this_present_predicate && that_present_predicate)) return false; if (!this.predicate.equals(that.predicate)) return false; } return true; }