本文整理汇总了Java中io.netty.buffer.DrillBuf.setBytes方法的典型用法代码示例。如果您正苦于以下问题:Java DrillBuf.setBytes方法的具体用法?Java DrillBuf.setBytes怎么用?Java DrillBuf.setBytes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.netty.buffer.DrillBuf
的用法示例。
在下文中一共展示了DrillBuf.setBytes方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: reAlloc
import io.netty.buffer.DrillBuf; //导入方法依赖的package包/类
/**
* Allocate new buffer with double capacity, and copy data into the new buffer. Replace vector's buffer with new buffer, and release old one
*/
public void reAlloc() {
final long newAllocationSize = allocationSizeInBytes * 2L;
if (newAllocationSize > MAX_ALLOCATION_SIZE) {
throw new OversizedAllocationException("Requested amount of memory is more than max allowed allocation size");
}
final int curSize = (int)newAllocationSize;
final DrillBuf newBuf = allocator.buffer(curSize);
newBuf.setZero(0, newBuf.capacity());
newBuf.setBytes(0, data, 0, data.capacity());
data.release();
data = newBuf;
allocationSizeInBytes = curSize;
}
示例2: decompress
import io.netty.buffer.DrillBuf; //导入方法依赖的package包/类
@Override
public void decompress(DrillBuf input, int compressedSize, DrillBuf output, int uncompressedSize)
throws IOException {
BytesInput uncompressed = decompress(new ByteBufBytesInput(input), uncompressedSize);
output.clear();
output.setBytes(0, uncompressed.toByteArray());
output.writerIndex((int) uncompressed.size());
}
示例3: getBigDecimalFromDense
import io.netty.buffer.DrillBuf; //导入方法依赖的package包/类
public static BigDecimal getBigDecimalFromDense(DrillBuf data, int startIndex, int nDecimalDigits, int scale, int maxPrecision, int width) {
/* This method converts the dense representation to
* an intermediate representation. The intermediate
* representation has one more integer than the dense
* representation.
*/
byte[] intermediateBytes = new byte[((nDecimalDigits + 1) * integerSize)];
// Start storing from the least significant byte of the first integer
int intermediateIndex = 3;
int[] mask = {0x03, 0x0F, 0x3F, 0xFF};
int[] reverseMask = {0xFC, 0xF0, 0xC0, 0x00};
int maskIndex;
int shiftOrder;
byte shiftBits;
// TODO: Some of the logic here is common with casting from Dense to Sparse types, factor out common code
if (maxPrecision == 38) {
maskIndex = 0;
shiftOrder = 6;
shiftBits = 0x00;
intermediateBytes[intermediateIndex++] = (byte) (data.getByte(startIndex) & 0x7F);
} else if (maxPrecision == 28) {
maskIndex = 1;
shiftOrder = 4;
shiftBits = (byte) ((data.getByte(startIndex) & 0x03) << shiftOrder);
intermediateBytes[intermediateIndex++] = (byte) (((data.getByte(startIndex) & 0x3C) & 0xFF) >>> 2);
} else {
throw new UnsupportedOperationException("Dense types with max precision 38 and 28 are only supported");
}
int inputIndex = 1;
boolean sign = false;
if ((data.getByte(startIndex) & 0x80) != 0) {
sign = true;
}
while (inputIndex < width) {
intermediateBytes[intermediateIndex] = (byte) ((shiftBits) | (((data.getByte(startIndex + inputIndex) & reverseMask[maskIndex]) & 0xFF) >>> (8 - shiftOrder)));
shiftBits = (byte) ((data.getByte(startIndex + inputIndex) & mask[maskIndex]) << shiftOrder);
inputIndex++;
intermediateIndex++;
if (((inputIndex - 1) % integerSize) == 0) {
shiftBits = (byte) ((shiftBits & 0xFF) >>> 2);
maskIndex++;
shiftOrder -= 2;
}
}
/* copy the last byte */
intermediateBytes[intermediateIndex] = shiftBits;
if (sign == true) {
intermediateBytes[0] = (byte) (intermediateBytes[0] | 0x80);
}
DrillBuf intermediate = data.getAllocator().buffer(intermediateBytes.length);
intermediate.setBytes(0, intermediateBytes);
BigDecimal ret = getBigDecimalFromIntermediate(intermediate, 0, nDecimalDigits + 1, scale);
intermediate.release();
return ret;
}
示例4: mappify
import io.netty.buffer.DrillBuf; //导入方法依赖的package包/类
public static DrillBuf mappify(FieldReader reader, BaseWriter.ComplexWriter writer, DrillBuf buffer) {
// Currently we expect single map as input
if (DataMode.REPEATED == reader.getType().getMode() || !(reader.getType().getMinorType() == TypeProtos.MinorType.MAP)) {
throw new DrillRuntimeException("kvgen function only supports Simple maps as input");
}
BaseWriter.ListWriter listWriter = writer.rootAsList();
listWriter.start();
BaseWriter.MapWriter mapWriter = listWriter.map();
// Iterate over the fields in the map
Iterator<String> fieldIterator = reader.iterator();
while (fieldIterator.hasNext()) {
String str = fieldIterator.next();
FieldReader fieldReader = reader.reader(str);
// Skip the field if its null
if (fieldReader.isSet() == false) {
mapWriter.end();
continue;
}
// writing a new field, start a new map
mapWriter.start();
// write "key":"columnname" into the map
VarCharHolder vh = new VarCharHolder();
byte[] b = str.getBytes(Charsets.UTF_8);
buffer = buffer.reallocIfNeeded(b.length);
buffer.setBytes(0, b);
vh.start = 0;
vh.end = b.length;
vh.buffer = buffer;
mapWriter.varChar(fieldKey).write(vh);
// Write the value to the map
MapUtility.writeToMapFromReader(fieldReader, mapWriter);
mapWriter.end();
}
listWriter.end();
return buffer;
}