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

The following examples show how to use io.prestosql.spi.block.Block#getInt() . 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: ColorType.java    From presto with Apache License 2.0 6 votes vote down vote up
@Override
public Object getObjectValue(ConnectorSession session, Block block, int position)
{
    if (block.isNull(position)) {
        return null;
    }

    int color = block.getInt(position, 0);
    if (color < 0) {
        return ColorFunctions.SystemColor.valueOf(-(color + 1)).getName();
    }

    return format("#%02x%02x%02x",
            (color >> 16) & 0xFF,
            (color >> 8) & 0xFF,
            color & 0xFF);
}
 
Example 2
Source File: IntervalYearMonthType.java    From presto with Apache License 2.0 5 votes vote down vote up
@Override
public Object getObjectValue(ConnectorSession session, Block block, int position)
{
    if (block.isNull(position)) {
        return null;
    }
    return new SqlIntervalYearMonth(block.getInt(position, 0));
}
 
Example 3
Source File: DateType.java    From presto with Apache License 2.0 5 votes vote down vote up
@Override
public Object getObjectValue(ConnectorSession session, Block block, int position)
{
    if (block.isNull(position)) {
        return null;
    }

    int days = block.getInt(position, 0);
    return new SqlDate(days);
}
 
Example 4
Source File: IntegerType.java    From presto with Apache License 2.0 5 votes vote down vote up
@Override
public Object getObjectValue(ConnectorSession session, Block block, int position)
{
    if (block.isNull(position)) {
        return null;
    }

    return block.getInt(position, 0);
}
 
Example 5
Source File: AbstractIntType.java    From presto with Apache License 2.0 5 votes vote down vote up
@Override
public boolean equalTo(Block leftBlock, int leftPosition, Block rightBlock, int rightPosition)
{
    int leftValue = leftBlock.getInt(leftPosition, 0);
    int rightValue = rightBlock.getInt(rightPosition, 0);
    return leftValue == rightValue;
}
 
Example 6
Source File: AbstractIntType.java    From presto with Apache License 2.0 5 votes vote down vote up
@Override
public int compareTo(Block leftBlock, int leftPosition, Block rightBlock, int rightPosition)
{
    // WARNING: the correctness of InCodeGenerator is dependent on the implementation of this
    // function being the equivalence of internal long representation.
    int leftValue = leftBlock.getInt(leftPosition, 0);
    int rightValue = rightBlock.getInt(rightPosition, 0);
    return Integer.compare(leftValue, rightValue);
}
 
Example 7
Source File: LongTimestampType.java    From presto with Apache License 2.0 4 votes vote down vote up
private static int getFraction(Block block, int position)
{
    return block.getInt(position, SIZE_OF_LONG);
}
 
Example 8
Source File: AbstractIntType.java    From presto with Apache License 2.0 4 votes vote down vote up
@Override
public final long getLong(Block block, int position)
{
    return block.getInt(position, 0);
}
 
Example 9
Source File: LongTimestampWithTimeZoneType.java    From presto with Apache License 2.0 4 votes vote down vote up
private static int getFraction(Block block, int position)
{
    return block.getInt(position, SIZE_OF_LONG);
}