Java Code Examples for io.airlift.slice.Slices

The following examples show how to use io.airlift.slice.Slices. These examples are extracted from open source projects. 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 Project: presto   Source File: Chars.java    License: Apache License 2.0 7 votes vote down vote up
public static Slice padSpaces(Slice slice, int length)
{
    int textLength = countCodePoints(slice);

    if (textLength > length) {
        throw new IllegalArgumentException("pad length is smaller than slice length");
    }

    if (textLength == length) {
        return slice;
    }

    int bufferSize = slice.length() + length - textLength;
    Slice buffer = Slices.allocate(bufferSize);

    buffer.setBytes(0, slice);

    for (int i = slice.length(); i < bufferSize; ++i) {
        buffer.setByte(i, ' ');
    }

    return buffer;
}
 
Example 2
Source Project: presto   Source File: Footer.java    License: Apache License 2.0 6 votes vote down vote up
public Footer(
        long numberOfRows,
        OptionalInt rowsInRowGroup,
        List<StripeInformation> stripes,
        ColumnMetadata<OrcType> types,
        Optional<ColumnMetadata<ColumnStatistics>> fileStats,
        Map<String, Slice> userMetadata)
{
    this.numberOfRows = numberOfRows;
    rowsInRowGroup.ifPresent(value -> checkArgument(value > 0, "rowsInRowGroup must be at least 1"));
    this.rowsInRowGroup = rowsInRowGroup;
    this.stripes = ImmutableList.copyOf(requireNonNull(stripes, "stripes is null"));
    this.types = requireNonNull(types, "types is null");
    this.fileStats = requireNonNull(fileStats, "fileStats is null");
    requireNonNull(userMetadata, "userMetadata is null");
    this.userMetadata = ImmutableMap.copyOf(transformValues(userMetadata, Slices::copyOf));
}
 
Example 3
Source Project: presto   Source File: BenchmarkArrayDistinct.java    License: Apache License 2.0 6 votes vote down vote up
private static Block createChannel(int positionCount, int arraySize, ArrayType arrayType)
{
    BlockBuilder blockBuilder = arrayType.createBlockBuilder(null, positionCount);
    for (int position = 0; position < positionCount; position++) {
        BlockBuilder entryBuilder = blockBuilder.beginBlockEntry();
        for (int i = 0; i < arraySize; i++) {
            if (arrayType.getElementType().getJavaType() == long.class) {
                arrayType.getElementType().writeLong(entryBuilder, ThreadLocalRandom.current().nextLong());
            }
            else if (arrayType.getElementType().equals(VARCHAR)) {
                arrayType.getElementType().writeSlice(entryBuilder, Slices.utf8Slice("test_string"));
            }
            else {
                throw new UnsupportedOperationException();
            }
        }
        blockBuilder.closeEntry();
    }
    return blockBuilder.build();
}
 
Example 4
Source Project: presto   Source File: JsonUtil.java    License: Apache License 2.0 6 votes vote down vote up
public static Slice currentTokenAsVarchar(JsonParser parser)
        throws IOException
{
    switch (parser.currentToken()) {
        case VALUE_NULL:
            return null;
        case VALUE_STRING:
        case FIELD_NAME:
            return Slices.utf8Slice(parser.getText());
        case VALUE_NUMBER_FLOAT:
            // Avoidance of loss of precision does not seem to be possible here because of Jackson implementation.
            return DoubleOperators.castToVarchar(parser.getDoubleValue());
        case VALUE_NUMBER_INT:
            // An alternative is calling getLongValue and then BigintOperators.castToVarchar.
            // It doesn't work as well because it can result in overflow and underflow exceptions for large integral numbers.
            return Slices.utf8Slice(parser.getText());
        case VALUE_TRUE:
            return BooleanOperators.castToVarchar(true);
        case VALUE_FALSE:
            return BooleanOperators.castToVarchar(false);
        default:
            throw new JsonCastException(format("Unexpected token when cast to %s: %s", StandardTypes.VARCHAR, parser.getText()));
    }
}
 
Example 5
Source Project: presto   Source File: TestAllOrNoneValueSet.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testNone()
{
    AllOrNoneValueSet valueSet = AllOrNoneValueSet.none(HYPER_LOG_LOG);
    assertEquals(valueSet.getType(), HYPER_LOG_LOG);
    assertTrue(valueSet.isNone());
    assertFalse(valueSet.isAll());
    assertFalse(valueSet.isSingleValue());
    assertFalse(valueSet.containsValue(Slices.EMPTY_SLICE));

    try {
        valueSet.getSingleValue();
        fail();
    }
    catch (Exception ignored) {
    }
}
 
Example 6
Source Project: presto   Source File: DictionaryBlockEncoding.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public Block readBlock(BlockEncodingSerde blockEncodingSerde, SliceInput sliceInput)
{
    // positionCount
    int positionCount = sliceInput.readInt();

    // dictionary
    Block dictionaryBlock = blockEncodingSerde.readBlock(sliceInput);

    // ids
    int[] ids = new int[positionCount];
    sliceInput.readBytes(Slices.wrappedIntArray(ids));

    // instance id
    long mostSignificantBits = sliceInput.readLong();
    long leastSignificantBits = sliceInput.readLong();
    long sequenceId = sliceInput.readLong();

    // We always compact the dictionary before we send it. However, dictionaryBlock comes from sliceInput, which may over-retain memory.
    // As a result, setting dictionaryIsCompacted to true is not appropriate here.
    // TODO: fix DictionaryBlock so that dictionaryIsCompacted can be set to true when the underlying block over-retains memory.
    return new DictionaryBlock(positionCount, dictionaryBlock, ids, false, new DictionaryId(mostSignificantBits, leastSignificantBits, sequenceId));
}
 
Example 7
Source Project: presto   Source File: ArrayPositionLinks.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public PositionLinks.Factory build()
{
    return new PositionLinks.Factory()
    {
        @Override
        public PositionLinks create(List<JoinFilterFunction> searchFunctions)
        {
            return new ArrayPositionLinks(positionLinks);
        }

        @Override
        public long checksum()
        {
            return XxHash64.hash(Slices.wrappedIntArray(positionLinks));
        }
    };
}
 
Example 8
Source Project: presto   Source File: TestVarcharType.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testRange()
{
    VarcharType type = createVarcharType(5);

    Type.Range range = type.getRange().get();

    String expectedMax = new StringBuilder()
            .appendCodePoint(Character.MAX_CODE_POINT)
            .appendCodePoint(Character.MAX_CODE_POINT)
            .appendCodePoint(Character.MAX_CODE_POINT)
            .appendCodePoint(Character.MAX_CODE_POINT)
            .appendCodePoint(Character.MAX_CODE_POINT)
            .toString();

    assertEquals(Slices.utf8Slice(""), range.getMin());
    assertEquals(Slices.utf8Slice(expectedMax), range.getMax());
}
 
Example 9
Source Project: presto   Source File: NumericHistogram.java    License: Apache License 2.0 6 votes vote down vote up
public Slice serialize()
{
    compact();

    int requiredBytes = SizeOf.SIZE_OF_BYTE + // format
            SizeOf.SIZE_OF_INT + // max buckets
            SizeOf.SIZE_OF_INT + // entry count
            SizeOf.SIZE_OF_DOUBLE * nextIndex + // values
            SizeOf.SIZE_OF_DOUBLE * nextIndex; // weights

    return Slices.allocate(requiredBytes)
            .getOutput()
            .appendByte(FORMAT_TAG)
            .appendInt(maxBuckets)
            .appendInt(nextIndex)
            .appendBytes(Slices.wrappedDoubleArray(values, 0, nextIndex))
            .appendBytes(Slices.wrappedDoubleArray(weights, 0, nextIndex))
            .getUnderlyingSlice();
}
 
Example 10
@Override
public void serialize(LongDecimalWithOverflowState state, BlockBuilder out)
{
    if (state.getLongDecimal() == null) {
        out.appendNull();
    }
    else {
        Slice slice = Slices.allocate(Long.BYTES + UnscaledDecimal128Arithmetic.UNSCALED_DECIMAL_128_SLICE_LENGTH);
        SliceOutput output = slice.getOutput();

        output.writeLong(state.getOverflow());
        output.writeBytes(state.getLongDecimal());

        VARBINARY.writeSlice(out, slice);
    }
}
 
Example 11
@Override
public Object evaluate(DeferredObject[] arguments) throws HiveException {
    String source = (String) arguments[0].get();
    String pattern = (String) arguments[1].get();
    Long groupIndex = 0L;
    if (arguments.length == 3) {
        groupIndex = (Long) arguments[2].get();
    }

    if (source == null) {
        return null;
    }

    if (re2JRegexp == null) {
        re2JRegexp = new Re2JRegexp(Integer.MAX_VALUE, 5, Slices.utf8Slice(pattern));
    }

    result.clear();
    result.addAll(re2JRegexp.extractAll(Slices.utf8Slice(source), groupIndex));

    return result;
}
 
Example 12
@Test
public void testBloomFilterPerformanceContains()
{
    BloomFilter bf = BloomFilter.newInstance();
    long start = new Date().getTime();
    Random rand = new Random();
    byte[] buf = new byte[32];
    int iterations = 100000;
    for (int i = 0; i < iterations; i++) {
        rand.nextBytes(buf);
        Slice x = Slices.wrappedBuffer(buf);
        bf.mightContain(x);
    }
    long took = new Date().getTime() - start;
    assertEquals(bf.getPreMiss(), iterations);
    assertTrue(took < 10000L);
}
 
Example 13
Source Project: presto   Source File: BenchmarkArrayHashCodeOperator.java    License: Apache License 2.0 6 votes vote down vote up
private static Block createChannel(int positionCount, int arraySize, ArrayType arrayType)
{
    BlockBuilder blockBuilder = arrayType.createBlockBuilder(null, positionCount);
    for (int position = 0; position < positionCount; position++) {
        BlockBuilder entryBuilder = blockBuilder.beginBlockEntry();
        for (int i = 0; i < arraySize; i++) {
            if (arrayType.getElementType().getJavaType() == long.class) {
                arrayType.getElementType().writeLong(entryBuilder, ThreadLocalRandom.current().nextLong());
            }
            else if (arrayType.getElementType().getJavaType() == double.class) {
                arrayType.getElementType().writeDouble(entryBuilder, ThreadLocalRandom.current().nextDouble());
            }
            else if (arrayType.getElementType().getJavaType() == boolean.class) {
                arrayType.getElementType().writeBoolean(entryBuilder, ThreadLocalRandom.current().nextBoolean());
            }
            else if (arrayType.getElementType().equals(VARCHAR)) {
                arrayType.getElementType().writeSlice(entryBuilder, Slices.utf8Slice("test_string"));
            }
            else {
                throw new UnsupportedOperationException();
            }
        }
        blockBuilder.closeEntry();
    }
    return blockBuilder.build();
}
 
Example 14
@Override
public <K> Map<K, FixedLengthSliceInput> readFully(Map<K, DiskRange> diskRanges)
        throws IOException
{
    ImmutableMap.Builder<K, FixedLengthSliceInput> builder = ImmutableMap.builder();

    // Assumption here: all disk ranges are in the same region. Therefore, serving them in arbitrary order
    // will not result in eviction of cache that otherwise could have served any of the DiskRanges provided.
    for (Map.Entry<K, DiskRange> entry : diskRanges.entrySet()) {
        DiskRange diskRange = entry.getValue();
        byte[] buffer = new byte[diskRange.getLength()];
        readFully(diskRange.getOffset(), buffer);
        builder.put(entry.getKey(), Slices.wrappedBuffer(buffer).getInput());
    }
    return builder.build();
}
 
Example 15
Source Project: presto   Source File: PrestoSystemRequirements.java    License: Apache License 2.0 5 votes vote down vote up
private static void verifySlice()
{
    Slice slice = Slices.wrappedBuffer(new byte[5]);
    slice.setByte(4, 0xDE);
    slice.setByte(3, 0xAD);
    slice.setByte(2, 0xBE);
    slice.setByte(1, 0xEF);
    if (slice.getInt(1) != 0xDEADBEEF) {
        failRequirement("Slice library produced an unexpected result");
    }
}
 
Example 16
Source Project: presto   Source File: LocalFileRecordCursor.java    License: Apache License 2.0 5 votes vote down vote up
private static boolean isThisServerIncluded(HostAddress address, TupleDomain<LocalFileColumnHandle> predicate, LocalFileTableHandle table)
{
    if (table.getServerAddressColumn().isEmpty()) {
        return true;
    }

    Optional<Map<LocalFileColumnHandle, Domain>> domains = predicate.getDomains();
    if (domains.isEmpty()) {
        return true;
    }

    Set<Domain> serverAddressDomain = domains.get().entrySet().stream()
            .filter(entry -> entry.getKey().getOrdinalPosition() == table.getServerAddressColumn().getAsInt())
            .map(Map.Entry::getValue)
            .collect(toSet());

    if (serverAddressDomain.isEmpty()) {
        return true;
    }

    for (Domain domain : serverAddressDomain) {
        if (domain.includesNullableValue(Slices.utf8Slice(address.toString()))) {
            return true;
        }
    }
    return false;
}
 
Example 17
Source Project: presto   Source File: BlackHolePageSourceProvider.java    License: Apache License 2.0 5 votes vote down vote up
private Page generateZeroPage(List<Type> types, int rowsCount, int fieldLength)
{
    byte[] constantBytes = new byte[fieldLength];
    Arrays.fill(constantBytes, (byte) 42);
    Slice constantSlice = Slices.wrappedBuffer(constantBytes);

    Block[] blocks = new Block[types.size()];
    for (int i = 0; i < blocks.length; i++) {
        blocks[i] = createZeroBlock(types.get(i), rowsCount, constantSlice);
    }

    return new Page(rowsCount, blocks);
}
 
Example 18
Source Project: presto   Source File: LearnVarcharClassifierAggregation.java    License: Apache License 2.0 5 votes vote down vote up
@InputFunction
public static void input(
        @AggregationState LearnState state,
        @SqlType(VARCHAR) Slice label,
        @SqlType("map(bigint,double)") Block features)
{
    LearnLibSvmVarcharClassifierAggregation.input(state, label, features, Slices.utf8Slice(""));
}
 
Example 19
Source Project: presto   Source File: BenchmarkRegexpFunctions.java    License: Apache License 2.0 5 votes vote down vote up
@Setup
public void setup()
{
    SliceOutput sliceOutput = new DynamicSliceOutput(sourceLength);
    Slice pattern;
    switch (patternString) {
        case ".*x.*":
            pattern = Slices.utf8Slice(".*x.*");
            IntStream.generate(() -> 97).limit(sourceLength).forEach(sliceOutput::appendByte);
            break;
        case ".*(x|y).*":
            pattern = Slices.utf8Slice(".*(x|y).*");
            IntStream.generate(() -> 97).limit(sourceLength).forEach(sliceOutput::appendByte);
            break;
        case "longdotstar":
            pattern = Slices.utf8Slice(".*coolfunctionname.*");
            ThreadLocalRandom.current().ints(97, 123).limit(sourceLength).forEach(sliceOutput::appendByte);
            break;
        case "phone":
            pattern = Slices.utf8Slice("\\d{3}/\\d{3}/\\d{4}");
            // 47: '/', 48-57: '0'-'9'
            ThreadLocalRandom.current().ints(47, 58).limit(sourceLength).forEach(sliceOutput::appendByte);
            break;
        case "literal":
            pattern = Slices.utf8Slice("literal");
            // 97-122: 'a'-'z'
            ThreadLocalRandom.current().ints(97, 123).limit(sourceLength).forEach(sliceOutput::appendByte);
            break;
        default:
            throw new IllegalArgumentException("pattern: " + patternString + " not supported");
    }

    joniPattern = joniRegexp(pattern);
    re2JPattern = re2JRegexp(pattern);
    source = sliceOutput.slice();
    checkState(source.length() == sourceLength, "source.length=%s, sourceLength=%s", source.length(), sourceLength);
}
 
Example 20
Source Project: presto-connectors   Source File: MatchQueryFunction.java    License: Apache License 2.0 5 votes vote down vote up
@ScalarFunction("match_query")
@Description("es match_query")
@SqlType(StandardTypes.VARCHAR)
@SqlNullable
public static Slice matchQuery(
        @SqlType(StandardTypes.VARCHAR) Slice filter)
{
    if (filter == null) {
        return null;
    }
    String filterStr = filter.toStringUtf8();

    QueryBuilder builder = QueryBuilders.matchQuery(MATCH_COLUMN_SEP, filterStr);
    return Slices.utf8Slice(builder.toString());
}
 
Example 21
Source Project: presto   Source File: LearnRegressorAggregation.java    License: Apache License 2.0 5 votes vote down vote up
@InputFunction
public static void input(
        @AggregationState LearnState state,
        @SqlType(DOUBLE) double label,
        @SqlType("map(bigint,double)") Block features)
{
    LearnLibSvmRegressorAggregation.input(state, label, features, Slices.utf8Slice(""));
}
 
Example 22
Source Project: presto   Source File: CompressedOrcChunkLoader.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public Slice nextChunk()
        throws IOException
{
    // 3 byte header
    // NOTE: this must match BLOCK_HEADER_SIZE
    ensureCompressedBytesAvailable(3);
    lastCheckpoint = createInputStreamCheckpoint(getCurrentCompressedOffset(), nextUncompressedOffset);
    int b0 = compressedBufferStream.readUnsignedByte();
    int b1 = compressedBufferStream.readUnsignedByte();
    int b2 = compressedBufferStream.readUnsignedByte();

    boolean isUncompressed = (b0 & 0x01) == 1;
    int chunkLength = (b2 << 15) | (b1 << 7) | (b0 >>> 1);

    ensureCompressedBytesAvailable(chunkLength);
    Slice chunk = compressedBufferStream.readSlice(chunkLength);

    if (!isUncompressed) {
        int uncompressedSize = decompressor.decompress(
                chunk.byteArray(),
                chunk.byteArrayOffset(),
                chunk.length(),
                createOutputBuffer());
        chunk = Slices.wrappedBuffer(decompressorOutputBuffer, 0, uncompressedSize);
    }
    if (nextUncompressedOffset != 0) {
        chunk = chunk.slice(nextUncompressedOffset, chunk.length() - nextUncompressedOffset);
        nextUncompressedOffset = 0;
        // if we positioned to the end of the chunk, read the next one
        if (chunk.length() == 0) {
            chunk = nextChunk();
        }
    }
    return chunk;
}
 
Example 23
Source Project: presto   Source File: ChunkedSliceOutput.java    License: Apache License 2.0 5 votes vote down vote up
public ChunkedSliceOutput(int minChunkSize, int maxChunkSize)
{
    this.chunkSupplier = new ChunkSupplier(minChunkSize, maxChunkSize);

    this.buffer = chunkSupplier.get();
    this.slice = Slices.wrappedBuffer(buffer);
}
 
Example 24
Source Project: presto-kudu   Source File: TypeHelper.java    License: Apache License 2.0 5 votes vote down vote up
public static Object getObject(Type type, RowResult row, int field) {
    if (row.isNull(field)) {
        return null;
    } else {
        if (type instanceof VarcharType) {
            return row.getString(field);
        } else if (type == TimestampType.TIMESTAMP) {
            return row.getLong(field) / 1000;
        } else if (type == BigintType.BIGINT) {
            return row.getLong(field);
        } else if (type == IntegerType.INTEGER) {
            return row.getInt(field);
        } else if (type == SmallintType.SMALLINT) {
            return row.getShort(field);
        } else if (type == TinyintType.TINYINT) {
            return row.getByte(field);
        } else if (type == DoubleType.DOUBLE) {
            return row.getDouble(field);
        } else if (type == RealType.REAL) {
            return row.getFloat(field);
        } else if (type == BooleanType.BOOLEAN) {
            return row.getBoolean(field);
        } else if (type instanceof VarbinaryType) {
            return Slices.wrappedBuffer(row.getBinary(field));
        } else if (type instanceof DecimalType) {
            return row.getDecimal(field);
        } else {
            throw new IllegalStateException("getObject not implemented for " + type);
        }
    }
}
 
Example 25
Source Project: presto   Source File: DecimalColumnReader.java    License: Apache License 2.0 5 votes vote down vote up
private Block readLongNullBlock(boolean[] isNull, int nonNullCount)
        throws IOException
{
    verifyNotNull(decimalStream);
    verifyNotNull(scaleStream);

    int minTempSize = minNonNullValueSize(nonNullCount) * 2;
    if (nonNullValueTemp.length < minTempSize) {
        nonNullValueTemp = new long[minTempSize];
        systemMemoryContext.setBytes(sizeOf(nonNullValueTemp));
    }

    decimalStream.nextLongDecimal(nonNullValueTemp, nonNullCount);

    // rescale if necessary
    for (int offset = 0; offset < nonNullCount * 2; offset += 2) {
        long sourceScale = scaleStream.next();
        if (sourceScale != type.getScale()) {
            Slice decimal = Slices.wrappedLongArray(nonNullValueTemp[offset], nonNullValueTemp[offset + 1]);
            UnscaledDecimal128Arithmetic.rescale(decimal, (int) (type.getScale() - sourceScale), Slices.wrappedLongArray(nonNullValueTemp, offset, 2));
        }
    }

    long[] result = unpackInt128Nulls(nonNullValueTemp, isNull);

    return new Int128ArrayBlock(nextBatchSize, Optional.of(isNull), result);
}
 
Example 26
private void advance()
        throws IOException
{
    if (compressedSliceInput == null || compressedSliceInput.remaining() == 0) {
        current = null;
        return;
    }

    // 3 byte header
    // NOTE: this must match BLOCK_HEADER_SIZE
    currentCompressedBlockOffset = toIntExact(compressedSliceInput.position());
    int b0 = compressedSliceInput.readUnsignedByte();
    int b1 = compressedSliceInput.readUnsignedByte();
    int b2 = compressedSliceInput.readUnsignedByte();

    boolean isUncompressed = (b0 & 0x01) == 1;
    int chunkLength = (b2 << 15) | (b1 << 7) | (b0 >>> 1);
    if (chunkLength < 0 || chunkLength > compressedSliceInput.remaining()) {
        throw new OrcCorruptionException(String.format("The chunkLength (%s) must not be negative or greater than remaining size (%s)", chunkLength, compressedSliceInput.remaining()));
    }

    Slice chunk = compressedSliceInput.readSlice(chunkLength);

    if (isUncompressed) {
        current = chunk.getInput();
    }
    else {
        int uncompressedSize;
        if (compressionKind == ZLIB) {
            uncompressedSize = decompressZip(chunk);
        }
        else {
            uncompressedSize = decompressSnappy(chunk);
        }

        current = Slices.wrappedBuffer(buffer, 0, uncompressedSize).getInput();
    }
}
 
Example 27
Source Project: presto   Source File: ChunkedSliceOutput.java    License: Apache License 2.0 5 votes vote down vote up
public ChunkedSliceOutput(int minChunkSize, int maxChunkSize)
{
    this.chunkSupplier = new ChunkSupplier(minChunkSize, maxChunkSize);

    this.buffer = chunkSupplier.get();
    this.slice = Slices.wrappedBuffer(buffer);
}
 
Example 28
Source Project: presto   Source File: ChunkedSliceOutput.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void reset()
{
    chunkSupplier.reset();
    closedSlices.clear();

    buffer = chunkSupplier.get();
    slice = Slices.wrappedBuffer(buffer);

    closedSlicesRetainedSize = 0;
    streamOffset = 0;
    bufferPosition = 0;
}
 
Example 29
Source Project: presto   Source File: MLFunctions.java    License: Apache License 2.0 5 votes vote down vote up
@ScalarFunction("classify")
@SqlType(StandardTypes.VARCHAR)
public static Slice varcharClassify(@SqlType(MAP_BIGINT_DOUBLE) Block featuresMap, @SqlType("Classifier(varchar)") Slice modelSlice)
{
    FeatureVector features = ModelUtils.toFeatures(featuresMap);
    Model model = getOrLoadModel(modelSlice);
    checkArgument(model.getType().equals(VARCHAR_CLASSIFIER), "model is not a Classifier(varchar)");
    Classifier<String> varcharClassifier = (Classifier<String>) model;
    return Slices.utf8Slice(varcharClassifier.classify(features));
}
 
Example 30
Source Project: presto   Source File: TestDecimalStream.java    License: Apache License 2.0 5 votes vote down vote up
private static BigInteger nextLongDecimalValue(DecimalInputStream stream)
        throws IOException
{
    long[] decimal = new long[2];
    stream.nextLongDecimal(decimal, 1);
    return unscaledDecimalToBigInteger(Slices.wrappedLongArray(decimal));
}