handler.put(table, put); TGet get = new TGet(wrap(rowName)); get.setMaxVersions(2); TResult result = handler.get(table, get); assertEquals(2, result.getColumnValuesSize()); get = new TGet(wrap(rowName)); result = handler.get(table, get); assertArrayEquals(null, result.getRow());
case ROW: if (value == null) { unsetRow(); } else { if (value instanceof byte[]) { setRow((byte[])value); } else { setRow((java.nio.ByteBuffer)value); unsetColumns(); } else { setColumns((java.util.List<TColumn>)value); unsetTimestamp(); } else { setTimestamp((java.lang.Long)value); unsetTimeRange(); } else { setTimeRange((TTimeRange)value); unsetMaxVersions(); } else { setMaxVersions((java.lang.Integer)value); unsetFilterString(); } else { if (value instanceof byte[]) { setFilterString((byte[])value);
@Override public boolean equals(java.lang.Object that) { if (that == null) return false; if (that instanceof TGet) return this.equals((TGet)that); return false; }
switch (field) { case ROW: return getRow(); return getColumns(); return getTimestamp(); return getTimeRange(); return getMaxVersions(); return getFilterString(); return getAttributes(); return getAuthorizations(); return getConsistency(); return getTargetReplicaId(); return isCacheBlocks(); return getStoreLimit(); return getStoreOffset(); return isExistence_only();
Get out = new Get(in.getRow()); if (in.isSetTimestamp()) { out.setTimestamp(in.getTimestamp()); } else if (in.isSetTimeRange()) { out.setTimeRange(in.getTimeRange().getMinStamp(), in.getTimeRange().getMaxStamp()); if (in.isSetMaxVersions()) { out.setMaxVersions(in.getMaxVersions()); if (in.isSetFilterString()) { ParseFilter parseFilter = new ParseFilter(); out.setFilter(parseFilter.parseFilterString(in.getFilterString())); if (in.isSetAttributes()) { addAttributes(out,in.getAttributes()); if (in.isSetAuthorizations()) { out.setAuthorizations(new Authorizations(in.getAuthorizations().getLabels())); if (in.isSetConsistency()) { out.setConsistency(consistencyFromThrift(in.getConsistency())); if (in.isSetTargetReplicaId()) { out.setReplicaId(in.getTargetReplicaId()); if (in.isSetCacheBlocks()) { out.setCacheBlocks(in.isCacheBlocks());
case ROW: if (value == null) { unsetRow(); } else { setRow((ByteBuffer)value); unsetColumns(); } else { setColumns((List<TColumn>)value); unsetTimestamp(); } else { setTimestamp((Long)value); unsetTimeRange(); } else { setTimeRange((TTimeRange)value); unsetMaxVersions(); } else { setMaxVersions((Integer)value); unsetFilterString(); } else { setFilterString((ByteBuffer)value); unsetAttributes(); } else { setAttributes((Map<ByteBuffer,ByteBuffer>)value);
Get out = new Get(in.getRow()); if (in.isSetTimestamp()) { out.setTimestamp(in.getTimestamp()); } else if (in.isSetTimeRange()) { out.setTimeRange(in.getTimeRange().getMinStamp(), in.getTimeRange().getMaxStamp()); if (in.isSetMaxVersions()) { out.setMaxVersions(in.getMaxVersions()); if (in.isSetFilterString()) { ParseFilter parseFilter = new ParseFilter(); out.setFilter(parseFilter.parseFilterString(in.getFilterString())); if (in.isSetAttributes()) { addAttributes(out,in.getAttributes()); if (in.isSetAuthorizations()) { out.setAuthorizations(new Authorizations(in.getAuthorizations().getLabels())); if (!in.isSetColumns()) { return out; for (TColumn column : in.getColumns()) { if (column.isSetQualifier()) { out.addColumn(column.getFamily(), column.getQualifier());
public Object getFieldValue(_Fields field) { switch (field) { case ROW: return getRow(); case COLUMNS: return getColumns(); case TIMESTAMP: return Long.valueOf(getTimestamp()); case TIME_RANGE: return getTimeRange(); case MAX_VERSIONS: return Integer.valueOf(getMaxVersions()); case FILTER_STRING: return getFilterString(); case ATTRIBUTES: return getAttributes(); case AUTHORIZATIONS: return getAuthorizations(); } throw new IllegalStateException(); }
case ROW: if (value == null) { unsetRow(); } else { setRow((ByteBuffer)value); unsetColumns(); } else { setColumns((List<TColumn>)value); unsetTimestamp(); } else { setTimestamp((Long)value); unsetTimeRange(); } else { setTimeRange((TTimeRange)value); unsetMaxVersions(); } else { setMaxVersions((Integer)value);
public static TGet getFromHBase(Get in) { TGet out = new TGet(); out.setRow(in.getRow()); out.setTimeRange(tTimeRange); out.setMaxVersions(in.getMaxVersions()); out.putToAttributes(ByteBuffer.wrap(Bytes.toBytes(attribute.getKey())), ByteBuffer.wrap(attribute.getValue())); TAuthorization tAuthorization = new TAuthorization(); tAuthorization.setLabels(authorizations.getLabels()); out.setAuthorizations(tAuthorization); out.setConsistency(consistencyFromHBase(in.getConsistency())); out.setTargetReplicaId(in.getReplicaId()); out.setCacheBlocks(in.getCacheBlocks()); out.setStoreLimit(in.getMaxResultsPerColumnFamily()); out.setStoreOffset(in.getRowOffsetPerColumnFamily()); out.setExistence_only(in.isCheckExistenceOnly()); for (Map.Entry<byte[], NavigableSet<byte[]>> family : in.getFamilyMap().entrySet()) { column.setFamily(family.getKey()); column.setQualifier(qualifier); out.addToColumns(column); out.addToColumns(column); out.setFilterBytes(in.getFilter().toByteArray()); } catch (IOException ioE) {
@Test public void testGetsWithLabels() throws Exception { ThriftHBaseServiceHandler handler = createHandler(); byte[] rowName = Bytes.toBytes("testPutGet"); ByteBuffer table = wrap(tableAname); 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))); TPut put = new TPut(wrap(rowName), columnValues); put.setColumnValues(columnValues); put.setCellVisibility(new TCellVisibility().setExpression("(" + SECRET + "|" + CONFIDENTIAL + ")" + "&" + "!" + TOPSECRET)); handler.put(table, put); TGet get = new TGet(wrap(rowName)); TAuthorization tauth = new TAuthorization(); List<String> labels = new ArrayList<>(2); labels.add(SECRET); labels.add(PRIVATE); tauth.setLabels(labels); get.setAuthorizations(tauth); TResult result = handler.get(table, get); assertArrayEquals(rowName, result.getRow()); List<TColumnValue> returnedColumnValues = result.getColumnValues(); assertTColumnValuesEqual(columnValues, returnedColumnValues); }
Get out = new Get(in.getRow()); if (in.isSetTimestamp()) { out.setTimeStamp(in.getTimestamp()); } else if (in.isSetTimeRange()) { out.setTimeRange(in.getTimeRange().getMinStamp(), in.getTimeRange().getMaxStamp()); if (in.isSetMaxVersions()) { out.setMaxVersions(in.getMaxVersions()); if (!in.isSetColumns()) { return out; for (TColumn column : in.getColumns()) { if (column.isSetQualifier()) { out.addColumn(column.getFamily(), column.getQualifier());
public TGet deepCopy() { return new TGet(this); }
private void testExceptionType(THBaseService.Iface handler, ThriftMetrics metrics, ByteBuffer tTableName, byte[] rowkey, ErrorThrowingGetObserver.ErrorType errorType) { long preGetCounter = metricsHelper.getCounter("get_num_ops", metrics.getSource()); String exceptionKey = errorType.getMetricName(); long preExceptionCounter = metricsHelper.checkCounterExists(exceptionKey, metrics.getSource()) ? metricsHelper.getCounter(exceptionKey, metrics.getSource()) : 0; TGet tGet = new TGet(wrap(rowkey)); Map<ByteBuffer, ByteBuffer> attributes = new HashMap<>(); attributes.put(wrap(Bytes.toBytes(ErrorThrowingGetObserver.SHOULD_ERROR_ATTRIBUTE)), wrap(Bytes.toBytes(errorType.name()))); tGet.setAttributes(attributes); try { TResult tResult = handler.get(tTableName, tGet); fail("Get with error attribute should have thrown an exception"); } catch (TException e) { LOG.info("Received exception: ", e); metricsHelper.assertCounter("get_num_ops", preGetCounter + 1, metrics.getSource()); metricsHelper.assertCounter(exceptionKey, preExceptionCounter + 1, metrics.getSource()); } }
public Object getFieldValue(_Fields field) { switch (field) { case ROW: return getRow(); case COLUMNS: return getColumns(); case TIMESTAMP: return Long.valueOf(getTimestamp()); case TIME_RANGE: return getTimeRange(); case MAX_VERSIONS: return Integer.valueOf(getMaxVersions()); } throw new IllegalStateException(); }
@Override public void read(org.apache.thrift.protocol.TProtocol prot, exists_args struct) throws org.apache.thrift.TException { TTupleProtocol iprot = (TTupleProtocol) prot; struct.table = iprot.readBinary(); struct.setTableIsSet(true); struct.get = new TGet(); struct.get.read(iprot); struct.setGetIsSet(true); } }
public byte[] getRow() { setRow(org.apache.thrift.TBaseHelper.rightSize(row)); return row == null ? null : row.array(); }
@Test public void testConsistency() throws Exception { byte[] rowName = Bytes.toBytes("testConsistency"); TGet tGet = new TGet(wrap(rowName)); tGet.setConsistency(TConsistency.STRONG); Get get = getFromThrift(tGet); assertEquals(Consistency.STRONG, get.getConsistency()); tGet.setConsistency(TConsistency.TIMELINE); tGet.setTargetReplicaId(1); get = getFromThrift(tGet); assertEquals(Consistency.TIMELINE, get.getConsistency()); assertEquals(1, get.getReplicaId()); TScan tScan = new TScan(); tScan.setConsistency(TConsistency.STRONG); Scan scan = scanFromThrift(tScan); assertEquals(Consistency.STRONG, scan.getConsistency()); tScan.setConsistency(TConsistency.TIMELINE); tScan.setTargetReplicaId(1); scan = scanFromThrift(tScan); assertEquals(Consistency.TIMELINE, scan.getConsistency()); assertEquals(1, scan.getReplicaId()); TResult tResult = new TResult(); assertFalse(tResult.isSetStale()); tResult.setStale(true); assertTrue(tResult.isSetStale()); }
case ROW: if (value == null) { unsetRow(); } else { setRow((ByteBuffer)value); unsetColumns(); } else { setColumns((List<TColumn>)value); unsetTimestamp(); } else { setTimestamp((Long)value); unsetTimeRange(); } else { setTimeRange((TTimeRange)value); unsetMaxVersions(); } else { setMaxVersions((Integer)value); unsetFilterString(); } else { setFilterString((ByteBuffer)value); unsetAttributes(); } else { setAttributes((Map<ByteBuffer,ByteBuffer>)value);