本文整理汇总了Java中org.apache.hadoop.hbase.util.OrderedBytes类的典型用法代码示例。如果您正苦于以下问题:Java OrderedBytes类的具体用法?Java OrderedBytes怎么用?Java OrderedBytes使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
OrderedBytes类属于org.apache.hadoop.hbase.util包,在下文中一共展示了OrderedBytes类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: deserialize
import org.apache.hadoop.hbase.util.OrderedBytes; //导入依赖的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);
}
示例2: generateHBaseDatasetDoubleOB
import org.apache.hadoop.hbase.util.OrderedBytes; //导入依赖的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);
}
示例3: generateHBaseDatasetFloatOB
import org.apache.hadoop.hbase.util.OrderedBytes; //导入依赖的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);
}
示例4: generateHBaseDatasetBigIntOB
import org.apache.hadoop.hbase.util.OrderedBytes; //导入依赖的package包/类
public static void generateHBaseDatasetBigIntOB(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.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);
}
示例5: generateHBaseDatasetIntOB
import org.apache.hadoop.hbase.util.OrderedBytes; //导入依赖的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);
}
示例6: generateHBaseDatasetDoubleOBDesc
import org.apache.hadoop.hbase.util.OrderedBytes; //导入依赖的package包/类
public static void generateHBaseDatasetDoubleOBDesc(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.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);
}
示例7: generateHBaseDatasetFloatOBDesc
import org.apache.hadoop.hbase.util.OrderedBytes; //导入依赖的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);
}
示例8: generateHBaseDatasetBigIntOBDesc
import org.apache.hadoop.hbase.util.OrderedBytes; //导入依赖的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);
}
示例9: generateHBaseDatasetIntOBDesc
import org.apache.hadoop.hbase.util.OrderedBytes; //导入依赖的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);
}
示例10: decode
import org.apache.hadoop.hbase.util.OrderedBytes; //导入依赖的package包/类
@Override
public Number decode(PositionedByteRange src) {
if (OrderedBytes.isNumericInfinite(src) || OrderedBytes.isNumericNaN(src)) {
return OrderedBytes.decodeNumericAsDouble(src);
}
return OrderedBytes.decodeNumericAsBigDecimal(src);
}
示例11: encode
import org.apache.hadoop.hbase.util.OrderedBytes; //导入依赖的package包/类
@Override
public int encode(PositionedByteRange dst, Number val) {
if (null == val) {
return OrderedBytes.encodeNull(dst, order);
} else if (val instanceof BigDecimal) {
return OrderedBytes.encodeNumeric(dst, (BigDecimal) val, order);
} else if (val instanceof BigInteger) {
return OrderedBytes.encodeNumeric(dst, new BigDecimal((BigInteger) val), order);
} else if (val instanceof Double || val instanceof Float) {
return OrderedBytes.encodeNumeric(dst, val.doubleValue(), order);
} else {
// TODO: other instances of Numeric to consider?
return OrderedBytes.encodeNumeric(dst, val.longValue(), order);
}
}
示例12: serialize
import org.apache.hadoop.hbase.util.OrderedBytes; //导入依赖的package包/类
public byte[] serialize(String outVertexLabel, String edgeLabel, String inVertexLabel) {
PositionedByteRange buffer = new SimplePositionedMutableByteRange(4096);
OrderedBytes.encodeString(buffer, outVertexLabel, Order.ASCENDING);
OrderedBytes.encodeString(buffer, edgeLabel, Order.ASCENDING);
OrderedBytes.encodeString(buffer, inVertexLabel, Order.ASCENDING);
buffer.setLength(buffer.getPosition());
buffer.setPosition(0);
byte[] bytes = new byte[buffer.getRemaining()];
buffer.get(bytes);
return bytes;
}
示例13: deserialize
import org.apache.hadoop.hbase.util.OrderedBytes; //导入依赖的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);
}
示例14: serialize
import org.apache.hadoop.hbase.util.OrderedBytes; //导入依赖的package包/类
public byte[] serialize(IndexMetadata.Key index) {
PositionedByteRange buffer = new SimplePositionedMutableByteRange(4096);
OrderedBytes.encodeString(buffer, index.label(), Order.ASCENDING);
OrderedBytes.encodeString(buffer, index.propertyKey(), Order.ASCENDING);
OrderedBytes.encodeInt8(buffer, index.type() == ElementType.VERTEX ? (byte) 1 : (byte) 0, Order.ASCENDING);
buffer.setLength(buffer.getPosition());
buffer.setPosition(0);
byte[] bytes = new byte[buffer.getRemaining()];
buffer.get(bytes);
return bytes;
}
示例15: encode
import org.apache.hadoop.hbase.util.OrderedBytes; //导入依赖的package包/类
@Override
public int encode(PositionedByteRange dst, Integer val) {
if (null == val) {
throw new IllegalArgumentException("Null values not supported.");
}
return OrderedBytes.encodeInt32(dst, val, order);
}