本文整理汇总了Java中com.facebook.presto.spi.block.BlockBuilder.appendNull方法的典型用法代码示例。如果您正苦于以下问题:Java BlockBuilder.appendNull方法的具体用法?Java BlockBuilder.appendNull怎么用?Java BlockBuilder.appendNull使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.facebook.presto.spi.block.BlockBuilder
的用法示例。
在下文中一共展示了BlockBuilder.appendNull方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: output
import com.facebook.presto.spi.block.BlockBuilder; //导入方法依赖的package包/类
@OutputFunction("array<bigint>")
public static void output(DigestAndPercentileArrayState state, BlockBuilder out)
{
QuantileDigest digest = state.getDigest();
List<Double> percentiles = state.getPercentiles();
if (percentiles == null || digest == null) {
out.appendNull();
return;
}
BlockBuilder blockBuilder = out.beginBlockEntry();
for (int i = 0; i < percentiles.size(); i++) {
Double percentile = percentiles.get(i);
BIGINT.writeLong(blockBuilder, digest.getQuantile(percentile));
}
out.closeEntry();
}
示例2: serializePrimitive
import com.facebook.presto.spi.block.BlockBuilder; //导入方法依赖的package包/类
private static void serializePrimitive(Type type, BlockBuilder builder, Object object) {
requireNonNull(builder, "parent builder is null");
if (object == null) {
builder.appendNull();
return;
}
if (BOOLEAN.equals(type)) {
BOOLEAN.writeBoolean(builder, (Boolean) object);
} else if (BIGINT.equals(type) || INTEGER.equals(type) || SMALLINT.equals(type) || TINYINT.equals(type)
|| REAL.equals(type) || DATE.equals(type) || TIMESTAMP.equals(type)) {
type.writeLong(builder, getLongExpressedValue(object));
} else if (DOUBLE.equals(type)) {
DOUBLE.writeDouble(builder, ((Number) object).doubleValue());
} else if (isVarcharType(type) || VARBINARY.equals(type) || isCharType(type)) {
type.writeSlice(builder, getSliceExpressedValue(object, type));
} else {
throw new UnsupportedOperationException("Unsupported primitive type: " + type);
}
}
示例3: output
import com.facebook.presto.spi.block.BlockBuilder; //导入方法依赖的package包/类
@OutputFunction("map<double,double>")
public static void output(State state, BlockBuilder out)
{
if (state.get() == null) {
out.appendNull();
}
else {
Map<Double, Double> value = state.get().getBuckets();
BlockBuilder blockBuilder = DoubleType.DOUBLE.createBlockBuilder(new BlockBuilderStatus(), value.size() * 2);
for (Map.Entry<Double, Double> entry : value.entrySet()) {
DoubleType.DOUBLE.writeDouble(blockBuilder, entry.getKey());
DoubleType.DOUBLE.writeDouble(blockBuilder, entry.getValue());
}
Block block = blockBuilder.build();
out.writeObject(block);
out.closeEntry();
}
}
示例4: createAlternatingNullsBlock
import com.facebook.presto.spi.block.BlockBuilder; //导入方法依赖的package包/类
public Block[] createAlternatingNullsBlock(List<Type> types, Block... sequenceBlocks)
{
Block[] alternatingNullsBlocks = new Block[sequenceBlocks.length];
for (int i = 0; i < sequenceBlocks.length; i++) {
int positionCount = sequenceBlocks[i].getPositionCount();
Type type = types.get(i);
BlockBuilder blockBuilder = type.createBlockBuilder(new BlockBuilderStatus(), positionCount);
for (int position = 0; position < positionCount; position++) {
// append null
blockBuilder.appendNull();
// append value
type.appendTo(sequenceBlocks[i], position, blockBuilder);
}
alternatingNullsBlocks[i] = blockBuilder.build();
}
return alternatingNullsBlocks;
}
示例5: getOutput
import com.facebook.presto.spi.block.BlockBuilder; //导入方法依赖的package包/类
@Override
public Page getOutput()
{
if (finished) {
return null;
}
finished = true;
OptionalLong rowsDeletedCount = metadata.metadataDelete(session, tableHandle, tableLayout);
PageBuilder page = new PageBuilder(TYPES);
BlockBuilder rowsBuilder = page.getBlockBuilder(0);
page.declarePosition();
if (rowsDeletedCount.isPresent()) {
BIGINT.writeLong(rowsBuilder, rowsDeletedCount.getAsLong());
}
else {
rowsBuilder.appendNull();
}
return page.build();
}
示例6: appendTo
import com.facebook.presto.spi.block.BlockBuilder; //导入方法依赖的package包/类
@Override
public void appendTo(Block block, int position, BlockBuilder blockBuilder)
{
if (block.isNull(position)) {
blockBuilder.appendNull();
}
else {
block.writeBytesTo(position, 0, block.getLength(position), blockBuilder);
blockBuilder.closeEntry();
}
}
示例7: serialize
import com.facebook.presto.spi.block.BlockBuilder; //导入方法依赖的package包/类
@Override
public void serialize(HyperLogLogState state, BlockBuilder out)
{
if (state.getHyperLogLog() == null) {
out.appendNull();
}
else {
Slice slice = Slices.wrappedBuffer(HyperLogLog.toBytes(state.getHyperLogLog()));
HyperLogLogType.HYPER_LOG_LOG.writeSlice(out, slice);
}
}
示例8: appendTo
import com.facebook.presto.spi.block.BlockBuilder; //导入方法依赖的package包/类
@Override
public void appendTo(Block block, int position, BlockBuilder blockBuilder)
{
if (block.isNull(position)) {
blockBuilder.appendNull();
}
else {
blockBuilder.writeLong(block.getLong(position, 0)).closeEntry();
}
}
示例9: appendSliceBlockBuilder
import com.facebook.presto.spi.block.BlockBuilder; //导入方法依赖的package包/类
public static void appendSliceBlockBuilder(BlockBuilder builder, @Nullable Slice value)
{
if (value == null) {
builder.appendNull();
}
else {
builder.writeBytes(value, 0, value.length()).closeEntry();
}
}
示例10: nextVector
import com.facebook.presto.spi.block.BlockBuilder; //导入方法依赖的package包/类
public void nextVector(Type type, long items, BlockBuilder builder, boolean[] isNull)
throws IOException
{
for (int i = 0; i < items; i++) {
if (isNull[i]) {
builder.appendNull();
}
else {
type.writeDouble(builder, next());
}
}
}
示例11: testMultipleValuesWithNull
import com.facebook.presto.spi.block.BlockBuilder; //导入方法依赖的package包/类
@Test
public void testMultipleValuesWithNull()
{
BlockBuilder blockBuilder = BIGINT.createBlockBuilder(new BlockBuilderStatus(), 10);
blockBuilder.appendNull();
BIGINT.writeLong(blockBuilder, 42);
blockBuilder.appendNull();
BIGINT.writeLong(blockBuilder, 42);
Block block = blockBuilder.build();
assertTrue(block.isNull(0));
assertEquals(BIGINT.getLong(block, 1), 42L);
assertTrue(block.isNull(2));
assertEquals(BIGINT.getLong(block, 3), 42L);
}
示例12: serialize
import com.facebook.presto.spi.block.BlockBuilder; //导入方法依赖的package包/类
@Override
public void serialize(BloomFilterState state, BlockBuilder out)
{
if (state.getBloomFilter() == null) {
out.appendNull();
}
else {
BloomFilterType.BLOOM_FILTER.writeSlice(out, state.getBloomFilter().serialize());
}
}
示例13: appendTo
import com.facebook.presto.spi.block.BlockBuilder; //导入方法依赖的package包/类
@Override
public void appendTo(Block block, int position, BlockBuilder blockBuilder)
{
if (block.isNull(position)) {
blockBuilder.appendNull();
}
else {
blockBuilder.writeObject(block.getObject(position, Block.class));
blockBuilder.closeEntry();
}
}
示例14: serialize
import com.facebook.presto.spi.block.BlockBuilder; //导入方法依赖的package包/类
@Override
public void serialize(MinMaxByNState state, BlockBuilder out)
{
TypedKeyValueHeap heap = state.getTypedKeyValueHeap();
if (heap == null) {
out.appendNull();
return;
}
heap.serialize(out);
}
示例15: regexpExtractAll
import com.facebook.presto.spi.block.BlockBuilder; //导入方法依赖的package包/类
@Description("group(s) extracted using the given pattern")
@ScalarFunction
@SqlType("array<varchar>")
public static Block regexpExtractAll(@SqlType(StandardTypes.VARCHAR) Slice source, @SqlType(RegexpType.NAME) Regex pattern, @SqlType(StandardTypes.BIGINT) long groupIndex)
{
Matcher matcher = pattern.matcher(source.getBytes());
validateGroup(groupIndex, matcher.getEagerRegion());
BlockBuilder blockBuilder = VARCHAR.createBlockBuilder(new BlockBuilderStatus(), 32);
int group = Ints.checkedCast(groupIndex);
int nextStart = 0;
while (true) {
int offset = matcher.search(nextStart, source.length(), Option.DEFAULT);
if (offset == -1) {
break;
}
if (matcher.getEnd() == matcher.getBegin()) {
nextStart = matcher.getEnd() + 1;
}
else {
nextStart = matcher.getEnd();
}
Region region = matcher.getEagerRegion();
int beg = region.beg[group];
int end = region.end[group];
if (beg == -1 || end == -1) {
blockBuilder.appendNull();
}
else {
Slice slice = source.slice(beg, end - beg);
VARCHAR.writeSlice(blockBuilder, slice);
}
}
return blockBuilder.build();
}