@Test public void testPutGetMultiple() throws Exception { ThriftHBaseServiceHandler handler = createHandler(); ByteBuffer table = wrap(tableAname); byte[] rowName1 = Bytes.toBytes("testPutGetMultiple1"); byte[] rowName2 = Bytes.toBytes("testPutGetMultiple2"); List<TColumnValue> columnValues = new ArrayList<>(2); columnValues.add(new TColumnValue(wrap(familyAname), wrap(qualifierAname), wrap(valueAname))); columnValues.add(new TColumnValue(wrap(familyBname), wrap(qualifierBname), wrap(valueBname))); List<TPut> puts = new ArrayList<>(2); puts.add(new TPut(wrap(rowName1), columnValues)); puts.add(new TPut(wrap(rowName2), columnValues)); handler.putMultiple(table, puts); List<TGet> gets = new ArrayList<>(2); gets.add(new TGet(wrap(rowName1))); gets.add(new TGet(wrap(rowName2))); List<TResult> results = handler.getMultiple(table, gets); assertEquals(2, results.size()); assertArrayEquals(rowName1, results.get(0).getRow()); assertTColumnValuesEqual(columnValues, results.get(0).getColumnValues()); assertArrayEquals(rowName2, results.get(1).getRow()); assertTColumnValuesEqual(columnValues, results.get(1).getColumnValues()); }
/** * Performs a deep copy on <i>other</i>. */ public TResult(TResult other) { __isset_bitfield = other.__isset_bitfield; if (other.isSetRow()) { this.row = org.apache.thrift.TBaseHelper.copyBinary(other.row); } if (other.isSetColumnValues()) { java.util.List<TColumnValue> __this__columnValues = new java.util.ArrayList<TColumnValue>(other.columnValues.size()); for (TColumnValue other_element : other.columnValues) { __this__columnValues.add(new TColumnValue(other_element)); } this.columnValues = __this__columnValues; } this.stale = other.stale; this.partial = other.partial; }
TResult out = new TResult(); byte[] row = in.getRow(); if (row != null) { out.setRow(in.getRow()); out.setColumnValues(columnValues); out.setStale(in.isStale()); out.setPartial(in.mayHaveMoreCellsInRow()); return out;
@Override public int hashCode() { int hashCode = 1; hashCode = hashCode * 8191 + ((isSetRow()) ? 131071 : 524287); if (isSetRow()) hashCode = hashCode * 8191 + row.hashCode(); hashCode = hashCode * 8191 + ((isSetColumnValues()) ? 131071 : 524287); if (isSetColumnValues()) hashCode = hashCode * 8191 + columnValues.hashCode(); hashCode = hashCode * 8191 + ((isSetStale()) ? 131071 : 524287); if (isSetStale()) hashCode = hashCode * 8191 + ((stale) ? 131071 : 524287); hashCode = hashCode * 8191 + ((isSetPartial()) ? 131071 : 524287); if (isSetPartial()) hashCode = hashCode * 8191 + ((partial) ? 131071 : 524287); return hashCode; }
@org.apache.thrift.annotation.Nullable public java.lang.Object getFieldValue(_Fields field) { switch (field) { case ROW: return getRow(); case COLUMN_VALUES: return getColumnValues(); case STALE: return isStale(); case PARTIAL: return isPartial(); } throw new java.lang.IllegalStateException(); }
case ROW: if (value == null) { unsetRow(); } else { if (value instanceof byte[]) { setRow((byte[])value); } else { setRow((java.nio.ByteBuffer)value); unsetColumnValues(); } else { setColumnValues((java.util.List<TColumnValue>)value); unsetStale(); } else { setStale((java.lang.Boolean)value); unsetPartial(); } else { setPartial((java.lang.Boolean)value);
@Test public void testIncrement() throws Exception { ThriftHBaseServiceHandler handler = createHandler(); byte[] rowName = Bytes.toBytes("testIncrement"); ByteBuffer table = wrap(tableAname); List<TColumnValue> columnValues = new ArrayList<>(1); columnValues.add(new TColumnValue(wrap(familyAname), wrap(qualifierAname), wrap(Bytes.toBytes(1L)))); TPut put = new TPut(wrap(rowName), columnValues); put.setColumnValues(columnValues); handler.put(table, put); List<TColumnIncrement> incrementColumns = new ArrayList<>(1); incrementColumns.add(new TColumnIncrement(wrap(familyAname), wrap(qualifierAname))); TIncrement increment = new TIncrement(wrap(rowName), incrementColumns); handler.increment(table, increment); TGet get = new TGet(wrap(rowName)); TResult result = handler.get(table, get); assertArrayEquals(rowName, result.getRow()); assertEquals(1, result.getColumnValuesSize()); TColumnValue columnValue = result.getColumnValues().get(0); assertArrayEquals(Bytes.toBytes(2L), columnValue.getValue()); }
public void setFieldValue(_Fields field, Object value) { switch (field) { case ROW: if (value == null) { unsetRow(); } else { setRow((ByteBuffer)value); } break; case COLUMN_VALUES: if (value == null) { unsetColumnValues(); } else { setColumnValues((List<TColumnValue>)value); } break; } }
@Override public void read(org.apache.thrift.protocol.TProtocol prot, get_result struct) throws org.apache.thrift.TException { TTupleProtocol iprot = (TTupleProtocol) prot; BitSet incoming = iprot.readBitSet(2); if (incoming.get(0)) { struct.success = new TResult(); struct.success.read(iprot); struct.setSuccessIsSet(true); } if (incoming.get(1)) { struct.io = new TIOError(); struct.io.read(iprot); struct.setIoIsSet(true); } } }
if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { struct.row = iprot.readBinary(); struct.setRowIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); struct.setColumnValuesIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); struct.validate();
assertArrayEquals(rowName, result.getRow()); assertTColumnValuesEqual(columnValuesB, result.getColumnValues()); assertFalse(result.isSetRow()); assertEquals(0, result.getColumnValuesSize());
/** * Creates a {@link TResult} (Thrift) from a {@link Result} (HBase). * * @param in the <code>Result</code> to convert * * @return converted result, returns an empty result if the input is <code>null</code> */ public static TResult resultFromHBase(Result in) { KeyValue[] raw = in.raw(); TResult out = new TResult(); byte[] row = in.getRow(); if (row != null) { out.setRow(in.getRow()); } List<TColumnValue> columnValues = new ArrayList<TColumnValue>(); for (KeyValue kv : raw) { TColumnValue col = new TColumnValue(); col.setFamily(kv.getFamily()); col.setQualifier(kv.getQualifier()); col.setTimestamp(kv.getTimestamp()); col.setValue(kv.getValue()); columnValues.add(col); } out.setColumnValues(columnValues); return out; }
@Override public void read(org.apache.thrift.protocol.TProtocol prot, TResult struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot; { org.apache.thrift.protocol.TList _list5 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32()); struct.columnValues = new java.util.ArrayList<TColumnValue>(_list5.size); @org.apache.thrift.annotation.Nullable TColumnValue _elem6; for (int _i7 = 0; _i7 < _list5.size; ++_i7) { _elem6 = new TColumnValue(); _elem6.read(iprot); struct.columnValues.add(_elem6); } } struct.setColumnValuesIsSet(true); java.util.BitSet incoming = iprot.readBitSet(3); if (incoming.get(0)) { struct.row = iprot.readBinary(); struct.setRowIsSet(true); } if (incoming.get(1)) { struct.stale = iprot.readBool(); struct.setStaleIsSet(true); } if (incoming.get(2)) { struct.partial = iprot.readBool(); struct.setPartialIsSet(true); } } }
@Override public void read(org.apache.thrift.protocol.TProtocol prot, TResult struct) throws org.apache.thrift.TException { TTupleProtocol iprot = (TTupleProtocol) prot; { org.apache.thrift.protocol.TList _list5 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32()); struct.columnValues = new ArrayList<TColumnValue>(_list5.size); TColumnValue _elem6; for (int _i7 = 0; _i7 < _list5.size; ++_i7) { _elem6 = new TColumnValue(); _elem6.read(iprot); struct.columnValues.add(_elem6); } } struct.setColumnValuesIsSet(true); BitSet incoming = iprot.readBitSet(1); if (incoming.get(0)) { struct.row = iprot.readBinary(); struct.setRowIsSet(true); } } }
public TResult deepCopy() { return new TResult(this); }
@Override public boolean equals(java.lang.Object that) { if (that == null) return false; if (that instanceof TResult) return this.equals((TResult)that); return false; }
public void write(org.apache.thrift.protocol.TProtocol oprot, TResult struct) throws org.apache.thrift.TException { struct.validate(); if (struct.isSetRow()) { oprot.writeFieldBegin(ROW_FIELD_DESC); oprot.writeBinary(struct.row); if (struct.isSetStale()) { oprot.writeFieldBegin(STALE_FIELD_DESC); oprot.writeBool(struct.stale); oprot.writeFieldEnd(); if (struct.isSetPartial()) { oprot.writeFieldBegin(PARTIAL_FIELD_DESC); oprot.writeBool(struct.partial);
get.setMaxVersions(2); TResult result = handler.get(table, get); assertEquals(2, result.getColumnValuesSize()); assertArrayEquals(null, result.getRow()); assertEquals(0, result.getColumnValuesSize());
boolean first = true; if (isSetRow()) { sb.append("row:"); if (this.row == null) { if (isSetStale()) { if (!first) sb.append(", "); sb.append("stale:"); first = false; if (isSetPartial()) { if (!first) sb.append(", "); sb.append("partial:");
public byte[] getRow() { setRow(org.apache.thrift.TBaseHelper.rightSize(row)); return row == null ? null : row.array(); }