Package com.facebook.presto.spi.block

Examples of com.facebook.presto.spi.block.Block


            Page page = new Page(builder.build());
            page = OperatorAssertion.appendSampleWeight(ImmutableList.of(page), WEIGHT).get(0);
            Accumulator accumulator = getFunction().bind(ImmutableList.of(0), Optional.<Integer>absent(), Optional.of(page.getChannelCount() - 1), getConfidence()).createAccumulator();

            accumulator.addInput(page);
            Block result = accumulator.evaluateFinal();

            String approxValue = BlockAssertions.toValues(accumulator.getFinalType(), result).get(0).toString();
            double approx = Double.parseDouble(approxValue.split(" ")[0]);
            double error = Double.parseDouble(approxValue.split(" ")[2]);
View Full Code Here


        }

        @Override
        public void addInput(Page page)
        {
            Block block = page.getBlock(labelChannel);
            for (int position = 0; position < block.getPositionCount(); position++) {
                if (labelIsLong) {
                    labels.add((double) BIGINT.getLong(block, position));
                }
                else {
                    labels.add(DOUBLE.getDouble(block, position));
                }
            }

            block = page.getBlock(featuresChannel);
            for (int position = 0; position < block.getPositionCount(); position++) {
                FeatureVector featureVector = ModelUtils.jsonToFeatures(VARCHAR.getSlice(block, position));
                rowsSize += featureVector.getEstimatedSize();
                rows.add(featureVector);
            }
View Full Code Here

        }

        @Override
        public void addInput(Page page)
        {
            Block block = page.getBlock(labelChannel);
            for (int position = 0; position < block.getPositionCount(); position++) {
                if (labelIsLong) {
                    labels.add((double) BIGINT.getLong(block, position));
                }
                else {
                    labels.add(DOUBLE.getDouble(block, position));
                }
            }

            block = page.getBlock(featuresChannel);
            for (int position = 0; position < block.getPositionCount(); position++) {
                FeatureVector featureVector = ModelUtils.jsonToFeatures(VARCHAR.getSlice(block, position));
                rowsSize += featureVector.getEstimatedSize();
                rows.add(featureVector);
            }
        }
View Full Code Here

        BlockBuilder expectedBlockBuilder = VARCHAR.createBlockBuilder(new BlockBuilderStatus());
        VARCHAR.writeString(expectedBlockBuilder, "alice");
        VARCHAR.writeString(expectedBlockBuilder, "bob");
        VARCHAR.writeString(expectedBlockBuilder, "charlie");
        VARCHAR.writeString(expectedBlockBuilder, "dave");
        Block expectedBlock = expectedBlockBuilder.build();

        Page expectedPage = new Page(expectedBlock, expectedBlock, expectedBlock);

        DynamicSliceOutput sliceOutput = new DynamicSliceOutput(1024);
        writePages(createTestingBlockEncodingManager(), sliceOutput, expectedPage, expectedPage, expectedPage);
View Full Code Here

            processBlock(page.getBlock(channel), maskChannel.transform(page.blockGetter()), sampleWeightChannel.transform(page.blockGetter()));
        }

        private void processBlock(Block block, Optional<Block> maskBlock, Optional<Block> sampleWeightBlock)
        {
            Block masks = null;
            Block sampleWeights = null;
            if (maskBlock.isPresent()) {
                masks = maskBlock.get();
            }
            if (sampleWeightBlock.isPresent()) {
                sampleWeights = sampleWeightBlock.get();
View Full Code Here

        private void processBlock(GroupByIdBlock groupIdsBlock, Block block, Optional<Block> maskBlock, Optional<Block> sampleWeightBlock)
        {
            notNull.ensureCapacity(groupIdsBlock.getGroupCount());
            sums.ensureCapacity(groupIdsBlock.getGroupCount());

            Block masks = null;
            Block sampleWeights = null;
            if (maskBlock.isPresent()) {
                masks = maskBlock.get();
            }
            if (sampleWeightBlock.isPresent()) {
                sampleWeights = sampleWeightBlock.get();
View Full Code Here

        assertNotNull(output);
        assertEquals(output.getPositionCount(), 1);
        assertEquals(output.getChannelCount(), 1);

        Block block = output.getBlock(0);
        assertEquals(block.getPositionCount(), 1);

        BlockCursor cursor = block.cursor();
        assertTrue(cursor.advanceNextPosition());
        if (cursor.isNull()) {
            return null;
        }
        else {
View Full Code Here

    private static void assertLearnClassifer(Accumulator accumulator)
            throws Exception
    {
        accumulator.addInput(getPage());
        Block block = accumulator.evaluateFinal();
        Slice slice = block.getSlice(0);
        Model deserialized = ModelUtils.deserialize(slice);
        assertNotNull(deserialized, "deserialization failed");
        assertTrue(deserialized instanceof Classifier, "deserialized model is not a classifier");
    }
View Full Code Here

            this.block = block;
        }

        public Block getRegionAndAdvance(int length)
        {
            Block region = block.getRegion(position, length);
            position += length;
            return region;
        }
View Full Code Here

        checkState(blocks.length == writers.size(), "Block count does not match writer count (%s vs %s)!", blocks.length, writers.size());

        int i = 0;
        for (BlocksFileWriter writer : writers.values()) {
            Block block = blocks[i];
            writer.append(block);
            positionCount[i] = block.getPositionCount();
            if (i > 0) {
                checkState(positionCount[i] == positionCount[i - 1], "different position count (%s vs. %s) for block!", positionCount[i], positionCount[i - 1]);
            }
            i++;
        }
View Full Code Here

TOP

Related Classes of com.facebook.presto.spi.block.Block

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.