Package io.airlift.slice

Examples of io.airlift.slice.Slice


        return bucket;
    }

    private static int calculateHashCode(TupleInfo tupleInfo, BlockCursor cursor)
    {
        Slice slice = cursor.getRawSlice();
        int offset = cursor.getRawOffset();
        int length = tupleInfo.size(slice, offset);
        return slice.hashCode(offset, length);
    }
View Full Code Here


            // Construct the set from the source
            strategy = new SliceHashStrategy(tupleInfo);
            addressValueSet = new AddressValueSet(expectedPositions, strategy);

            // allocate the first slice of the set
            Slice slice = Slices.allocate((int) BlockBuilder.DEFAULT_MAX_BLOCK_SIZE.toBytes());
            strategy.addSlice(slice);
            blockBuilder = new BlockBuilder(tupleInfo, slice.length(), slice.getOutput());
        }
View Full Code Here

        public void addBlock(Block sourceBlock)
        {
            operatorContext.setMemoryReservation(getEstimatedSize());

            BlockCursor sourceCursor = sourceBlock.cursor();
            Slice sourceSlice = ((UncompressedBlock) sourceBlock).getSlice();
            strategy.setLookupSlice(sourceSlice);

            for (int position = 0; position < sourceBlock.getPositionCount(); position++) {
                checkState(sourceCursor.advanceNextPosition());

                // Record whether we have seen a null
                containsNull |= sourceCursor.isNull();

                long sourceAddress = encodeSyntheticAddress(LOOKUP_SLICE_INDEX, sourceCursor.getRawOffset());

                if (!addressValueSet.contains(sourceAddress)) {
                    int length = tupleInfo.size(sourceSlice, sourceCursor.getRawOffset());
                    if (blockBuilder.writableBytes() < length) {
                        Slice slice = Slices.allocate(Math.max((int) BlockBuilder.DEFAULT_MAX_BLOCK_SIZE.toBytes(), length));
                        strategy.addSlice(slice);
                        blockBuilder = new BlockBuilder(tupleInfo, slice.length(), slice.getOutput());
                        currentBlockId++;
                    }
                    int blockRawOffset = blockBuilder.size();
                    blockBuilder.appendTuple(sourceSlice, sourceCursor.getRawOffset(), length);
                    addressValueSet.add(encodeSyntheticAddress(currentBlockId, blockRawOffset));
View Full Code Here

    }

    @Override
    public int hashCode(long sliceAddress)
    {
        Slice slice = getSliceForSyntheticAddress(sliceAddress);
        int offset = (int) sliceAddress;
        int length = tupleInfo.size(slice, offset);
        return slice.hashCode(offset, length);
    }
View Full Code Here

    }

    @Override
    public boolean equals(long leftSliceAddress, long rightSliceAddress)
    {
        Slice leftSlice = getSliceForSyntheticAddress(leftSliceAddress);
        int leftOffset = decodePosition(leftSliceAddress);
        int leftLength = tupleInfo.size(leftSlice, leftOffset);

        Slice rightSlice = getSliceForSyntheticAddress(rightSliceAddress);
        int rightOffset = decodePosition(rightSliceAddress);
        int rightLength = tupleInfo.size(rightSlice, rightOffset);

        return leftSlice.equals(leftOffset, leftLength, rightSlice, rightOffset, rightLength);
    }
View Full Code Here

        return slice.getDouble(SIZE_OF_LONG + SIZE_OF_DOUBLE);
    }

    public static Slice createIntermediate(long count, double mean, double m2)
    {
        Slice slice = Slices.allocate(SIZE_OF_LONG + SIZE_OF_DOUBLE + SIZE_OF_DOUBLE);
        slice.setLong(0, count);
        slice.setDouble(SIZE_OF_LONG, mean);
        slice.setDouble(SIZE_OF_LONG + SIZE_OF_DOUBLE, m2);
        return slice;
    }
View Full Code Here

                checkState(values.advanceNextPosition());

                if (!values.isNull()) {
                    long groupId = groupIdsBlock.getGroupId(position);

                    Slice slice = values.getSlice();
                    long inputCount = getCount(slice);
                    double inputMean = getMean(slice);
                    double inputM2 = getM2(slice);

                    long currentCount = counts.get(groupId);
View Full Code Here

            for (int position = 0; position < block.getPositionCount(); position++) {
                checkState(values.advanceNextPosition());

                if (!values.isNull()) {
                    Slice slice = values.getSlice();
                    long inputCount = getCount(slice);
                    double inputMean = getMean(slice);
                    double inputM2 = getM2(slice);

                    // Use numerically stable variant
View Full Code Here

        fileWriter.append(expectedBlock);
        fileWriter.append(expectedBlock);
        fileWriter.close();

        // read the block
        Slice slice = sliceOutput.getLastSlice();
        BlocksFileReader actualBlocks = readBlocks(createTestingBlockEncodingManager(), slice);

        List<Object> actualValues = BlockAssertions.toValues(actualBlocks);

        assertEquals(actualValues, expectedValues);
View Full Code Here

    private static int serializedSize(Page expectedPage)
    {
        DynamicSliceOutput sliceOutput = new DynamicSliceOutput(1024);
        writePages(createTestingBlockEncodingManager(), sliceOutput, expectedPage);
        Slice slice = sliceOutput.slice();

        Iterator<Page> pageIterator = readPages(createTestingBlockEncodingManager(), slice.getInput());
        assertPageEquals(pageIterator.next(), expectedPage);
        assertFalse(pageIterator.hasNext());

        return slice.length();
    }
View Full Code Here

TOP

Related Classes of io.airlift.slice.Slice

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.