org.apache.hadoop.hbase.client.Get.getAttribute()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(12.1k)|赞(0)|评价(0)|浏览(135)

本文整理了Java中org.apache.hadoop.hbase.client.Get.getAttribute()方法的一些代码示例,展示了Get.getAttribute()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Get.getAttribute()方法的具体详情如下:
包路径:org.apache.hadoop.hbase.client.Get
类名称:Get
方法名:getAttribute

Get.getAttribute介绍

暂无

代码示例

代码示例来源:origin: apache/hbase

@Override
 public void preGetOp(final ObserverContext<RegionCoprocessorEnvironment> c,
   final Get get, final List<Cell> result) throws IOException {
  if (get.getAttribute("count") != null) {
   result.clear();
   // order is important!
   result.add(new KeyValue(count, count, delete, Bytes.toBytes(nDelete)));
   result.add(new KeyValue(count, count, put, Bytes.toBytes(nCount)));
   c.bypass();
  }
 }
}

代码示例来源:origin: apache/hbase

@Test
public void testAttributesSerialization() throws IOException {
 Get get = new Get(Bytes.toBytes("row"));
 get.setAttribute("attribute1", Bytes.toBytes("value1"));
 get.setAttribute("attribute2", Bytes.toBytes("value2"));
 get.setAttribute("attribute3", Bytes.toBytes("value3"));
 ClientProtos.Get getProto = ProtobufUtil.toGet(get);
 Get get2 = ProtobufUtil.toGet(getProto);
 Assert.assertNull(get2.getAttribute("absent"));
 Assert.assertTrue(Arrays.equals(Bytes.toBytes("value1"), get2.getAttribute("attribute1")));
 Assert.assertTrue(Arrays.equals(Bytes.toBytes("value2"), get2.getAttribute("attribute2")));
 Assert.assertTrue(Arrays.equals(Bytes.toBytes("value3"), get2.getAttribute("attribute3")));
 Assert.assertEquals(3, get2.getAttributesMap().size());
}

代码示例来源:origin: apache/hbase

Get get = new Get(ROW);
Assert.assertTrue(get.getAttributesMap().isEmpty());
Assert.assertNull(get.getAttribute("absent"));
Assert.assertNull(get.getAttribute("absent"));
Assert.assertTrue(Arrays.equals(Bytes.toBytes("value1"), get.getAttribute("attribute1")));
Assert.assertEquals(1, get.getAttributesMap().size());
Assert.assertTrue(Arrays.equals(Bytes.toBytes("value1"), get.getAttributesMap().get("attribute1")));
Assert.assertTrue(Arrays.equals(Bytes.toBytes("value12"), get.getAttribute("attribute1")));
Assert.assertEquals(1, get.getAttributesMap().size());
Assert.assertTrue(Arrays.equals(Bytes.toBytes("value12"), get.getAttributesMap().get("attribute1")));
Assert.assertTrue(Arrays.equals(Bytes.toBytes("value2"), get.getAttribute("attribute2")));
Assert.assertEquals(2, get.getAttributesMap().size());
Assert.assertTrue(Arrays.equals(Bytes.toBytes("value2"), get.getAttributesMap().get("attribute2")));
Assert.assertNull(get.getAttribute("attribute2"));
Assert.assertEquals(1, get.getAttributesMap().size());
Assert.assertNull(get.getAttributesMap().get("attribute2"));
Assert.assertNull(get.getAttribute("attribute2"));
Assert.assertEquals(1, get.getAttributesMap().size());
Assert.assertNull(get.getAttributesMap().get("attribute2"));
Assert.assertNull(get.getAttribute("attribute1"));
Assert.assertTrue(get.getAttributesMap().isEmpty());
Assert.assertNull(get.getAttributesMap().get("attribute1"));

代码示例来源:origin: apache/hbase

tGet.setAttributes(attributes);
Get get = getFromThrift(tGet);
assertArrayEquals(get.getAttribute("attribute1"), attributeValue);

代码示例来源:origin: org.apache.hbase/hbase-client

@Test
public void testAttributesSerialization() throws IOException {
 Get get = new Get(Bytes.toBytes("row"));
 get.setAttribute("attribute1", Bytes.toBytes("value1"));
 get.setAttribute("attribute2", Bytes.toBytes("value2"));
 get.setAttribute("attribute3", Bytes.toBytes("value3"));
 ClientProtos.Get getProto = ProtobufUtil.toGet(get);
 Get get2 = ProtobufUtil.toGet(getProto);
 Assert.assertNull(get2.getAttribute("absent"));
 Assert.assertTrue(Arrays.equals(Bytes.toBytes("value1"), get2.getAttribute("attribute1")));
 Assert.assertTrue(Arrays.equals(Bytes.toBytes("value2"), get2.getAttribute("attribute2")));
 Assert.assertTrue(Arrays.equals(Bytes.toBytes("value3"), get2.getAttribute("attribute3")));
 Assert.assertEquals(3, get2.getAttributesMap().size());
}

代码示例来源:origin: apache/hbase

@Override
public void preGetOp(ObserverContext<RegionCoprocessorEnvironment> e,
           Get get, List<Cell> results) throws IOException {
 byte[] errorType = get.getAttribute(SHOULD_ERROR_ATTRIBUTE);
 if (errorType != null) {
  ErrorType type = ErrorType.valueOf(Bytes.toString(errorType));
  switch (type) {
   case CALL_QUEUE_TOO_BIG:
    throw new CallQueueTooBigException("Failing for test");
   case MULTI_ACTION_RESULT_TOO_LARGE:
    throw new MultiActionResultTooLarge("Failing for test");
   case FAILED_SANITY_CHECK:
    throw new FailedSanityCheckException("Failing for test");
   case NOT_SERVING_REGION:
    throw new NotServingRegionException("Failing for test");
   case REGION_MOVED:
    throw new RegionMovedException(e.getEnvironment().getServerName(), 1);
   case SCANNER_RESET:
    throw new ScannerResetException("Failing for test");
   case UNKNOWN_SCANNER:
    throw new UnknownScannerException("Failing for test");
   case REGION_TOO_BUSY:
    throw new RegionTooBusyException("Failing for test");
   case OUT_OF_ORDER_SCANNER_NEXT:
    throw new OutOfOrderScannerNextException("Failing for test");
   default:
    throw new DoNotRetryIOException("Failing for test");
  }
 }
}

代码示例来源:origin: org.apache.hbase/hbase-client

Get get = new Get(ROW);
Assert.assertTrue(get.getAttributesMap().isEmpty());
Assert.assertNull(get.getAttribute("absent"));
Assert.assertNull(get.getAttribute("absent"));
Assert.assertTrue(Arrays.equals(Bytes.toBytes("value1"), get.getAttribute("attribute1")));
Assert.assertEquals(1, get.getAttributesMap().size());
Assert.assertTrue(Arrays.equals(Bytes.toBytes("value1"), get.getAttributesMap().get("attribute1")));
Assert.assertTrue(Arrays.equals(Bytes.toBytes("value12"), get.getAttribute("attribute1")));
Assert.assertEquals(1, get.getAttributesMap().size());
Assert.assertTrue(Arrays.equals(Bytes.toBytes("value12"), get.getAttributesMap().get("attribute1")));
Assert.assertTrue(Arrays.equals(Bytes.toBytes("value2"), get.getAttribute("attribute2")));
Assert.assertEquals(2, get.getAttributesMap().size());
Assert.assertTrue(Arrays.equals(Bytes.toBytes("value2"), get.getAttributesMap().get("attribute2")));
Assert.assertNull(get.getAttribute("attribute2"));
Assert.assertEquals(1, get.getAttributesMap().size());
Assert.assertNull(get.getAttributesMap().get("attribute2"));
Assert.assertNull(get.getAttribute("attribute2"));
Assert.assertEquals(1, get.getAttributesMap().size());
Assert.assertNull(get.getAttributesMap().get("attribute2"));
Assert.assertNull(get.getAttribute("attribute1"));
Assert.assertTrue(get.getAttributesMap().isEmpty());
Assert.assertNull(get.getAttributesMap().get("attribute1"));

代码示例来源:origin: apache/hbase

assertEquals(get.getTimeRange().getMin(), scan.getTimeRange().getMin());
assertEquals(get.getTimeRange().getMax(), scan.getTimeRange().getMax());
assertTrue(Bytes.equals(get.getAttribute("att_v0"), scan.getAttribute("att_v0")));
assertEquals(get.getColumnFamilyTimeRange().get(Bytes.toBytes("cf")).getMin(),
    scan.getColumnFamilyTimeRange().get(Bytes.toBytes("cf")).getMin());

代码示例来源:origin: com.aliyun.phoenix/ali-phoenix-core

public static TupleProjector deserializeProjectorFromGet(Get get) {
  byte[] proj = get.getAttribute(SCAN_PROJECTOR);
  if (proj == null) {
    return null;
  }
  return deserializeProjectorFromBytes(proj);
}

代码示例来源:origin: org.apache.hbase/hbase-client

assertEquals(get.getTimeRange().getMin(), scan.getTimeRange().getMin());
assertEquals(get.getTimeRange().getMax(), scan.getTimeRange().getMax());
assertTrue(Bytes.equals(get.getAttribute("att_v0"), scan.getAttribute("att_v0")));
assertEquals(get.getColumnFamilyTimeRange().get(Bytes.toBytes("cf")).getMin(),
    scan.getColumnFamilyTimeRange().get(Bytes.toBytes("cf")).getMin());

代码示例来源:origin: org.apache.hbase/hbase-server

@Override
 public void preGetOp(final ObserverContext<RegionCoprocessorEnvironment> c,
   final Get get, final List<Cell> result) throws IOException {
  if (get.getAttribute("count") != null) {
   result.clear();
   // order is important!
   result.add(new KeyValue(count, count, delete, Bytes.toBytes(nDelete)));
   result.add(new KeyValue(count, count, put, Bytes.toBytes(nCount)));
   c.bypass();
  }
 }
}

代码示例来源:origin: com.aliyun.phoenix/ali-phoenix-core

@Override
public void postGetOp(ObserverContext<RegionCoprocessorEnvironment> e, Get get,
    List<Cell> results) throws IOException {
  if (results.isEmpty()) {
    return;
  }
  ResultTuple rsTuple = new ResultTuple(Result.create(results));
  //filter rows by the where expression
  byte[] whereBytes = get.getAttribute(GET_WHERE_EXPRESSION);
  if (whereBytes != null) {
    Expression expression = deserializeExpression(whereBytes);
    if (!expression.evaluate(rsTuple, ptr) ||
        ptr.getLength() == 0 ||
        !Boolean.TRUE.equals(expression.getDataType().toObject(ptr))) {
      results.clear();
      return;
    }
  }
  boolean useNewValueColumnQualifier =
      get.getAttribute(BaseScannerRegionObserver.USE_NEW_VALUE_COLUMN_QUALIFIER) == null ? false : true;
  TupleProjector projector = TupleProjector.deserializeProjectorFromGet(get);
  if (projector != null) {
    Tuple projectTuple = projector.projectResults(rsTuple, useNewValueColumnQualifier);
    results.clear();
    results.add(projectTuple.getValue(0));
  }
}

代码示例来源:origin: com.aliyun.hbase/alihbase-thrift

tGet.setAttributes(attributes);
Get get = getFromThrift(tGet);
assertArrayEquals(get.getAttribute("attribute1"), attributeValue);

代码示例来源:origin: org.apache.hbase/hbase-thrift

tGet.setAttributes(attributes);
Get get = getFromThrift(tGet);
assertArrayEquals(get.getAttribute("attribute1"), attributeValue);

代码示例来源:origin: com.aliyun.hbase/alihbase-thrift

@Override
public void preGetOp(ObserverContext<RegionCoprocessorEnvironment> e,
           Get get, List<Cell> results) throws IOException {
 byte[] errorType = get.getAttribute(SHOULD_ERROR_ATTRIBUTE);
 if (errorType != null) {
  ErrorType type = ErrorType.valueOf(Bytes.toString(errorType));
  switch (type) {
   case CALL_QUEUE_TOO_BIG:
    throw new CallQueueTooBigException("Failing for test");
   case MULTI_ACTION_RESULT_TOO_LARGE:
    throw new MultiActionResultTooLarge("Failing for test");
   case FAILED_SANITY_CHECK:
    throw new FailedSanityCheckException("Failing for test");
   case NOT_SERVING_REGION:
    throw new NotServingRegionException("Failing for test");
   case REGION_MOVED:
    throw new RegionMovedException(e.getEnvironment().getServerName(), 1);
   case SCANNER_RESET:
    throw new ScannerResetException("Failing for test");
   case UNKNOWN_SCANNER:
    throw new UnknownScannerException("Failing for test");
   case REGION_TOO_BUSY:
    throw new RegionTooBusyException("Failing for test");
   case OUT_OF_ORDER_SCANNER_NEXT:
    throw new OutOfOrderScannerNextException("Failing for test");
   default:
    throw new DoNotRetryIOException("Failing for test");
  }
 }
}

代码示例来源:origin: org.apache.hbase/hbase-thrift

@Override
public void preGetOp(ObserverContext<RegionCoprocessorEnvironment> e,
           Get get, List<Cell> results) throws IOException {
 byte[] errorType = get.getAttribute(SHOULD_ERROR_ATTRIBUTE);
 if (errorType != null) {
  ErrorType type = ErrorType.valueOf(Bytes.toString(errorType));
  switch (type) {
   case CALL_QUEUE_TOO_BIG:
    throw new CallQueueTooBigException("Failing for test");
   case MULTI_ACTION_RESULT_TOO_LARGE:
    throw new MultiActionResultTooLarge("Failing for test");
   case FAILED_SANITY_CHECK:
    throw new FailedSanityCheckException("Failing for test");
   case NOT_SERVING_REGION:
    throw new NotServingRegionException("Failing for test");
   case REGION_MOVED:
    throw new RegionMovedException(e.getEnvironment().getServerName(), 1);
   case SCANNER_RESET:
    throw new ScannerResetException("Failing for test");
   case UNKNOWN_SCANNER:
    throw new UnknownScannerException("Failing for test");
   case REGION_TOO_BUSY:
    throw new RegionTooBusyException("Failing for test");
   case OUT_OF_ORDER_SCANNER_NEXT:
    throw new OutOfOrderScannerNextException("Failing for test");
   default:
    throw new DoNotRetryIOException("Failing for test");
  }
 }
}

相关文章