public Mutation deepCopy() { return new Mutation(this); }
/** * @return a List of Mutations for a row, with columnA having valueA * and columnB having valueB */ private static List<Mutation> getMutations() { List<Mutation> mutations = new ArrayList<>(2); mutations.add(new Mutation(false, columnAname, valueAname, true)); mutations.add(new Mutation(false, columnBname, valueBname, true)); return mutations; }
/** * Performs a deep copy on <i>other</i>. */ public BatchMutation(BatchMutation other) { if (other.isSetRow()) { this.row = org.apache.thrift.TBaseHelper.copyBinary(other.row); } if (other.isSetMutations()) { java.util.List<Mutation> __this__mutations = new java.util.ArrayList<Mutation>(other.mutations.size()); for (Mutation other_element : other.mutations) { __this__mutations.add(new Mutation(other_element)); } this.mutations = __this__mutations; } }
/** * @return a List of BatchMutations with the following effects: * (rowA, columnA): delete * (rowA, columnB): place valueC * (rowB, columnA): place valueC * (rowB, columnB): place valueD */ private static List<BatchMutation> getBatchMutations() { List<BatchMutation> batchMutations = new ArrayList<>(3); // Mutations to rowA. You can't mix delete and put anymore. List<Mutation> rowAmutations = new ArrayList<>(1); rowAmutations.add(new Mutation(true, columnAname, null, true)); batchMutations.add(new BatchMutation(rowAname, rowAmutations)); rowAmutations = new ArrayList<>(1); rowAmutations.add(new Mutation(false, columnBname, valueCname, true)); batchMutations.add(new BatchMutation(rowAname, rowAmutations)); // Mutations to rowB List<Mutation> rowBmutations = new ArrayList<>(2); rowBmutations.add(new Mutation(false, columnAname, valueCname, true)); rowBmutations.add(new Mutation(false, columnBname, valueDname, true)); batchMutations.add(new BatchMutation(rowBname, rowBmutations)); return batchMutations; }
for (int _i2 = 0; _i2 < _list0.size; ++_i2) _elem1 = new Mutation(); _elem1.read(iprot); struct.mutations.add(_elem1);
@Override public void read(org.apache.thrift.protocol.TProtocol prot, BatchMutation struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot; java.util.BitSet incoming = iprot.readBitSet(2); if (incoming.get(0)) { struct.row = iprot.readBinary(); struct.setRowIsSet(true); } if (incoming.get(1)) { { org.apache.thrift.protocol.TList _list5 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32()); struct.mutations = new java.util.ArrayList<Mutation>(_list5.size); @org.apache.thrift.annotation.Nullable Mutation _elem6; for (int _i7 = 0; _i7 < _list5.size; ++_i7) { _elem6 = new Mutation(); _elem6.read(iprot); struct.mutations.add(_elem6); } } struct.setMutationsIsSet(true); } } }
mutations.add(new Mutation(false, ByteBuffer.wrap(bytes("entry:foo")), ByteBuffer.wrap(invalid), writeToWal)); client.mutateRow(ByteBuffer.wrap(t), ByteBuffer.wrap(bytes("foo")), mutations.add(new Mutation(false, ByteBuffer.wrap(bytes("entry:foo")), ByteBuffer.wrap(valid), writeToWal)); client.mutateRow(ByteBuffer.wrap(t), ByteBuffer.wrap(valid), mutations, dummyAttributes); mutations.add(new Mutation(false, ByteBuffer.wrap(bytes("entry:foo")), ByteBuffer.wrap(invalid), writeToWal)); client.mutateRow(ByteBuffer.wrap(t), ByteBuffer.wrap(invalid), mutations, dummyAttributes); mutations.add(new Mutation(false, ByteBuffer.wrap(bytes("unused:")), ByteBuffer.wrap(bytes("DELETE_ME")), writeToWal)); client.mutateRow(ByteBuffer.wrap(t), ByteBuffer.wrap(row), mutations, dummyAttributes); printRow(client.getRow(ByteBuffer.wrap(t), ByteBuffer.wrap(row), dummyAttributes)); mutations.add(new Mutation(false, ByteBuffer.wrap(bytes("entry:num")), ByteBuffer.wrap(bytes("0")), writeToWal)); mutations.add(new Mutation(false, ByteBuffer.wrap(bytes("entry:foo")), ByteBuffer.wrap(bytes("FOO")), writeToWal)); client.mutateRow(ByteBuffer.wrap(t), ByteBuffer.wrap(row), mutations, dummyAttributes); printRow(client.getRow(ByteBuffer.wrap(t), ByteBuffer.wrap(row), dummyAttributes)); m = new Mutation(); m.column = ByteBuffer.wrap(bytes("entry:foo")); m.isDelete = true; mutations.add(m); m = new Mutation(); m.column = ByteBuffer.wrap(bytes("entry:num")); m.value = ByteBuffer.wrap(bytes("-1")); mutations.add(new Mutation(false, ByteBuffer.wrap(bytes("entry:num")), ByteBuffer.wrap(bytes(Integer.toString(i))), writeToWal)); mutations.add(new Mutation(false, ByteBuffer.wrap(bytes("entry:sqr")), ByteBuffer.wrap(bytes(Integer.toString(i * i))), writeToWal));
public static void doTestIncrements(ThriftHBaseServiceHandler handler) throws Exception { List<Mutation> mutations = new ArrayList<>(1); mutations.add(new Mutation(false, columnAAname, valueEname, true)); mutations.add(new Mutation(false, columnAname, valueEname, true)); handler.mutateRow(tableAname, rowAname, mutations, null); handler.mutateRow(tableAname, rowBname, mutations, null); List<TIncrement> increments = new ArrayList<>(3); increments.add(new TIncrement(tableAname, rowBname, columnAAname, 7)); increments.add(new TIncrement(tableAname, rowBname, columnAAname, 7)); increments.add(new TIncrement(tableAname, rowBname, columnAAname, 7)); int numIncrements = 60000; for (int i = 0; i < numIncrements; i++) { handler.increment(new TIncrement(tableAname, rowAname, columnAname, 2)); handler.incrementRows(increments); } Thread.sleep(1000); long lv = handler.get(tableAname, rowAname, columnAname, null).get(0).value.getLong(); // Wait on all increments being flushed while (handler.coalescer.getQueueSize() != 0) { Threads.sleep(10); } assertEquals((100 + (2 * numIncrements)), lv); lv = handler.get(tableAname, rowBname, columnAAname, null).get(0).value.getLong(); assertEquals((100 + (3 * 7 * numIncrements)), lv); assertTrue(handler.coalescer.getSuccessfulCoalescings() > 0); }
/** * Appends the value to a cell and checks that the cell value is updated properly. */ public static void doTestAppend() throws Exception { ThriftHBaseServiceHandler handler = new ThriftHBaseServiceHandler(UTIL.getConfiguration(), UserProvider.instantiate(UTIL.getConfiguration())); handler.createTable(tableAname, getColumnDescriptors()); try { List<Mutation> mutations = new ArrayList<>(1); mutations.add(new Mutation(false, columnAname, valueAname, true)); handler.mutateRow(tableAname, rowAname, mutations, null); List<ByteBuffer> columnList = new ArrayList<>(1); columnList.add(columnAname); List<ByteBuffer> valueList = new ArrayList<>(1); valueList.add(valueBname); TAppend append = new TAppend(tableAname, rowAname, columnList, valueList); handler.append(append); TRowResult rowResult = handler.getRow(tableAname, rowAname, null).get(0); assertEquals(rowAname, rowResult.row); assertArrayEquals(Bytes.add(valueAname.array(), valueBname.array()), rowResult.columns.get(columnAname).value.array()); } finally { handler.disableTable(tableAname); handler.deleteTable(tableAname); } }
public Mutation deepCopy() { return new Mutation(this); }
public Mutation deepCopy() { return new Mutation(this); }
/** * Check that checkAndPut fails if the cell does not exist, then put in the cell, then check that * the checkAndPut succeeds. */ public static void doTestCheckAndPut() throws Exception { ThriftHBaseServiceHandler handler = new ThriftHBaseServiceHandler(UTIL.getConfiguration(), UserProvider.instantiate(UTIL.getConfiguration())); handler.createTable(tableAname, getColumnDescriptors()); try { List<Mutation> mutations = new ArrayList<>(1); mutations.add(new Mutation(false, columnAname, valueAname, true)); Mutation putB = (new Mutation(false, columnBname, valueBname, true)); assertFalse(handler.checkAndPut(tableAname, rowAname, columnAname, valueAname, putB, null)); handler.mutateRow(tableAname, rowAname, mutations, null); assertTrue(handler.checkAndPut(tableAname, rowAname, columnAname, valueAname, putB, null)); TRowResult rowResult = handler.getRow(tableAname, rowAname, null).get(0); assertEquals(rowAname, rowResult.row); assertEquals(valueBname, rowResult.columns.get(columnBname).value); } finally { handler.disableTable(tableAname); handler.deleteTable(tableAname); } }
mutations.add(new Mutation(false, columnAname, null, true)); handler.mutateRow(tableAname, rowAname, mutations, null); TRowResult rowResult3 = handler.getRow(tableAname, rowAname, null).get(0);
rowBmutations.add(new Mutation(false, asByteBuffer("columnA:" + i), valueCname, true));
/** * Performs a deep copy on <i>other</i>. */ public BatchMutation(BatchMutation other) { if (other.isSetRow()) { this.row = other.row; } if (other.isSetMutations()) { List<Mutation> __this__mutations = new ArrayList<Mutation>(other.mutations.size()); for (Mutation other_element : other.mutations) { __this__mutations.add(new Mutation(other_element)); } this.mutations = __this__mutations; } }
/** * Performs a deep copy on <i>other</i>. */ public BatchMutation(BatchMutation other) { if (other.isSetRow()) { this.row = other.row; } if (other.isSetMutations()) { List<Mutation> __this__mutations = new ArrayList<Mutation>(other.mutations.size()); for (Mutation other_element : other.mutations) { __this__mutations.add(new Mutation(other_element)); } this.mutations = __this__mutations; } }
for (int _i2 = 0; _i2 < _list0.size; ++_i2) _elem1 = new Mutation(); _elem1.read(iprot); struct.mutations.add(_elem1);
for (int _i2 = 0; _i2 < _list0.size; ++_i2) _elem1 = new Mutation(); _elem1.read(iprot); struct.mutations.add(_elem1);
@Override public void read(org.apache.thrift.protocol.TProtocol prot, BatchMutation struct) throws org.apache.thrift.TException { TTupleProtocol iprot = (TTupleProtocol) prot; BitSet incoming = iprot.readBitSet(2); if (incoming.get(0)) { struct.row = iprot.readBinary(); struct.setRowIsSet(true); } if (incoming.get(1)) { { org.apache.thrift.protocol.TList _list5 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32()); struct.mutations = new ArrayList<Mutation>(_list5.size); Mutation _elem6; for (int _i7 = 0; _i7 < _list5.size; ++_i7) { _elem6 = new Mutation(); _elem6.read(iprot); struct.mutations.add(_elem6); } } struct.setMutationsIsSet(true); } } }
@Override public void read(org.apache.thrift.protocol.TProtocol prot, BatchMutation struct) throws org.apache.thrift.TException { TTupleProtocol iprot = (TTupleProtocol) prot; BitSet incoming = iprot.readBitSet(2); if (incoming.get(0)) { struct.row = iprot.readBinary(); struct.setRowIsSet(true); } if (incoming.get(1)) { { org.apache.thrift.protocol.TList _list5 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32()); struct.mutations = new ArrayList<Mutation>(_list5.size); Mutation _elem6; for (int _i7 = 0; _i7 < _list5.size; ++_i7) { _elem6 = new Mutation(); _elem6.read(iprot); struct.mutations.add(_elem6); } } struct.setMutationsIsSet(true); } } }