本文整理汇总了Java中org.apache.hadoop.hbase.util.PositionedByteRange类的典型用法代码示例。如果您正苦于以下问题:Java PositionedByteRange类的具体用法?Java PositionedByteRange怎么用?Java PositionedByteRange使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PositionedByteRange类属于org.apache.hadoop.hbase.util包,在下文中一共展示了PositionedByteRange类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: testReadWrite
import org.apache.hadoop.hbase.util.PositionedByteRange; //导入依赖的package包/类
@Test
public void testReadWrite() {
for (int limit : limits) {
PositionedByteRange buff = new SimplePositionedMutableByteRange(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:fengchen8086,项目名称:ditb,代码行数:20,代码来源:TestFixedLengthWrapper.java
示例2: testReadWriteSkippable
import org.apache.hadoop.hbase.util.PositionedByteRange; //导入依赖的package包/类
@Test
public void testReadWriteSkippable() {
PositionedByteRange buff = new SimplePositionedMutableByteRange(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:fengchen8086,项目名称:ditb,代码行数:19,代码来源:TestTerminatedWrapper.java
示例3: testSkipSkippable
import org.apache.hadoop.hbase.util.PositionedByteRange; //导入依赖的package包/类
@Test
public void testSkipSkippable() {
PositionedByteRange buff = new SimplePositionedMutableByteRange(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:fengchen8086,项目名称:ditb,代码行数:20,代码来源:TestTerminatedWrapper.java
示例4: testReadWriteNonSkippable
import org.apache.hadoop.hbase.util.PositionedByteRange; //导入依赖的package包/类
@Test
public void testReadWriteNonSkippable() {
PositionedByteRange buff = new SimplePositionedMutableByteRange(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:fengchen8086,项目名称:ditb,代码行数:17,代码来源:TestTerminatedWrapper.java
示例5: skip
import org.apache.hadoop.hbase.util.PositionedByteRange; //导入依赖的package包/类
/**
* Skip {@code src}'s position forward over one encoded value.
* @param src the buffer containing the encoded value.
* @return number of bytes skipped.
* @throws IllegalArgumentException when the terminator sequence is not found.
*/
@Override
public int skip(PositionedByteRange src) {
if (wrapped.isSkippable()) {
int ret = wrapped.skip(src);
src.setPosition(src.getPosition() + term.length);
return ret + term.length;
} else {
// find the terminator position
final int start = src.getPosition();
int skipped = terminatorPosition(src);
if (-1 == skipped) throw new IllegalArgumentException("Terminator sequence not found.");
skipped += term.length;
src.setPosition(skipped);
return skipped - start;
}
}
开发者ID:fengchen8086,项目名称:ditb,代码行数:23,代码来源:TerminatedWrapper.java
示例6: generateHBaseDatasetDoubleOB
import org.apache.hadoop.hbase.util.PositionedByteRange; //导入依赖的package包/类
public static void generateHBaseDatasetDoubleOB(Connection conn, Admin admin, TableName tableName, int numberRegions) throws Exception {
if (admin.tableExists(tableName)) {
admin.disableTable(tableName);
admin.deleteTable(tableName);
}
HTableDescriptor desc = new HTableDescriptor(tableName);
desc.addFamily(new HColumnDescriptor(FAMILY_F));
if (numberRegions > 1) {
admin.createTable(desc, Arrays.copyOfRange(SPLIT_KEYS, 0, numberRegions-1));
} else {
admin.createTable(desc);
}
BufferedMutator table = conn.getBufferedMutator(tableName);
for (double i = 0.5; i <= 100.00; i += 0.75) {
byte[] bytes = new byte[9];
PositionedByteRange br = new SimplePositionedMutableByteRange(bytes, 0, 9);
OrderedBytes.encodeFloat64(br, i, Order.ASCENDING);
Put p = new Put(bytes);
p.addColumn(FAMILY_F, COLUMN_C, String.format("value %03f", i).getBytes());
table.mutate(p);
}
table.close();
admin.flush(tableName);
}
开发者ID:dremio,项目名称:dremio-oss,代码行数:31,代码来源:TestTableGenerator.java
示例7: generateHBaseDatasetFloatOB
import org.apache.hadoop.hbase.util.PositionedByteRange; //导入依赖的package包/类
public static void generateHBaseDatasetFloatOB(Connection conn, Admin admin, TableName tableName, int numberRegions) throws Exception {
if (admin.tableExists(tableName)) {
admin.disableTable(tableName);
admin.deleteTable(tableName);
}
HTableDescriptor desc = new HTableDescriptor(tableName);
desc.addFamily(new HColumnDescriptor(FAMILY_F));
if (numberRegions > 1) {
admin.createTable(desc, Arrays.copyOfRange(SPLIT_KEYS, 0, numberRegions-1));
} else {
admin.createTable(desc);
}
BufferedMutator table = conn.getBufferedMutator(tableName);
for (float i = (float)0.5; i <= 100.00; i += 0.75) {
byte[] bytes = new byte[5];
PositionedByteRange br = new SimplePositionedMutableByteRange(bytes, 0, 5);
OrderedBytes.encodeFloat32(br, i,Order.ASCENDING);
Put p = new Put(bytes);
p.addColumn(FAMILY_F, COLUMN_C, String.format("value %03f", i).getBytes());
table.mutate(p);
}
table.close();
admin.flush(tableName);
}
开发者ID:dremio,项目名称:dremio-oss,代码行数:31,代码来源:TestTableGenerator.java
示例8: decode
import org.apache.hadoop.hbase.util.PositionedByteRange; //导入依赖的package包/类
@Override
public Pojo1 decode(PositionedByteRange src) {
Object[] ret = new Object[3];
ret[0] = stringField.decode(src);
ret[1] = intField.decode(src);
ret[2] = doubleField.decode(src);
return new Pojo1(ret);
}
开发者ID:fengchen8086,项目名称:ditb,代码行数:9,代码来源:TestStruct.java
示例9: generateHBaseDatasetIntOB
import org.apache.hadoop.hbase.util.PositionedByteRange; //导入依赖的package包/类
public static void generateHBaseDatasetIntOB(Connection conn, Admin admin, TableName tableName, int numberRegions) throws Exception {
if (admin.tableExists(tableName)) {
admin.disableTable(tableName);
admin.deleteTable(tableName);
}
HTableDescriptor desc = new HTableDescriptor(tableName);
desc.addFamily(new HColumnDescriptor(FAMILY_F));
if (numberRegions > 1) {
admin.createTable(desc, Arrays.copyOfRange(SPLIT_KEYS, 0, numberRegions-1));
} else {
admin.createTable(desc);
}
BufferedMutator table = conn.getBufferedMutator(tableName);
for (int i = -49; i <= 100; i ++) {
byte[] bytes = new byte[5];
PositionedByteRange br = new SimplePositionedMutableByteRange(bytes, 0, 5);
OrderedBytes.encodeInt32(br, i, Order.ASCENDING);
Put p = new Put(bytes);
p.addColumn(FAMILY_F, COLUMN_C, String.format("value %d", i).getBytes());
table.mutate(p);
}
table.close();
admin.flush(tableName);
}
开发者ID:dremio,项目名称:dremio-oss,代码行数:31,代码来源:TestTableGenerator.java
示例10: skip
import org.apache.hadoop.hbase.util.PositionedByteRange; //导入依赖的package包/类
@Override
public int skip(PositionedByteRange src) {
CellProtos.Cell.Builder builder = CellProtos.Cell.newBuilder();
CodedInputStream is = inputStreamFromByteRange(src);
is.setSizeLimit(src.getLength());
try {
builder.mergeFrom(is);
int consumed = is.getTotalBytesRead();
src.setPosition(src.getPosition() + consumed);
return consumed;
} catch (IOException e) {
throw new RuntimeException("Error while skipping type.", e);
}
}
开发者ID:fengchen8086,项目名称:ditb,代码行数:15,代码来源:PBCell.java
示例11: generateHBaseDatasetFloatOBDesc
import org.apache.hadoop.hbase.util.PositionedByteRange; //导入依赖的package包/类
public static void generateHBaseDatasetFloatOBDesc(Connection conn, Admin admin, TableName tableName, int numberRegions) throws Exception {
if (admin.tableExists(tableName)) {
admin.disableTable(tableName);
admin.deleteTable(tableName);
}
HTableDescriptor desc = new HTableDescriptor(tableName);
desc.addFamily(new HColumnDescriptor(FAMILY_F));
if (numberRegions > 1) {
admin.createTable(desc, Arrays.copyOfRange(SPLIT_KEYS, 0, numberRegions-1));
} else {
admin.createTable(desc);
}
BufferedMutator table = conn.getBufferedMutator(tableName);
for (float i = (float)0.5; i <= 100.00; i += 0.75) {
byte[] bytes = new byte[5];
PositionedByteRange br = new SimplePositionedMutableByteRange(bytes, 0, 5);
OrderedBytes.encodeFloat32(br, i, Order.DESCENDING);
Put p = new Put(bytes);
p.addColumn(FAMILY_F, COLUMN_C, String.format("value %03f", i).getBytes());
table.mutate(p);
}
table.close();
admin.flush(tableName);
}
开发者ID:dremio,项目名称:dremio-oss,代码行数:31,代码来源:TestTableGenerator.java
示例12: generateHBaseDatasetBigIntOBDesc
import org.apache.hadoop.hbase.util.PositionedByteRange; //导入依赖的package包/类
public static void generateHBaseDatasetBigIntOBDesc(Connection conn, Admin admin, TableName tableName, int numberRegions) throws Exception {
if (admin.tableExists(tableName)) {
admin.disableTable(tableName);
admin.deleteTable(tableName);
}
HTableDescriptor desc = new HTableDescriptor(tableName);
desc.addFamily(new HColumnDescriptor(FAMILY_F));
if (numberRegions > 1) {
admin.createTable(desc, Arrays.copyOfRange(SPLIT_KEYS, 0, numberRegions-1));
} else {
admin.createTable(desc);
}
BufferedMutator table = conn.getBufferedMutator(tableName);
long startTime = (long)1438034423 * 1000;
for (long i = startTime; i <= startTime + 100; i ++) {
byte[] bytes = new byte[9];
PositionedByteRange br = new SimplePositionedMutableByteRange(bytes, 0, 9);
OrderedBytes.encodeInt64(br, i, Order.DESCENDING);
Put p = new Put(bytes);
p.addColumn(FAMILY_F, COLUMN_C, String.format("value %d", i).getBytes());
table.mutate(p);
}
table.close();
admin.flush(tableName);
}
开发者ID:dremio,项目名称:dremio-oss,代码行数:31,代码来源:TestTableGenerator.java
示例13: generateHBaseDatasetIntOBDesc
import org.apache.hadoop.hbase.util.PositionedByteRange; //导入依赖的package包/类
public static void generateHBaseDatasetIntOBDesc(Connection conn, Admin admin, TableName tableName, int numberRegions) throws Exception {
if (admin.tableExists(tableName)) {
admin.disableTable(tableName);
admin.deleteTable(tableName);
}
HTableDescriptor desc = new HTableDescriptor(tableName);
desc.addFamily(new HColumnDescriptor(FAMILY_F));
if (numberRegions > 1) {
admin.createTable(desc, Arrays.copyOfRange(SPLIT_KEYS, 0, numberRegions-1));
} else {
admin.createTable(desc);
}
BufferedMutator table = conn.getBufferedMutator(tableName);
for (int i = -49; i <= 100; i ++) {
byte[] bytes = new byte[5];
PositionedByteRange br = new SimplePositionedMutableByteRange(bytes, 0, 5);
OrderedBytes.encodeInt32(br, i, Order.DESCENDING);
Put p = new Put(bytes);
p.addColumn(FAMILY_F, COLUMN_C, String.format("value %d", i).getBytes());
table.mutate(p);
}
table.close();
admin.flush(tableName);
}
开发者ID:dremio,项目名称:dremio-oss,代码行数:31,代码来源:TestTableGenerator.java
示例14: encode
import org.apache.hadoop.hbase.util.PositionedByteRange; //导入依赖的package包/类
@Override
public int encode(PositionedByteRange dst, Pojo2 val) {
int written = byteField1.encode(dst, val.byteField1Asc);
written += byteField2.encode(dst, val.byteField2Dsc);
written += stringField.encode(dst, val.stringFieldDsc);
written += byteField3.encode(dst, val.byteField3Dsc);
return written;
}
开发者ID:fengchen8086,项目名称:ditb,代码行数:9,代码来源:TestStruct.java
示例15: testSkip
import org.apache.hadoop.hbase.util.PositionedByteRange; //导入依赖的package包/类
@Test
public void testSkip() {
Integer intVal = Integer.valueOf(10);
String strVal = "hello";
PositionedByteRange buff = new SimplePositionedMutableByteRange(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:fengchen8086,项目名称:ditb,代码行数:16,代码来源:TestUnion2.java
示例16: decode
import org.apache.hadoop.hbase.util.PositionedByteRange; //导入依赖的package包/类
@Override
public String decode(PositionedByteRange src) {
if (Order.ASCENDING == this.order) {
// avoid unnecessary array copy for ASC case.
String val =
Bytes.toString(src.getBytes(), src.getOffset() + src.getPosition(), src.getRemaining());
src.setPosition(src.getLength());
return val;
} else {
byte[] b = new byte[src.getRemaining()];
src.get(b);
order.apply(b, 0, b.length);
return Bytes.toString(b);
}
}
开发者ID:fengchen8086,项目名称:ditb,代码行数:16,代码来源:RawString.java
示例17: encode
import org.apache.hadoop.hbase.util.PositionedByteRange; //导入依赖的package包/类
@Override
public int encode(PositionedByteRange dst, String val) {
byte[] s = Bytes.toBytes(val);
order.apply(s);
dst.put(s);
return s.length;
}
开发者ID:fengchen8086,项目名称:ditb,代码行数:8,代码来源:RawString.java
示例18: skip
import org.apache.hadoop.hbase.util.PositionedByteRange; //导入依赖的package包/类
@Override
public int skip(PositionedByteRange src) {
StructIterator it = iterator(src);
int skipped = 0;
while (it.hasNext())
skipped += it.skip();
return skipped;
}
开发者ID:fengchen8086,项目名称:ditb,代码行数:9,代码来源:Struct.java
示例19: testEncodedLength
import org.apache.hadoop.hbase.util.PositionedByteRange; //导入依赖的package包/类
@Test
public void testEncodedLength() {
PositionedByteRange buff = new SimplePositionedMutableByteRange(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:fengchen8086,项目名称:ditb,代码行数:14,代码来源:TestOrderedString.java
示例20: decode
import org.apache.hadoop.hbase.util.PositionedByteRange; //导入依赖的package包/类
/**
* Read the field at {@code index}. {@code src}'s position is not affected.
*/
public Object decode(PositionedByteRange src, int index) {
assert index >= 0;
StructIterator it = iterator(src.shallowCopy());
for (; index > 0; index--)
it.skip();
return it.next();
}
开发者ID:fengchen8086,项目名称:ditb,代码行数:11,代码来源:Struct.java
注:本文中的org.apache.hadoop.hbase.util.PositionedByteRange类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论