Package org.apache.hadoop.hbase

Examples of org.apache.hadoop.hbase.Tag


        Cell cell = cellScanner.current();
        byte[] tag = LoadTestTool.generateData(random,
            minTagLength + random.nextInt(maxTagLength - minTagLength));
        tags = new ArrayList<Tag>();
        for (int n = 0; n < numTags; n++) {
          tags.add(new Tag((byte) 127, tag));
        }
        Cell updatedCell = new KeyValue(cell.getRowArray(), cell.getRowOffset(),
            cell.getRowLength(), cell.getFamilyArray(), cell.getFamilyOffset(),
            cell.getFamilyLength(), cell.getQualifierArray(), cell.getQualifierOffset(),
            cell.getQualifierLength(), cell.getTimestamp(), Type.codeToType(cell.getTypeByte()),
View Full Code Here


            CellScanner cellScanner = next.cellScanner();
            cellScanner.advance();
            KeyValue current = (KeyValue) cellScanner.current();
            if (CellUtil.matchingRow(current, row)) {
              assertEquals(1, TestCoprocessorForTags.tags.size());
              Tag tag = TestCoprocessorForTags.tags.get(0);
              assertEquals(bigTagLen, tag.getTagLength());
            } else {
              assertEquals(0, TestCoprocessorForTags.tags.size());
            }
          }
        } finally {
          if (scanner != null) {
            scanner.close();
          }
          TestCoprocessorForTags.checkTagPresence = false;
        }
        while (admin.getCompactionState(tableName) != CompactionState.NONE) {
          Thread.sleep(10);
        }
        TestCoprocessorForTags.checkTagPresence = true;
        scanner = table.getScanner(s);
        try {
          Result next = null;
          while ((next = scanner.next()) != null) {
            CellScanner cellScanner = next.cellScanner();
            cellScanner.advance();
            KeyValue current = (KeyValue) cellScanner.current();
            if (CellUtil.matchingRow(current, row)) {
              assertEquals(1, TestCoprocessorForTags.tags.size());
              Tag tag = TestCoprocessorForTags.tags.get(0);
              assertEquals(bigTagLen, tag.getTagLength());
            } else {
              assertEquals(0, TestCoprocessorForTags.tags.size());
            }
          }
        } finally {
View Full Code Here

    DataOutputStream dos = new DataOutputStream(cos);
    Codec codec = new KeyValueCodecWithTags();
    Codec.Encoder encoder = codec.getEncoder(dos);
    final KeyValue kv1 = new KeyValue(Bytes.toBytes("r"), Bytes.toBytes("f"), Bytes.toBytes("1"),
        HConstants.LATEST_TIMESTAMP, Bytes.toBytes("1"), new Tag[] {
            new Tag((byte) 1, Bytes.toBytes("teststring1")),
            new Tag((byte) 2, Bytes.toBytes("teststring2")) });
    final KeyValue kv2 = new KeyValue(Bytes.toBytes("r"), Bytes.toBytes("f"), Bytes.toBytes("2"),
        HConstants.LATEST_TIMESTAMP, Bytes.toBytes("2"), new Tag[] { new Tag((byte) 1,
            Bytes.toBytes("teststring3")), });
    final KeyValue kv3 = new KeyValue(Bytes.toBytes("r"), Bytes.toBytes("f"), Bytes.toBytes("3"),
        HConstants.LATEST_TIMESTAMP, Bytes.toBytes("3"), new Tag[] {
            new Tag((byte) 2, Bytes.toBytes("teststring4")),
            new Tag((byte) 2, Bytes.toBytes("teststring5")),
            new Tag((byte) 1, Bytes.toBytes("teststring6")) });

    encoder.write(kv1);
    encoder.write(kv2);
    encoder.write(kv3);
    encoder.flush();
    dos.close();
    long offset = cos.getCount();
    CountingInputStream cis = new CountingInputStream(new ByteArrayInputStream(baos.toByteArray()));
    DataInputStream dis = new DataInputStream(cis);
    Codec.Decoder decoder = codec.getDecoder(dis);
    assertTrue(decoder.advance());
    Cell c = decoder.current();
    assertTrue(CellComparator.equals(c, kv1));
    List<Tag> tags = Tag.asList(c.getTagsArray(), c.getTagsOffset(), c.getTagsLength());
    assertEquals(2, tags.size());
    Tag tag = tags.get(0);
    assertEquals(1, tag.getType());
    assertTrue(Bytes.equals(Bytes.toBytes("teststring1"), tag.getValue()));
    tag = tags.get(1);
    assertEquals(2, tag.getType());
    assertTrue(Bytes.equals(Bytes.toBytes("teststring2"), tag.getValue()));
    assertTrue(decoder.advance());
    c = decoder.current();
    assertTrue(CellComparator.equals(c, kv2));
    tags = Tag.asList(c.getTagsArray(), c.getTagsOffset(), c.getTagsLength());
    assertEquals(1, tags.size());
    tag = tags.get(0);
    assertEquals(1, tag.getType());
    assertTrue(Bytes.equals(Bytes.toBytes("teststring3"), tag.getValue()));
    assertTrue(decoder.advance());
    c = decoder.current();
    assertTrue(CellComparator.equals(c, kv3));
    tags = Tag.asList(c.getTagsArray(), c.getTagsOffset(), c.getTagsLength());
    assertEquals(3, tags.size());
    tag = tags.get(0);
    assertEquals(2, tag.getType());
    assertTrue(Bytes.equals(Bytes.toBytes("teststring4"), tag.getValue()));
    tag = tags.get(1);
    assertEquals(2, tag.getType());
    assertTrue(Bytes.equals(Bytes.toBytes("teststring5"), tag.getValue()));
    tag = tags.get(2);
    assertEquals(1, tag.getType());
    assertTrue(Bytes.equals(Bytes.toBytes("teststring6"), tag.getValue()));
    assertFalse(decoder.advance());
    dis.close();
    assertEquals(offset, cis.getCount());
  }
View Full Code Here

    DataOutputStream dos = new DataOutputStream(cos);
    Codec codec = new CellCodecWithTags();
    Codec.Encoder encoder = codec.getEncoder(dos);
    final Cell cell1 = new KeyValue(Bytes.toBytes("r"), Bytes.toBytes("f"), Bytes.toBytes("1"),
        HConstants.LATEST_TIMESTAMP, Bytes.toBytes("1"), new Tag[] {
            new Tag((byte) 1, Bytes.toBytes("teststring1")),
            new Tag((byte) 2, Bytes.toBytes("teststring2")) });
    final Cell cell2 = new KeyValue(Bytes.toBytes("r"), Bytes.toBytes("f"), Bytes.toBytes("2"),
        HConstants.LATEST_TIMESTAMP, Bytes.toBytes("2"), new Tag[] { new Tag((byte) 1,
            Bytes.toBytes("teststring3")), });
    final Cell cell3 = new KeyValue(Bytes.toBytes("r"), Bytes.toBytes("f"), Bytes.toBytes("3"),
        HConstants.LATEST_TIMESTAMP, Bytes.toBytes("3"), new Tag[] {
            new Tag((byte) 2, Bytes.toBytes("teststring4")),
            new Tag((byte) 2, Bytes.toBytes("teststring5")),
            new Tag((byte) 1, Bytes.toBytes("teststring6")) });

    encoder.write(cell1);
    encoder.write(cell2);
    encoder.write(cell3);
    encoder.flush();
    dos.close();
    long offset = cos.getCount();
    CountingInputStream cis = new CountingInputStream(new ByteArrayInputStream(baos.toByteArray()));
    DataInputStream dis = new DataInputStream(cis);
    Codec.Decoder decoder = codec.getDecoder(dis);
    assertTrue(decoder.advance());
    Cell c = decoder.current();
    assertTrue(CellComparator.equals(c, cell1));
    List<Tag> tags = Tag.asList(c.getTagsArray(), c.getTagsOffset(), c.getTagsLength());
    assertEquals(2, tags.size());
    Tag tag = tags.get(0);
    assertEquals(1, tag.getType());
    assertTrue(Bytes.equals(Bytes.toBytes("teststring1"), tag.getValue()));
    tag = tags.get(1);
    assertEquals(2, tag.getType());
    assertTrue(Bytes.equals(Bytes.toBytes("teststring2"), tag.getValue()));
    assertTrue(decoder.advance());
    c = decoder.current();
    assertTrue(CellComparator.equals(c, cell2));
    tags = Tag.asList(c.getTagsArray(), c.getTagsOffset(), c.getTagsLength());
    assertEquals(1, tags.size());
    tag = tags.get(0);
    assertEquals(1, tag.getType());
    assertTrue(Bytes.equals(Bytes.toBytes("teststring3"), tag.getValue()));
    assertTrue(decoder.advance());
    c = decoder.current();
    assertTrue(CellComparator.equals(c, cell3));
    tags = Tag.asList(c.getTagsArray(), c.getTagsOffset(), c.getTagsLength());
    assertEquals(3, tags.size());
    tag = tags.get(0);
    assertEquals(2, tag.getType());
    assertTrue(Bytes.equals(Bytes.toBytes("teststring4"), tag.getValue()));
    tag = tags.get(1);
    assertEquals(2, tag.getType());
    assertTrue(Bytes.equals(Bytes.toBytes("teststring5"), tag.getValue()));
    tag = tags.get(2);
    assertEquals(1, tag.getType());
    assertTrue(Bytes.equals(Bytes.toBytes("teststring6"), tag.getValue()));
    assertFalse(decoder.advance());
    dis.close();
    assertEquals(offset, cis.getCount());
  }
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

     }
     List<Permission> results = Lists.newArrayList();
     Iterator<Tag> tagsIterator = CellUtil.tagsIterator(cell.getTagsArray(), cell.getTagsOffset(),
        cell.getTagsLength());
     while (tagsIterator.hasNext()) {
       Tag tag = tagsIterator.next();
       if (tag.getType() == ACL_TAG_TYPE) {
         // Deserialize the table permissions from the KV
         ListMultimap<String,Permission> kvPerms = ProtobufUtil.toUsersAndPermissions(
           AccessControlProtos.UsersAndPermissions.newBuilder().mergeFrom(
             tag.getBuffer(), tag.getTagOffset(), tag.getTagLength()).build());
         // Are there permissions for this user?
         List<Permission> userPerms = kvPerms.get(user.getShortName());
         if (userPerms != null) {
           results.addAll(userPerms);
         }
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

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.