本文整理了Java中org.apache.kylin.common.util.Bytes.toBytes()
方法的一些代码示例,展示了Bytes.toBytes()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Bytes.toBytes()
方法的具体详情如下:
包路径:org.apache.kylin.common.util.Bytes
类名称:Bytes
方法名:toBytes
[英]Serialize a double as the IEEE 754 double format output. The resultant array will be 8 bytes long.
[中]将double序列化为IEEE 754双格式输出。结果数组的长度将为8字节。
代码示例来源:origin: apache/kylin
protected byte[] toBytes(String str) {
if (str == null) {
return new byte[] { DimensionEncoding.NULL };
}
return Bytes.toBytes(str);
}
代码示例来源:origin: apache/kylin
/**
* @param t operands
* @return Array of byte arrays made from passed array of Text
*/
public static byte[][] toByteArrays(final String[] t) {
byte[][] result = new byte[t.length][];
for (int i = 0; i < t.length; i++) {
result[i] = Bytes.toBytes(t[i]);
}
return result;
}
代码示例来源:origin: apache/kylin
@Override
public byte[] convertToBytes(String v) {
return Bytes.toBytes(v);
}
代码示例来源:origin: apache/kylin
/**
* @param f float value
* @return the float represented as byte []
*/
public static byte[] toBytes(final float f) {
// Encode it as int
return Bytes.toBytes(Float.floatToRawIntBits(f));
}
代码示例来源:origin: apache/kylin
/**
* Serialize a double as the IEEE 754 double format output. The resultant
* array will be 8 bytes long.
*
* @param d value
* @return the double represented as byte []
*/
public static byte[] toBytes(final double d) {
// Encode it as a long
return Bytes.toBytes(Double.doubleToRawLongBits(d));
}
代码示例来源:origin: apache/kylin
private ObjectIdentityImpl getParentDomainObjectInfoFromRs(Result result) throws IOException {
ObjectIdentityImpl parentInfo = domainObjSerializer.deserialize(result.getValue(
Bytes.toBytes(AclConstant.ACL_INFO_FAMILY), Bytes.toBytes(AclConstant.ACL_INFO_FAMILY_PARENT_COLUMN)));
return parentInfo;
}
代码示例来源:origin: apache/kylin
private boolean getInheriting(Result result) {
boolean entriesInheriting = Bytes.toBoolean(result.getValue(Bytes.toBytes(AclConstant.ACL_INFO_FAMILY),
Bytes.toBytes(AclConstant.ACL_INFO_FAMILY_ENTRY_INHERIT_COLUMN)));
return entriesInheriting;
}
代码示例来源:origin: apache/kylin
private SidInfo getOwnerSidInfo(Result result) throws IOException {
SidInfo owner = sidSerializer.deserialize(result.getValue(Bytes.toBytes(AclConstant.ACL_INFO_FAMILY),
Bytes.toBytes(AclConstant.ACL_INFO_FAMILY_OWNER_COLUMN)));
return owner;
}
代码示例来源:origin: apache/kylin
private ObjectIdentityImpl getDomainObjectInfoFromRs(Result result) {
String type = new String(result.getValue(Bytes.toBytes(AclConstant.ACL_INFO_FAMILY),
Bytes.toBytes(AclConstant.ACL_INFO_FAMILY_TYPE_COLUMN)), StandardCharsets.UTF_8);
String id = new String(result.getRow(), StandardCharsets.UTF_8);
ObjectIdentityImpl newInfo = new ObjectIdentityImpl(type, id);
return newInfo;
}
代码示例来源:origin: apache/kylin
/**
* @param column operand
* @return A byte array of a byte array where first and only entry is
* <code>column</code>
*/
public static byte[][] toByteArrays(final String column) {
return toByteArrays(toBytes(column));
}
代码示例来源:origin: apache/kylin
@Override
public void doMap(NullWritable key, Text value, Context context) throws IOException, InterruptedException {
tmpBuf.clear();
int size = value.getLength()+ 1;
if (size >= tmpBuf.capacity()) {
tmpBuf = ByteBuffer.allocate(countNewSize(tmpBuf.capacity(), size));
}
tmpBuf.put(Bytes.toBytes(index)[3]);
tmpBuf.put(value.getBytes(), 0, value.getLength());
outputKey.set(tmpBuf.array(), 0, tmpBuf.position());
sortableKey.init(outputKey, type);
context.write(sortableKey, NullWritable.get());
}
代码示例来源:origin: apache/kylin
/**
* Writes a string as a fixed-size field, padded with zeros.
*/
public static void writeStringFixedSize(final DataOutput out, String s, int size) throws IOException {
byte[] b = toBytes(s);
if (b.length > size) {
throw new IOException("Trying to write " + b.length + " bytes (" + toStringBinary(b)
+ ") into a field of length " + size);
}
out.writeBytes(s);
for (int i = 0; i < size - s.length(); ++i)
out.writeByte(0);
}
代码示例来源:origin: apache/kylin
public RowValueDecoder(HBaseColumnDesc hbaseColumn) {
this.hbaseColumn = hbaseColumn;
this.hbaseColumnFamily = Bytes.toBytes(hbaseColumn.getColumnFamilyName());
this.hbaseColumnQualifier = Bytes.toBytes(hbaseColumn.getQualifier());
this.projectionIndex = new BitSet();
this.measures = hbaseColumn.getMeasures();
this.codec = new MeasureCodec(measures);
this.values = new Object[measures.length];
}
代码示例来源:origin: apache/kylin
@Override
public void doMap(LongWritable key, BytesWritable value, Context context) throws IOException, InterruptedException {
ByteBuffer buffer = ByteBuffer.wrap(value.getBytes(), 0, value.getLength());
StreamingMessageRow row = streamingParser.parse(buffer).get(0);
if (row == null) {
throw new IllegalArgumentException("");
}
data = StringUtil.join(row.getData(), delimiter);
// output this row to value
outValue.set(Bytes.toBytes(data));
context.write(outKey, outValue);
}
}
代码示例来源:origin: apache/kylin
/** Should be more private. For test only. */
public Cuboid(CubeDesc cubeDesc, long originalID, long validID) {
this.cubeDesc = cubeDesc;
this.inputID = originalID;
this.id = validID;
this.idBytes = Bytes.toBytes(id);
this.dimensionColumns = translateIdToColumns(this.id);
this.requirePostAggregation = calcExtraAggregation(this.inputID, this.id) != 0;
}
代码示例来源:origin: apache/kylin
@Override
public byte[] convertToBytes(String v) {
v = normalizeNumber(v);
NumberBytesCodec codec = getCodec(this.maxDigitsBeforeDecimalPoint);
byte[] num = Bytes.toBytes(v);
codec.encodeNumber(num, 0, num.length);
return Bytes.copy(codec.buf, codec.bufOffset, codec.bufLen);
}
代码示例来源:origin: apache/kylin
private String decodeNumber(String code) {
byte[] buf = Bytes.toBytes(code);
System.arraycopy(buf, 0, codec.buf, 0, buf.length);
codec.bufOffset = 0;
codec.bufLen = buf.length;
int len = codec.decodeNumber(buf, 0);
return Bytes.toString(buf, 0, len);
}
代码示例来源:origin: apache/kylin
private String encodeNumber(String number) {
byte[] num1 = Bytes.toBytes(number);
codec.encodeNumber(num1, 0, num1.length);
return Bytes.toString(codec.buf, codec.bufOffset, codec.bufLen);
}
代码示例来源:origin: apache/kylin
@Test
public void testEnDeCodeWithMultiKeys() {
HBaseLookupRowEncoder lookupRowEncoder = new HBaseLookupRowEncoder(tableDesc,
new String[] { "COUNTRY", "NAME" }, 1);
String[] row = new String[] { "AD", "42.546245", "1.601554", "Andorra" };
HBaseRow hBaseRow = lookupRowEncoder.encode(row);
assertEquals(2, hBaseRow.getQualifierValMap().size());
NavigableMap<byte[], byte[]> qualifierMap = hBaseRow.getQualifierValMap();
assertEquals("42.546245", Bytes.toString(qualifierMap.get(Bytes.toBytes("1"))));
assertEquals("1.601554", Bytes.toString(qualifierMap.get(Bytes.toBytes("2"))));
String[] decodeRow = lookupRowEncoder.decode(hBaseRow);
assertArrayEquals(row, decodeRow);
}
代码示例来源:origin: apache/kylin
@Test
public void testEnDeCode() {
HBaseLookupRowEncoder lookupRowEncoder = new HBaseLookupRowEncoder(tableDesc, new String[] { "COUNTRY" }, 1);
String[] row = new String[] { "AD", "42.546245", "1.601554", "Andorra" };
HBaseRow hBaseRow = lookupRowEncoder.encode(row);
assertEquals(6, hBaseRow.getRowKey().length);
assertEquals(3, hBaseRow.getQualifierValMap().size());
NavigableMap<byte[], byte[]> qualifierMap = hBaseRow.getQualifierValMap();
assertEquals("42.546245", Bytes.toString(qualifierMap.get(Bytes.toBytes("1"))));
assertEquals("1.601554", Bytes.toString(qualifierMap.get(Bytes.toBytes("2"))));
String[] decodeRow = lookupRowEncoder.decode(hBaseRow);
assertArrayEquals(row, decodeRow);
}
内容来源于网络,如有侵权,请联系作者删除!