Package org.apache.hadoop.hbase

Examples of org.apache.hadoop.hbase.Tag


  */
  private static Cell tagReplayLogSequenceNumber(long seqId, Cell cell) {
    // Tag puts with original sequence number if there is no LOG_REPLAY_TAG yet
    boolean needAddRecoveryTag = true;
    if (cell.getTagsLength() > 0) {
      Tag tmpTag = Tag.getTag(cell.getTagsArray(), cell.getTagsOffset(), cell.getTagsLength(),
        TagType.LOG_REPLAY_TAG_TYPE);
      if (tmpTag != null) {
        // found an existing log replay tag so reuse it
        needAddRecoveryTag = false;
      }
    }
    if (needAddRecoveryTag) {
      List<Tag> newTags = new ArrayList<Tag>();
      Tag replayTag = new Tag(TagType.LOG_REPLAY_TAG_TYPE, Bytes.toBytes(seqId));
      newTags.add(replayTag);
      return KeyValue.cloneAndAddTags(cell, newTags);
    }
    return cell;
  }
View Full Code Here


          for (Cell cell : edits) {
            KeyValue kv = KeyValueUtil.ensureKeyValue(cell);
            if (cf == null) {
              cf = kv.getFamily();
            }
            Tag tag = new Tag(TAG_TYPE, attribute);
            List<Tag> tagList = new ArrayList<Tag>();
            tagList.add(tag);

            KeyValue newKV = new KeyValue(kv.getRow(), 0, kv.getRowLength(), kv.getFamily(), 0,
                kv.getFamilyLength(), kv.getQualifier(), 0, kv.getQualifierLength(),
View Full Code Here

  }

  private KeyValue createKVWithTags(int noOfTags) {
    List<Tag> tags = new ArrayList<Tag>();
    for (int i = 0; i < noOfTags; i++) {
      tags.add(new Tag((byte) i, "tagValue" + i));
    }
    KeyValue kv = new KeyValue(ROW, CF, Q, 1234L, V, tags);
    return kv;
  }
View Full Code Here

    final byte[] QUALIFIER = Bytes.toBytes("q1");
    final byte[] VALUE = Bytes.toBytes("v");
    int kvCount = 1000000;
    List<KeyValue> kvs = new ArrayList<KeyValue>(kvCount);
    int totalSize = 0;
    Tag[] tags = new Tag[] { new Tag((byte) 1, "tag1") };
    for (int i = 0; i < kvCount; i++) {
      KeyValue kv = new KeyValue(Bytes.toBytes(i), FAMILY, QUALIFIER, i, VALUE, tags);
      kv.setSequenceId(i);
      kvs.add(kv);
      totalSize += kv.getLength() + Bytes.SIZEOF_LONG;
View Full Code Here

    Byte serializationFormat = null;
    if (cell.getTagsLength() > 0) {
      Iterator<Tag> tagsIterator = CellUtil.tagsIterator(cell.getTagsArray(), cell.getTagsOffset(),
          cell.getTagsLength());
      while (tagsIterator.hasNext()) {
        Tag tag = tagsIterator.next();
        if (tag.getType() == TagType.VISIBILITY_EXP_SERIALIZATION_FORMAT_TAG_TYPE) {
          serializationFormat = tag.getBuffer()[tag.getTagOffset()];
        } else if (tag.getType() == VISIBILITY_TAG_TYPE) {
          tags.add(tag);
        }
      }
    }
    return serializationFormat;
View Full Code Here

      return false;
    }
    Iterator<Tag> tagsIterator = CellUtil.tagsIterator(cell.getTagsArray(), cell.getTagsOffset(),
        cell.getTagsLength());
    while (tagsIterator.hasNext()) {
      Tag tag = tagsIterator.next();
      if (tag.getType() == VISIBILITY_TAG_TYPE) {
        return true;
      }
    }
    return false;
  }
View Full Code Here

      tags.add(VisibilityUtils.SORTED_ORDINAL_SERIALIZATION_FORMAT_TAG);
    }
    if (node.isSingleNode()) {
      getLabelOrdinals(node, labelOrdinals, auths, checkAuths, ordinalProvider);
      writeLabelOrdinalsToStream(labelOrdinals, dos);
      tags.add(new Tag(VISIBILITY_TAG_TYPE, baos.toByteArray()));
      baos.reset();
    } else {
      NonLeafExpressionNode nlNode = (NonLeafExpressionNode) node;
      if (nlNode.getOperator() == Operator.OR) {
        for (ExpressionNode child : nlNode.getChildExps()) {
          getLabelOrdinals(child, labelOrdinals, auths, checkAuths, ordinalProvider);
          writeLabelOrdinalsToStream(labelOrdinals, dos);
          tags.add(new Tag(VISIBILITY_TAG_TYPE, baos.toByteArray()));
          baos.reset();
          labelOrdinals.clear();
        }
      } else {
        getLabelOrdinals(nlNode, labelOrdinals, auths, checkAuths, ordinalProvider);
        writeLabelOrdinalsToStream(labelOrdinals, dos);
        tags.add(new Tag(VISIBILITY_TAG_TYPE, baos.toByteArray()));
        baos.reset();
      }
    }
    return tags;
  }
View Full Code Here

        if (cell.getTagsLength() > 0) {
          Iterator<Tag> tagsItr = CellUtil.tagsIterator(cell.getTagsArray(), cell.getTagsOffset(),
              cell.getTagsLength());
          while (tagsItr.hasNext()) {
            boolean includeKV = true;
            Tag tag = tagsItr.next();
            if (tag.getType() == VISIBILITY_TAG_TYPE) {
              visibilityTagPresent = true;
              int offset = tag.getTagOffset();
              int endOffset = offset + tag.getTagLength();
              while (offset < endOffset) {
                Pair<Integer, Integer> result = StreamUtils
                    .readRawVarint32(tag.getBuffer(), offset);
                int currLabelOrdinal = result.getFirst();
                if (currLabelOrdinal < 0) {
                  // check for the absence of this label in the Scan Auth labels
                  // ie. to check BitSet corresponding bit is 0
                  int temp = -currLabelOrdinal;
View Full Code Here

    // with new cells including the ACL data
    for (Map.Entry<byte[], List<Cell>> e: familyMap.entrySet()) {
      List<Cell> newCells = Lists.newArrayList();
      for (Cell cell: e.getValue()) {
        // Prepend the supplied perms in a new ACL tag to an update list of tags for the cell
        List<Tag> tags = Lists.newArrayList(new Tag(AccessControlLists.ACL_TAG_TYPE, perms));
        if (cell.getTagsLength() > 0) {
          Iterator<Tag> tagIterator = CellUtil.tagsIterator(cell.getTagsArray(),
            cell.getTagsOffset(), cell.getTagsLength());
          while (tagIterator.hasNext()) {
            tags.add(tagIterator.next());
View Full Code Here

      // Save an object allocation where we can
      if (oldCell.getTagsLength() > 0) {
        Iterator<Tag> tagIterator = CellUtil.tagsIterator(oldCell.getTagsArray(),
          oldCell.getTagsOffset(), oldCell.getTagsLength());
        while (tagIterator.hasNext()) {
          Tag tag = tagIterator.next();
          if (tag.getType() != AccessControlLists.ACL_TAG_TYPE) {
            // Not an ACL tag, just carry it through
            if (LOG.isTraceEnabled()) {
              LOG.trace("Carrying forward tag from " + oldCell + ": type " + tag.getType() +
                " length " + tag.getTagLength());
            }
            tags.add(tag);
          } else {
            // Merge the perms from the older ACL into the current permission set
            ListMultimap<String,Permission> kvPerms = ProtobufUtil.toUsersAndPermissions(
              AccessControlProtos.UsersAndPermissions.newBuilder().mergeFrom(
                tag.getBuffer(), tag.getTagOffset(), tag.getTagLength()).build());
            perms.putAll(kvPerms);
          }
        }
      }
    }

    // Do we have an ACL on the operation?
    byte[] aclBytes = mutation.getACL();
    if (aclBytes != null) {
      // Yes, use it
      tags.add(new Tag(AccessControlLists.ACL_TAG_TYPE, aclBytes));
    } else {
      // No, use what we carried forward
      if (perms != null) {
        // TODO: If we collected ACLs from more than one tag we may have a
        // List<Permission> of size > 1, this can be collapsed into a single
        // Permission
        if (LOG.isTraceEnabled()) {
          LOG.trace("Carrying forward ACLs from " + oldCell + ": " + perms);
        }
        tags.add(new Tag(AccessControlLists.ACL_TAG_TYPE,
          ProtobufUtil.toUsersAndPermissions(perms).toByteArray()));
      }
    }

    // If we have no tags to add, just return
View Full Code Here

TOP

Related Classes of org.apache.hadoop.hbase.Tag

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.