• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java SimplePositionedByteRange类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.hadoop.hbase.util.SimplePositionedByteRange的典型用法代码示例。如果您正苦于以下问题:Java SimplePositionedByteRange类的具体用法?Java SimplePositionedByteRange怎么用?Java SimplePositionedByteRange使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



SimplePositionedByteRange类属于org.apache.hadoop.hbase.util包,在下文中一共展示了SimplePositionedByteRange类的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: deserialize

import org.apache.hadoop.hbase.util.SimplePositionedByteRange; //导入依赖的package包/类
public IndexMetadata deserialize(Result result) {
    byte[] bytes = result.getRow();
    PositionedByteRange buffer = new SimplePositionedByteRange(bytes);
    String label = OrderedBytes.decodeString(buffer);
    String propertyKey = OrderedBytes.decodeString(buffer);
    ElementType type = OrderedBytes.decodeInt8(buffer) == 1 ? ElementType.VERTEX : ElementType.EDGE;
    Cell uniqueCell = result.getColumnLatestCell(Constants.DEFAULT_FAMILY_BYTES, Constants.UNIQUE_BYTES);
    boolean isUnique = ValueUtils.deserialize(CellUtil.cloneValue(uniqueCell));
    Cell stateCell = result.getColumnLatestCell(Constants.DEFAULT_FAMILY_BYTES, Constants.INDEX_STATE_BYTES);
    State state = State.valueOf(ValueUtils.deserialize(CellUtil.cloneValue(stateCell)));
    Cell createdAtCell = result.getColumnLatestCell(Constants.DEFAULT_FAMILY_BYTES, Constants.CREATED_AT_BYTES);
    Long createdAt = ValueUtils.deserialize(CellUtil.cloneValue(createdAtCell));
    Cell updatedAtCell = result.getColumnLatestCell(Constants.DEFAULT_FAMILY_BYTES, Constants.UPDATED_AT_BYTES);
    Long updatedAt = ValueUtils.deserialize(CellUtil.cloneValue(updatedAtCell));
    return new IndexMetadata(type, label, propertyKey, isUnique, state, createdAt, updatedAt);
}
 
开发者ID:rayokota,项目名称:hgraphdb,代码行数:17,代码来源:IndexMetadataModel.java


示例2: testReadWriteSkippable

import org.apache.hadoop.hbase.util.SimplePositionedByteRange; //导入依赖的package包/类
@Test
public void testReadWriteSkippable() {
  PositionedByteRange buff = new SimplePositionedByteRange(14);
  for (OrderedString t : new OrderedString[] {
      OrderedString.ASCENDING, OrderedString.DESCENDING
  }) {
    for (byte[] term : TERMINATORS) {
      for (String val : VALUES_STRINGS) {
        buff.setPosition(0);
        DataType<String> type = new TerminatedWrapper<String>(t, term);
        assertEquals(val.length() + 2 + term.length, type.encode(buff, val));
        buff.setPosition(0);
        assertEquals(val, type.decode(buff));
        assertEquals(val.length() + 2 + term.length, buff.getPosition());
      }
    }
  }
}
 
开发者ID:tenggyut,项目名称:HIndex,代码行数:19,代码来源:TestTerminatedWrapper.java


示例3: testReadWriteNonSkippable

import org.apache.hadoop.hbase.util.SimplePositionedByteRange; //导入依赖的package包/类
@Test
public void testReadWriteNonSkippable() {
  PositionedByteRange buff = new SimplePositionedByteRange(12);
  for (Order ord : new Order[] { Order.ASCENDING, Order.DESCENDING }) {
    for (byte[] term : TERMINATORS) {
      for (byte[] val : VALUES_BYTES) {
        buff.setPosition(0);
        DataType<byte[]> type = new TerminatedWrapper<byte[]>(new RawBytes(ord), term);
        assertEquals(val.length + term.length, type.encode(buff, val));
        buff.setPosition(0);
        assertArrayEquals(val, type.decode(buff));
        assertEquals(val.length + term.length, buff.getPosition());
      }
    }
  }
}
 
开发者ID:tenggyut,项目名称:HIndex,代码行数:17,代码来源:TestTerminatedWrapper.java


示例4: testSkipSkippable

import org.apache.hadoop.hbase.util.SimplePositionedByteRange; //导入依赖的package包/类
@Test
public void testSkipSkippable() {
  PositionedByteRange buff = new SimplePositionedByteRange(14);
  for (OrderedString t : new OrderedString[] {
      OrderedString.ASCENDING, OrderedString.DESCENDING
  }) {
    for (byte[] term : TERMINATORS) {
      for (String val : VALUES_STRINGS) {
        buff.setPosition(0);
        DataType<String> type = new TerminatedWrapper<String>(t, term);
        int expected = val.length() + 2 + term.length;
        assertEquals(expected, type.encode(buff, val));
        buff.setPosition(0);
        assertEquals(expected, type.skip(buff));
        assertEquals(expected, buff.getPosition());
      }
    }
  }
}
 
开发者ID:tenggyut,项目名称:HIndex,代码行数:20,代码来源:TestTerminatedWrapper.java


示例5: testSkipNonSkippable

import org.apache.hadoop.hbase.util.SimplePositionedByteRange; //导入依赖的package包/类
@Test
public void testSkipNonSkippable() {
  PositionedByteRange buff = new SimplePositionedByteRange(12);
  for (Order ord : new Order[] { Order.ASCENDING, Order.DESCENDING }) {
    for (byte[] term : TERMINATORS) {
      for (byte[] val : VALUES_BYTES) {
        buff.setPosition(0);
        DataType<byte[]> type = new TerminatedWrapper<byte[]>(new RawBytes(ord), term);
        int expected = type.encode(buff, val);
        buff.setPosition(0);
        assertEquals(expected, type.skip(buff));
        assertEquals(expected, buff.getPosition());
      }
    }
  }
}
 
开发者ID:tenggyut,项目名称:HIndex,代码行数:17,代码来源:TestTerminatedWrapper.java


示例6: testReadWrite

import org.apache.hadoop.hbase.util.SimplePositionedByteRange; //导入依赖的package包/类
@Test
public void testReadWrite() {
  for (int limit : limits) {
    PositionedByteRange buff = new SimplePositionedByteRange(limit);
    for (Order ord : new Order[] { Order.ASCENDING, Order.DESCENDING }) {
      for (byte[] val : VALUES) {
        buff.setPosition(0);
        DataType<byte[]> type = new FixedLengthWrapper<byte[]>(new RawBytes(ord), limit);
        assertEquals(limit, type.encode(buff, val));
        buff.setPosition(0);
        byte[] actual = type.decode(buff);
        assertTrue("Decoding output differs from expected", 
          Bytes.equals(val, 0, val.length, actual, 0, val.length));
        buff.setPosition(0);
        assertEquals(limit, type.skip(buff));
      }
    }
  }
}
 
开发者ID:tenggyut,项目名称:HIndex,代码行数:20,代码来源:TestFixedLengthWrapper.java


示例7: testReadWrite

import org.apache.hadoop.hbase.util.SimplePositionedByteRange; //导入依赖的package包/类
@Test
public void testReadWrite() {
  for (Order ord : new Order[] { Order.ASCENDING, Order.DESCENDING }) {
    RawString type =
        Order.ASCENDING == ord ? RawString.ASCENDING : RawString.DESCENDING;
    for (String val : VALUES) {
      PositionedByteRange buff = new SimplePositionedByteRange(Bytes.toBytes(val).length);
      assertEquals(buff.getLength(), type.encode(buff, val));
      byte[] expected = Bytes.toBytes(val);
      ord.apply(expected);
      assertArrayEquals(expected, buff.getBytes());
      buff.setPosition(0);
      assertEquals(val, type.decode(buff));
      buff.setPosition(0);
      assertEquals(buff.getLength(), type.skip(buff));
      assertEquals(buff.getLength(), buff.getPosition());
    }
  }
}
 
开发者ID:tenggyut,项目名称:HIndex,代码行数:20,代码来源:TestRawString.java


示例8: testReadWrite

import org.apache.hadoop.hbase.util.SimplePositionedByteRange; //导入依赖的package包/类
@Test
public void testReadWrite() {
  for (int limit : limits) {
    PositionedByteRange buff = new SimplePositionedByteRange(limit);
    for (Order ord : new Order[] { Order.ASCENDING, Order.DESCENDING }) {
      for (byte[] val : VALUES) {
        buff.setPosition(0);
        DataType<byte[]> type = new FixedLengthWrapper<byte[]>(new RawBytes(ord), limit);
        assertEquals(limit, type.encode(buff, val));
        byte[] expected = Arrays.copyOf(val, limit);
        buff.setPosition(0);
        byte[] actual = type.decode(buff);
        assertArrayEquals(expected, actual);
        buff.setPosition(0);
        assertEquals(limit, type.skip(buff));
      }
    }
  }
}
 
开发者ID:cloud-software-foundation,项目名称:c5,代码行数:20,代码来源:TestFixedLengthWrapper.java


示例9: testRoundTrip

import org.apache.hadoop.hbase.util.SimplePositionedByteRange; //导入依赖的package包/类
/**
 * Basic test to verify utility methods in {@link PBType} and delegation to protobuf works.
 */
@Test
public void testRoundTrip() {
  final Cell cell = new KeyValue(Bytes.toBytes("row"), Bytes.toBytes("fam"),
    Bytes.toBytes("qual"), Bytes.toBytes("val"));
  CellProtos.Cell c = ProtobufUtil.toCell(cell), decoded;
  PositionedByteRange pbr = new SimplePositionedByteRange(c.getSerializedSize());
  pbr.setPosition(0);
  int encodedLength = CODEC.encode(pbr, c);
  pbr.setPosition(0);
  decoded = CODEC.decode(pbr);
  assertEquals(encodedLength, pbr.getPosition());
  assertTrue(CellComparator.equals(cell, ProtobufUtil.toCell(decoded)));
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:17,代码来源:TestPBCell.java


示例10: deserialize

import org.apache.hadoop.hbase.util.SimplePositionedByteRange; //导入依赖的package包/类
public LabelConnection deserialize(Result result) {
    byte[] bytes = result.getRow();
    PositionedByteRange buffer = new SimplePositionedByteRange(bytes);
    String outVertexLabel = OrderedBytes.decodeString(buffer);
    String edgeLabel = OrderedBytes.decodeString(buffer);
    String inVertexLabel = OrderedBytes.decodeString(buffer);
    Cell createdAtCell = result.getColumnLatestCell(Constants.DEFAULT_FAMILY_BYTES, Constants.CREATED_AT_BYTES);
    Long createdAt = ValueUtils.deserialize(CellUtil.cloneValue(createdAtCell));
    return new LabelConnection(outVertexLabel, edgeLabel, inVertexLabel, createdAt);
}
 
开发者ID:rayokota,项目名称:hgraphdb,代码行数:11,代码来源:LabelConnectionModel.java


示例11: decode

import org.apache.hadoop.hbase.util.SimplePositionedByteRange; //导入依赖的package包/类
@Override
public T decode(PositionedByteRange src) {
  if (src.getRemaining() < length) {
    throw new IllegalArgumentException("Not enough buffer remaining. src.offset: "
        + src.getOffset() + " src.length: " + src.getLength() + " src.position: "
        + src.getPosition() + " max length: " + length);
  }
  // create a copy range limited to length bytes. boo.
  PositionedByteRange b = new SimplePositionedByteRange(length);
  src.get(b.getBytes());
  return base.decode(b);
}
 
开发者ID:tenggyut,项目名称:HIndex,代码行数:13,代码来源:FixedLengthWrapper.java


示例12: testNonNullableNullExtension

import org.apache.hadoop.hbase.util.SimplePositionedByteRange; //导入依赖的package包/类
/**
 * Verify null extension respects the type's isNullable field.
 */
@Test(expected = NullPointerException.class)
public void testNonNullableNullExtension() {
  Struct s = new StructBuilder()
      .add(new RawStringTerminated("|")) // not nullable
      .toStruct();
  PositionedByteRange buf = new SimplePositionedByteRange(4);
  s.encode(buf, new Object[1]);
}
 
开发者ID:tenggyut,项目名称:HIndex,代码行数:12,代码来源:TestStructNullExtension.java


示例13: testEncodedLength

import org.apache.hadoop.hbase.util.SimplePositionedByteRange; //导入依赖的package包/类
@Test
public void testEncodedLength() {
  PositionedByteRange buff = new SimplePositionedByteRange(20);
  for (DataType<byte[]> type : new OrderedBlob[] { OrderedBlob.ASCENDING, OrderedBlob.DESCENDING }) {
    for (byte[] val : VALUES) {
      buff.setPosition(0);
      type.encode(buff, val);
      assertEquals(
        "encodedLength does not match actual, " + Bytes.toStringBinary(val),
        buff.getPosition(), type.encodedLength(val));
    }
  }
}
 
开发者ID:tenggyut,项目名称:HIndex,代码行数:14,代码来源:TestOrderedBlob.java


示例14: testEncodeDecode

import org.apache.hadoop.hbase.util.SimplePositionedByteRange; //导入依赖的package包/类
@Test
public void testEncodeDecode() {
  Integer intVal = Integer.valueOf(10);
  String strVal = "hello";
  PositionedByteRange buff = new SimplePositionedByteRange(10);
  SampleUnion1 type = new SampleUnion1();

  type.encode(buff, intVal);
  buff.setPosition(0);
  assertTrue(0 == intVal.compareTo(type.decodeA(buff)));
  buff.setPosition(0);
  type.encode(buff, strVal);
  buff.setPosition(0);
  assertTrue(0 == strVal.compareTo(type.decodeB(buff)));
}
 
开发者ID:tenggyut,项目名称:HIndex,代码行数:16,代码来源:TestUnion2.java


示例15: testSkip

import org.apache.hadoop.hbase.util.SimplePositionedByteRange; //导入依赖的package包/类
@Test
public void testSkip() {
  Integer intVal = Integer.valueOf(10);
  String strVal = "hello";
  PositionedByteRange buff = new SimplePositionedByteRange(10);
  SampleUnion1 type = new SampleUnion1();

  int len = type.encode(buff, intVal);
  buff.setPosition(0);
  assertEquals(len, type.skip(buff));
  buff.setPosition(0);
  len = type.encode(buff, strVal);
  buff.setPosition(0);
  assertEquals(len, type.skip(buff));
}
 
开发者ID:tenggyut,项目名称:HIndex,代码行数:16,代码来源:TestUnion2.java


示例16: testEncodedLength

import org.apache.hadoop.hbase.util.SimplePositionedByteRange; //导入依赖的package包/类
@Test
public void testEncodedLength() {
  PositionedByteRange buff = new SimplePositionedByteRange(20);
  for (DataType<byte[]> type :
    new OrderedBlobVar[] { OrderedBlobVar.ASCENDING, OrderedBlobVar.DESCENDING }) {
    for (byte[] val : VALUES) {
      buff.setPosition(0);
      type.encode(buff, val);
      assertEquals(
        "encodedLength does not match actual, " + Bytes.toStringBinary(val),
        buff.getPosition(), type.encodedLength(val));
    }
  }
}
 
开发者ID:tenggyut,项目名称:HIndex,代码行数:15,代码来源:TestOrderedBlobVar.java


示例17: testEncodedLength

import org.apache.hadoop.hbase.util.SimplePositionedByteRange; //导入依赖的package包/类
@Test
public void testEncodedLength() {
  PositionedByteRange buff = new SimplePositionedByteRange(20);
  for (DataType<String> type : new OrderedString[] { OrderedString.ASCENDING, OrderedString.DESCENDING }) {
    for (String val : VALUES) {
      buff.setPosition(0);
      type.encode(buff, val);
      assertEquals(
        "encodedLength does not match actual, " + val,
        buff.getPosition(), type.encodedLength(val));
    }
  }
}
 
开发者ID:tenggyut,项目名称:HIndex,代码行数:14,代码来源:TestOrderedString.java


示例18: testOrderPreservation

import org.apache.hadoop.hbase.util.SimplePositionedByteRange; //导入依赖的package包/类
@Test
@SuppressWarnings("unchecked")
public void testOrderPreservation() throws Exception {
  Object[] vals = new Object[constructorArgs.length];
  PositionedByteRange[] encodedGeneric = new PositionedByteRange[constructorArgs.length];
  PositionedByteRange[] encodedSpecialized = new PositionedByteRange[constructorArgs.length];
  Constructor<?> ctor = specialized.encodedClass().getConstructor(Object[].class);
  for (int i = 0; i < vals.length; i++) {
    vals[i] = ctor.newInstance(new Object[] { constructorArgs[i] });
    encodedGeneric[i] = new SimplePositionedByteRange(generic.encodedLength(constructorArgs[i]));
    encodedSpecialized[i] = new SimplePositionedByteRange(specialized.encodedLength(vals[i]));
  }

  // populate our arrays
  for (int i = 0; i < vals.length; i++) {
    generic.encode(encodedGeneric[i], constructorArgs[i]);
    encodedGeneric[i].setPosition(0);
    specialized.encode(encodedSpecialized[i], vals[i]);
    encodedSpecialized[i].setPosition(0);
    assertArrayEquals(encodedGeneric[i].getBytes(), encodedSpecialized[i].getBytes());
  }

  Arrays.sort(vals);
  Arrays.sort(encodedGeneric);
  Arrays.sort(encodedSpecialized);

  for (int i = 0; i < vals.length; i++) {
    assertEquals(
      "Struct encoder does not preserve sort order at position " + i,
      vals[i],
      ctor.newInstance(new Object[] { generic.decode(encodedGeneric[i]) }));
    assertEquals(
      "Specialized encoder does not preserve sort order at position " + i,
      vals[i], specialized.decode(encodedSpecialized[i]));
  }
}
 
开发者ID:tenggyut,项目名称:HIndex,代码行数:37,代码来源:TestStruct.java


示例19: testRoundTrip

import org.apache.hadoop.hbase.util.SimplePositionedByteRange; //导入依赖的package包/类
/**
 * Basic test to verify utility methods in {@link PBType} and delegation to protobuf works.
 */
@Test
public void testRoundTrip() {
  final Cell cell = new KeyValue(Bytes.toBytes("row"), Bytes.toBytes("fam"),
      Bytes.toBytes("qual"), Bytes.toBytes("val"));
  CellProtos.Cell c = ProtobufUtil.toCell(cell), decoded;
  PositionedByteRange pbr = new SimplePositionedByteRange(c.getSerializedSize());
  pbr.setPosition(0);
  int encodedLength = CODEC.encode(pbr, c);
  pbr.setPosition(0);
  decoded = CODEC.decode(pbr);
  assertEquals(encodedLength, pbr.getPosition());
  assertTrue(CellUtil.equals(cell, ProtobufUtil
      .toCell(ExtendedCellBuilderFactory.create(CellBuilderType.SHALLOW_COPY), decoded)));
}
 
开发者ID:apache,项目名称:hbase,代码行数:18,代码来源:TestPBCell.java



注:本文中的org.apache.hadoop.hbase.util.SimplePositionedByteRange类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java PacketContext类代码示例发布时间:2022-05-23
下一篇:
Java SetOnce类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap