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

x33g5p2x  于2022-01-26 转载在 其他  
字(13.9k)|赞(0)|评价(0)|浏览(134)

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

Put.getAttribute介绍

暂无

代码示例

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

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

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

@Override
public void prePut(ObserverContext<RegionCoprocessorEnvironment> c, Put put, WALEdit edit,
          Durability durability) throws IOException {
 if (put.getAttribute(DO_ABORT) != null) {
  // TODO: Change this so it throws a CP Abort Exception instead.
  RegionServerServices rss =
    ((HasRegionServerServices)c.getEnvironment()).getRegionServerServices();
  String str = "Aborting for test";
  LOG.info(str  + " " + rss.getServerName());
  rss.abort(str, new Throwable(str));
 }
}

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

@Override
public void prePut(final ObserverContext<RegionCoprocessorEnvironment> c, final Put put,
  final WALEdit edit, final Durability durability) throws IOException {
 if (put.getAttribute("ttl") != null) {
  Cell cell = put.getFamilyCellMap().values().stream().findFirst().get().get(0);
  ttls.put(
   TableName.valueOf(Bytes.toString(cell.getQualifierArray(), cell.getQualifierOffset(),
    cell.getQualifierLength())),
   Bytes.toLong(cell.getValueArray(), cell.getValueOffset(), cell.getValueLength()));
  c.bypass();
 } else if (put.getAttribute("versions") != null) {
  Cell cell = put.getFamilyCellMap().values().stream().findFirst().get().get(0);
  versions.put(
   TableName.valueOf(Bytes.toString(cell.getQualifierArray(), cell.getQualifierOffset(),
    cell.getQualifierLength())),
   Bytes.toInt(cell.getValueArray(), cell.getValueOffset(), cell.getValueLength()));
  c.bypass();
 }
}

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

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

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

@Override
 public void prePut(ObserverContext<RegionCoprocessorEnvironment> e, Put m, WALEdit edit,
   Durability durability) throws IOException {
  byte[] attribute = m.getAttribute(NON_VISIBILITY);
  byte[] cf = null;
  List<Cell> updatedCells = new ArrayList<>();
  if (attribute != null) {
   for (List<? extends Cell> edits : m.getFamilyCellMap().values()) {
    for (Cell cell : edits) {
     KeyValue kv = KeyValueUtil.ensureKeyValue(cell);
     if (cf == null) {
      cf = CellUtil.cloneFamily(kv);
     }
     Tag tag = new ArrayBackedTag((byte) NON_VIS_TAG_TYPE, attribute);
     List<Tag> tagList = new ArrayList<>(PrivateCellUtil.getTags(cell).size() + 1);
     tagList.add(tag);
     tagList.addAll(PrivateCellUtil.getTags(cell));
     Cell newcell = PrivateCellUtil.createCell(kv, tagList);
     ((List<Cell>) updatedCells).add(newcell);
    }
   }
   m.getFamilyCellMap().remove(cf);
   // Update the family map
   m.getFamilyCellMap().put(cf, updatedCells);
  }
 }
}

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

tPut.setAttributes(attributes);
Put put = putFromThrift(tPut);
assertArrayEquals(put.getAttribute("attribute1"), attributeValue);

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

@Override
 public void prePut(ObserverContext<RegionCoprocessorEnvironment> e, Put put, WALEdit edit,
   Durability durability) throws IOException {
  Region region = e.getEnvironment().getRegion();
  if (!region.getRegionInfo().isMetaRegion()
    && !region.getRegionInfo().getTable().isSystemTable()) {
   if (put.getAttribute(TEST_ATR_KEY) != null) {
    LOG.debug("allow any put to happen " + region.getRegionInfo().getRegionNameAsString());
   } else {
    e.bypass();
   }
  }
 }
}

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

@Override
 public void prePut(final ObserverContext<RegionCoprocessorEnvironment> e, final Put put,
   final WALEdit edit, final Durability durability) throws IOException {
  byte[] attribute = put.getAttribute("visibility");
  byte[] cf = null;
  List<Cell> updatedCells = new ArrayList<>();
  if (attribute != null) {
   for (List<? extends Cell> edits : put.getFamilyCellMap().values()) {
    for (Cell cell : edits) {
     KeyValue kv = KeyValueUtil.ensureKeyValue(cell);
     if (cf == null) {
      cf = CellUtil.cloneFamily(kv);
     }
     Tag tag = new ArrayBackedTag(TAG_TYPE, attribute);
     List<Tag> tagList = new ArrayList<>(1);
     tagList.add(tag);
     KeyValue newKV = new KeyValue(CellUtil.cloneRow(kv), 0, kv.getRowLength(),
       CellUtil.cloneFamily(kv), 0, kv.getFamilyLength(), CellUtil.cloneQualifier(kv), 0,
       kv.getQualifierLength(), kv.getTimestamp(),
       KeyValue.Type.codeToType(kv.getTypeByte()), CellUtil.cloneValue(kv), 0,
       kv.getValueLength(), tagList);
     ((List<Cell>) updatedCells).add(newKV);
    }
   }
   put.getFamilyCellMap().remove(cf);
   // Update the family map
   put.getFamilyCellMap().put(cf, updatedCells);
  }
 }
}

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

byte[] bytes = put.getAttribute(AccessControlConstants.OP_ATTRIBUTE_ACL);
if (bytes != null) {
 if (cellFeaturesEnabled) {

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

byte[] bytes = put.getAttribute(AccessControlConstants.OP_ATTRIBUTE_ACL);
if (bytes != null) {
 if (cellFeaturesEnabled) {

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

@Override
public boolean preCheckAndPutAfterRowLock(final ObserverContext<RegionCoprocessorEnvironment> c,
  final byte[] row, final byte[] family, final byte[] qualifier,
  final CompareOperator opp, final ByteArrayComparable comparator, final Put put,
  final boolean result) throws IOException {
 if (put.getAttribute(CHECK_COVERING_PERM) != null) {
  // We had failure with table, cf and q perm checks and now giving a chance for cell
  // perm check
  TableName table = c.getEnvironment().getRegion().getRegionInfo().getTable();
  Map<byte[], ? extends Collection<byte[]>> families = makeFamilyMap(family, qualifier);
  AuthResult authResult = null;
  User user = getActiveUser(c);
  if (checkCoveringPermission(user, OpType.CHECK_AND_PUT, c.getEnvironment(), row, families,
    HConstants.LATEST_TIMESTAMP, Action.READ)) {
   authResult = AuthResult.allow(OpType.CHECK_AND_PUT.toString(),
     "Covering cell set", user, Action.READ, table, families);
  } else {
   authResult = AuthResult.deny(OpType.CHECK_AND_PUT.toString(),
     "Covering cell set", user, Action.READ, table, families);
  }
  AccessChecker.logResult(authResult);
  if (authorizationEnabled && !authResult.isAllowed()) {
   throw new AccessDeniedException("Insufficient permissions " + authResult.toContextString());
  }
 }
 return result;
}

代码示例来源:origin: opencb/opencga

public static boolean isSampleIndexTablePut(Put put) {
  byte[] s = put.getAttribute("s");
  return s != null && s[0] == 1;
}

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

@Override
public byte[] readRowAttribute(String name) throws IOException {
 return this.getPut().getAttribute(name);
}

代码示例来源:origin: rayokota/hgraphdb

public static void create(Table table, Creator... creators) {
  List<Mutation> batch = new ArrayList<>();
  for (Creator creator : creators) {
    Iterator<Put> insertions = creator.constructInsertions();
    insertions.forEachRemaining(put -> {
      byte[] isUniqueBytes = put.getAttribute(IS_UNIQUE);
      boolean isUnique = isUniqueBytes == null || Bytes.toBoolean(isUniqueBytes);
      if (isUnique) {
        create(table, creator, put);
      } else {
        batch.add(put);
      }
    });
  }
  write(table, batch);
}

代码示例来源:origin: co.cask.tigon/tigon-hbase-compat-0.96

@Override
public void prePut(ObserverContext<RegionCoprocessorEnvironment> ctx, Put put, WALEdit edit, Durability durability)
 throws IOException {
 if (put.getAttribute(Constants.DELTA_WRITE) != null) {
  // incremental write
  NavigableMap<byte[], List<Cell>> newFamilyMap = new TreeMap<byte[], List<Cell>>(Bytes.BYTES_COMPARATOR);
  for (Map.Entry<byte[], List<Cell>> entry : put.getFamilyCellMap().entrySet()) {
   List<Cell> newCells = new ArrayList<Cell>(entry.getValue().size());
   for (Cell cell : entry.getValue()) {
    // rewrite the cell value with a special prefix to identify it as a delta
    // for 0.98 we can update this to use cell tags
    byte[] newValue = Bytes.add(DELTA_MAGIC_PREFIX, CellUtil.cloneValue(cell));
    newCells.add(CellUtil.createCell(CellUtil.cloneRow(cell), CellUtil.cloneFamily(cell),
                     CellUtil.cloneQualifier(cell), cell.getTimestamp(), cell.getTypeByte(),
                     newValue));
   }
   newFamilyMap.put(entry.getKey(), newCells);
  }
  put.setFamilyCellMap(newFamilyMap);
 }
 // put completes normally with value prefix marker
}

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

@Override
public void prePut(ObserverContext<RegionCoprocessorEnvironment> c, Put put, WALEdit edit,
          Durability durability) throws IOException {
 if (put.getAttribute(DO_ABORT) != null) {
  // TODO: Change this so it throws a CP Abort Exception instead.
  RegionServerServices rss =
    ((HasRegionServerServices)c.getEnvironment()).getRegionServerServices();
  String str = "Aborting for test";
  LOG.info(str  + " " + rss.getServerName());
  rss.abort(str, new Throwable(str));
 }
}

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

@Override
public void prePut(final ObserverContext<RegionCoprocessorEnvironment> c, final Put put,
  final WALEdit edit, final Durability durability) throws IOException {
 if (put.getAttribute("ttl") != null) {
  Cell cell = put.getFamilyCellMap().values().stream().findFirst().get().get(0);
  ttls.put(
   TableName.valueOf(Bytes.toString(cell.getQualifierArray(), cell.getQualifierOffset(),
    cell.getQualifierLength())),
   Bytes.toLong(cell.getValueArray(), cell.getValueOffset(), cell.getValueLength()));
  c.bypass();
 } else if (put.getAttribute("versions") != null) {
  Cell cell = put.getFamilyCellMap().values().stream().findFirst().get().get(0);
  versions.put(
   TableName.valueOf(Bytes.toString(cell.getQualifierArray(), cell.getQualifierOffset(),
    cell.getQualifierLength())),
   Bytes.toInt(cell.getValueArray(), cell.getValueOffset(), cell.getValueLength()));
  c.bypass();
 }
}

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

@Override
 public void prePut(ObserverContext<RegionCoprocessorEnvironment> e, Put m, WALEdit edit,
   Durability durability) throws IOException {
  byte[] attribute = m.getAttribute(NON_VISIBILITY);
  byte[] cf = null;
  List<Cell> updatedCells = new ArrayList<>();
  if (attribute != null) {
   for (List<? extends Cell> edits : m.getFamilyCellMap().values()) {
    for (Cell cell : edits) {
     KeyValue kv = KeyValueUtil.ensureKeyValue(cell);
     if (cf == null) {
      cf = CellUtil.cloneFamily(kv);
     }
     Tag tag = new ArrayBackedTag((byte) NON_VIS_TAG_TYPE, attribute);
     List<Tag> tagList = new ArrayList<>(PrivateCellUtil.getTags(cell).size() + 1);
     tagList.add(tag);
     tagList.addAll(PrivateCellUtil.getTags(cell));
     Cell newcell = PrivateCellUtil.createCell(kv, tagList);
     ((List<Cell>) updatedCells).add(newcell);
    }
   }
   m.getFamilyCellMap().remove(cf);
   // Update the family map
   m.getFamilyCellMap().put(cf, updatedCells);
  }
 }
}

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

@Override
 public void prePut(ObserverContext<RegionCoprocessorEnvironment> e, Put put, WALEdit edit,
   Durability durability) throws IOException {
  Region region = e.getEnvironment().getRegion();
  if (!region.getRegionInfo().isMetaRegion()
    && !region.getRegionInfo().getTable().isSystemTable()) {
   if (put.getAttribute(TEST_ATR_KEY) != null) {
    LOG.debug("allow any put to happen " + region.getRegionInfo().getRegionNameAsString());
   } else {
    e.bypass();
   }
  }
 }
}

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

@Override
 public void prePut(ObserverContext<RegionCoprocessorEnvironment> e, Put put, WALEdit edit,
   Durability durability) throws IOException {
  Region region = e.getEnvironment().getRegion();
  if (!region.getRegionInfo().isMetaRegion()
    && !region.getRegionInfo().getTable().isSystemTable()) {
   if (put.getAttribute(TEST_ATR_KEY) != null) {
    LOG.debug("allow any put to happen " + region.getRegionInfo().getRegionNameAsString());
   } else {
    e.bypass();
   }
  }
 }
}

相关文章