Java Code Examples for io.prestosql.spi.block.Block#writeBytesTo()

The following examples show how to use io.prestosql.spi.block.Block#writeBytesTo() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DictionaryBuilder.java    From presto with Apache License 2.0 6 votes vote down vote up
private int addNewElement(long hashPosition, Block block, int position)
{
    checkArgument(!block.isNull(position), "position is null");
    block.writeBytesTo(position, 0, block.getSliceLength(position), elementBlock);
    elementBlock.closeEntry();

    int newElementPositionInBlock = elementBlock.getPositionCount() - 1;
    blockPositionByHash.set(hashPosition, newElementPositionInBlock);

    // increase capacity, if necessary
    if (elementBlock.getPositionCount() >= maxFill) {
        rehash(maxFill * 2);
    }

    return newElementPositionInBlock;
}
 
Example 2
Source File: SetDigestType.java    From presto with Apache License 2.0 5 votes vote down vote up
@Override
public void appendTo(Block block, int position, BlockBuilder blockBuilder)
{
    if (block.isNull(position)) {
        blockBuilder.appendNull();
    }
    else {
        block.writeBytesTo(position, 0, block.getSliceLength(position), blockBuilder);
        blockBuilder.closeEntry();
    }
}
 
Example 3
Source File: JsonType.java    From presto with Apache License 2.0 5 votes vote down vote up
@Override
public void appendTo(Block block, int position, BlockBuilder blockBuilder)
{
    if (block.isNull(position)) {
        blockBuilder.appendNull();
    }
    else {
        block.writeBytesTo(position, 0, block.getSliceLength(position), blockBuilder);
        blockBuilder.closeEntry();
    }
}
 
Example 4
Source File: AbstractTestBlock.java    From presto with Apache License 2.0 5 votes vote down vote up
protected void assertSlicePosition(Block block, int position, Slice expectedSliceValue)
{
    int length = block.getSliceLength(position);
    assertEquals(length, expectedSliceValue.length());

    Block expectedBlock = toSingeValuedBlock(expectedSliceValue);
    for (int offset = 0; offset < length - 3; offset++) {
        assertEquals(block.getSlice(position, offset, 3), expectedSliceValue.slice(offset, 3));
        assertTrue(block.bytesEqual(position, offset, expectedSliceValue, offset, 3));
        // if your tests fail here, please change your test to not use this value
        assertFalse(block.bytesEqual(position, offset, Slices.utf8Slice("XXX"), 0, 3));

        assertEquals(block.bytesCompare(position, offset, 3, expectedSliceValue, offset, 3), 0);
        assertTrue(block.bytesCompare(position, offset, 3, expectedSliceValue, offset, 2) > 0);
        Slice greaterSlice = createGreaterValue(expectedSliceValue, offset, 3);
        assertTrue(block.bytesCompare(position, offset, 3, greaterSlice, 0, greaterSlice.length()) < 0);

        assertTrue(block.equals(position, offset, expectedBlock, 0, offset, 3));
        assertEquals(block.compareTo(position, offset, 3, expectedBlock, 0, offset, 3), 0);

        BlockBuilder blockBuilder = VARBINARY.createBlockBuilder(null, 1);
        block.writeBytesTo(position, offset, 3, blockBuilder);
        blockBuilder.closeEntry();
        Block segment = blockBuilder.build();

        assertTrue(block.equals(position, offset, segment, 0, 0, 3));
    }
}
 
Example 5
Source File: ObjectIdType.java    From presto with Apache License 2.0 5 votes vote down vote up
@Override
public void appendTo(Block block, int position, BlockBuilder blockBuilder)
{
    if (block.isNull(position)) {
        blockBuilder.appendNull();
    }
    else {
        block.writeBytesTo(position, 0, block.getSliceLength(position), blockBuilder);
        blockBuilder.closeEntry();
    }
}
 
Example 6
Source File: ModelType.java    From presto with Apache License 2.0 5 votes vote down vote up
@Override
public void appendTo(Block block, int position, BlockBuilder blockBuilder)
{
    if (block.isNull(position)) {
        blockBuilder.appendNull();
    }
    else {
        block.writeBytesTo(position, 0, block.getSliceLength(position), blockBuilder);
        blockBuilder.closeEntry();
    }
}
 
Example 7
Source File: VarbinaryType.java    From presto with Apache License 2.0 5 votes vote down vote up
@Override
public void appendTo(Block block, int position, BlockBuilder blockBuilder)
{
    if (block.isNull(position)) {
        blockBuilder.appendNull();
    }
    else {
        block.writeBytesTo(position, 0, block.getSliceLength(position), blockBuilder);
        blockBuilder.closeEntry();
    }
}
 
Example 8
Source File: HyperLogLogType.java    From presto with Apache License 2.0 5 votes vote down vote up
@Override
public void appendTo(Block block, int position, BlockBuilder blockBuilder)
{
    if (block.isNull(position)) {
        blockBuilder.appendNull();
    }
    else {
        block.writeBytesTo(position, 0, block.getSliceLength(position), blockBuilder);
        blockBuilder.closeEntry();
    }
}
 
Example 9
Source File: VarcharType.java    From presto with Apache License 2.0 5 votes vote down vote up
@Override
public void appendTo(Block block, int position, BlockBuilder blockBuilder)
{
    if (block.isNull(position)) {
        blockBuilder.appendNull();
    }
    else {
        block.writeBytesTo(position, 0, block.getSliceLength(position), blockBuilder);
        blockBuilder.closeEntry();
    }
}
 
Example 10
Source File: CharType.java    From presto with Apache License 2.0 5 votes vote down vote up
@Override
public void appendTo(Block block, int position, BlockBuilder blockBuilder)
{
    if (block.isNull(position)) {
        blockBuilder.appendNull();
    }
    else {
        block.writeBytesTo(position, 0, block.getSliceLength(position), blockBuilder);
        blockBuilder.closeEntry();
    }
}
 
Example 11
Source File: QuantileDigestType.java    From presto with Apache License 2.0 5 votes vote down vote up
@Override
public void appendTo(Block block, int position, BlockBuilder blockBuilder)
{
    if (block.isNull(position)) {
        blockBuilder.appendNull();
    }
    else {
        block.writeBytesTo(position, 0, block.getSliceLength(position), blockBuilder);
        blockBuilder.closeEntry();
    }
}
 
Example 12
Source File: GeometryType.java    From presto with Apache License 2.0 5 votes vote down vote up
@Override
public void appendTo(Block block, int position, BlockBuilder blockBuilder)
{
    if (block.isNull(position)) {
        blockBuilder.appendNull();
    }
    else {
        block.writeBytesTo(position, 0, block.getSliceLength(position), blockBuilder);
        blockBuilder.closeEntry();
    }
}
 
Example 13
Source File: SphericalGeographyType.java    From presto with Apache License 2.0 5 votes vote down vote up
@Override
public void appendTo(Block block, int position, BlockBuilder blockBuilder)
{
    if (block.isNull(position)) {
        blockBuilder.appendNull();
    }
    else {
        block.writeBytesTo(position, 0, block.getSliceLength(position), blockBuilder);
        blockBuilder.closeEntry();
    }
}