本文整理了Java中io.airlift.slice.Slice.getBytes()
方法的一些代码示例,展示了Slice.getBytes()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Slice.getBytes()
方法的具体详情如下:
包路径:io.airlift.slice.Slice
类名称:Slice
方法名:getBytes
[英]Returns a copy of this buffer as a byte array.
[中]
代码示例来源:origin: prestodb/presto
private void writeToOutputStream(Slice source, int sourceIndex, int length)
{
try {
source.getBytes(sourceIndex, outputStream, length);
}
catch (IOException e) {
throw new UncheckedIOException(e);
}
}
}
代码示例来源:origin: prestodb/presto
private long parseTimestamp(Slice slice, int offset, int length)
{
//noinspection deprecation
return dateTimeFormatter.parseMillis(new String(slice.getBytes(offset, length), 0));
}
}
代码示例来源:origin: prestodb/presto
private static int compareTo(Slice left, Slice right)
{
return new ObjectId(left.getBytes()).compareTo(new ObjectId(right.getBytes()));
}
}
代码示例来源:origin: prestodb/presto
public static BigInteger unscaledDecimalToBigInteger(Slice decimal)
{
byte[] bytes = decimal.getBytes(0, UNSCALED_DECIMAL_128_SLICE_LENGTH);
// convert to big-endian order
reverse(bytes);
bytes[0] &= ~SIGN_BYTE_MASK;
return new BigInteger(isNegative(decimal) ? -1 : 1, bytes);
}
代码示例来源:origin: prestodb/presto
@Override
public void encodeValueInto(int depth, Block block, int position, SliceOutput output)
{
Slice slice = type.getSlice(block, position);
byte[] data = slice.getBytes();
slice = Slices.wrappedBuffer(base64Encoder.encode(data));
output.writeBytes(slice);
}
代码示例来源:origin: prestodb/presto
@Description("Compute HMAC with SHA512")
@ScalarFunction
@SqlType(StandardTypes.VARBINARY)
public static Slice hmacSha512(@SqlType(StandardTypes.VARBINARY) Slice slice, @SqlType(StandardTypes.VARBINARY) Slice key)
{
return wrappedBuffer(Hashing.hmacSha512(key.getBytes()).hashBytes(slice.getBytes()).asBytes());
}
}
代码示例来源:origin: prestodb/presto
@Description("encode binary data as base64")
@ScalarFunction
@SqlType(StandardTypes.VARCHAR)
public static Slice toBase64(@SqlType(StandardTypes.VARBINARY) Slice slice)
{
return Slices.wrappedBuffer(Base64.getEncoder().encode(slice.getBytes()));
}
代码示例来源:origin: prestodb/presto
@Override
protected Object getGreaterValue(Object value)
{
byte[] address = ((Slice) value).getBytes();
checkState(++address[address.length - 1] != 0, "Last byte of address is 0xff");
return Slices.wrappedBuffer(address);
}
代码示例来源:origin: prestodb/presto
private static UserMetadataItem toUserMetadata(Entry<String, Slice> entry)
{
return UserMetadataItem.newBuilder()
.setName(entry.getKey())
.setValue(ByteString.copyFrom(entry.getValue().getBytes()))
.build();
}
代码示例来源:origin: prestodb/presto
@Override
public Object getObjectValue(ConnectorSession session, Block block, int position)
{
if (block.isNull(position)) {
return null;
}
return new SqlVarbinary(block.getSlice(position, 0, block.getSliceLength(position)).getBytes());
}
}
代码示例来源:origin: prestodb/presto
@Override
public Object getObjectValue(ConnectorSession session, Block block, int position)
{
if (block.isNull(position)) {
return null;
}
return new SqlVarbinary(block.getSlice(position, 0, block.getSliceLength(position)).getBytes());
}
代码示例来源:origin: prestodb/presto
@ScalarOperator(CAST)
@SqlType(StandardTypes.HYPER_LOG_LOG)
public static Slice castToHyperLogLog(@SqlType(SetDigestType.NAME) Slice slice)
{
checkArgument(slice.getByte(0) == 1, "Legacy version of SetDigest cannot cast to HyperLogLog");
int hllLength = slice.getInt(SIZE_OF_BYTE);
return Slices.wrappedBuffer(slice.getBytes(SIZE_OF_BYTE + SIZE_OF_INT, hllLength));
}
}
代码示例来源:origin: prestodb/presto
@Description("encode binary data as base64 using the URL safe alphabet")
@ScalarFunction("to_base64url")
@SqlType(StandardTypes.VARCHAR)
public static Slice toBase64Url(@SqlType(StandardTypes.VARBINARY) Slice slice)
{
return Slices.wrappedBuffer(Base64.getUrlEncoder().encode(slice.getBytes()));
}
代码示例来源:origin: prestodb/presto
private static void assertByteCountWithoutTrailingSpace(byte[] actual, int offset, int length, byte[] expected)
{
Slice slice = wrappedBuffer(actual);
int trimmedLength = byteCountWithoutTrailingSpace(slice, offset, length);
byte[] bytes = slice.getBytes(offset, trimmedLength);
assertEquals(bytes, expected);
}
代码示例来源:origin: prestodb/presto
@Description("decode URL safe base64 encoded binary data")
@ScalarFunction("from_base64url")
@SqlType(StandardTypes.VARBINARY)
public static Slice fromBase64UrlVarbinary(@SqlType(StandardTypes.VARBINARY) Slice slice)
{
try {
return Slices.wrappedBuffer(Base64.getUrlDecoder().decode(slice.getBytes()));
}
catch (IllegalArgumentException e) {
throw new PrestoException(INVALID_FUNCTION_ARGUMENT, e);
}
}
代码示例来源:origin: prestodb/presto
public IntegerDictionary(DictionaryPage dictionaryPage)
throws IOException
{
super(dictionaryPage.getEncoding());
content = new int[dictionaryPage.getDictionarySize()];
IntegerPlainValuesReader intReader = new IntegerPlainValuesReader();
intReader.initFromPage(dictionaryPage.getDictionarySize(), dictionaryPage.getSlice().getBytes(), 0);
for (int i = 0; i < content.length; i++) {
content[i] = intReader.readInteger();
}
}
代码示例来源:origin: prestodb/presto
private Object getExpectedValueLongs(double maxError, long... values)
{
if (values.length == 0) {
return null;
}
QuantileDigest qdigest = new QuantileDigest(maxError);
Arrays.stream(values).forEach(qdigest::add);
return new SqlVarbinary(qdigest.serialize().getBytes());
}
代码示例来源:origin: prestodb/presto
public LongDictionary(DictionaryPage dictionaryPage)
throws IOException
{
super(dictionaryPage.getEncoding());
content = new long[dictionaryPage.getDictionarySize()];
LongPlainValuesReader longReader = new LongPlainValuesReader();
longReader.initFromPage(dictionaryPage.getDictionarySize(), dictionaryPage.getSlice().getBytes(), 0);
for (int i = 0; i < content.length; i++) {
content[i] = longReader.readLong();
}
}
代码示例来源:origin: prestodb/presto
public FloatDictionary(DictionaryPage dictionaryPage)
throws IOException
{
super(dictionaryPage.getEncoding());
content = new float[dictionaryPage.getDictionarySize()];
FloatPlainValuesReader floatReader = new FloatPlainValuesReader();
floatReader.initFromPage(dictionaryPage.getDictionarySize(), dictionaryPage.getSlice().getBytes(), 0);
for (int i = 0; i < content.length; i++) {
content[i] = floatReader.readFloat();
}
}
代码示例来源:origin: prestodb/presto
public DoubleDictionary(DictionaryPage dictionaryPage)
throws IOException
{
super(dictionaryPage.getEncoding());
content = new double[dictionaryPage.getDictionarySize()];
DoublePlainValuesReader doubleReader = new DoublePlainValuesReader();
doubleReader.initFromPage(dictionaryPage.getDictionarySize(), dictionaryPage.getSlice().getBytes(), 0);
for (int i = 0; i < content.length; i++) {
content[i] = doubleReader.readDouble();
}
}
内容来源于网络,如有侵权,请联系作者删除!