Package com.facebook.presto.sql.tree

Examples of com.facebook.presto.sql.tree.Input


        }

        @Override
        public Object visitInputReference(InputReference node, Object context)
        {
            Input input = node.getInput();

            int channel = input.getChannel();
            if (context instanceof TupleReadable[]) {
                TupleReadable[] inputs = (TupleReadable[]) context;
                TupleReadable tuple = inputs[channel];

                if (tuple.isNull()) {
                    return null;
                }

                switch (tuple.getTupleInfo().getType()) {
                    case BOOLEAN:
                        return tuple.getBoolean();
                    case FIXED_INT_64:
                        return tuple.getLong();
                    case DOUBLE:
                        return tuple.getDouble();
                    case VARIABLE_BINARY:
                        return tuple.getSlice();
                    default:
                        throw new UnsupportedOperationException("not yet implemented");
                }
            }
            else if (context instanceof RecordCursor) {
                RecordCursor cursor = (RecordCursor) context;
                if (cursor.isNull(channel)) {
                    return null;
                }

                switch (cursor.getType(input.getChannel())) {
                    case BOOLEAN:
                        return cursor.getBoolean(channel);
                    case LONG:
                        return cursor.getLong(channel);
                    case DOUBLE:
View Full Code Here


        int channel = 0;
        for (Symbol symbol : symbols) {
            ProjectionFunction function = ProjectionFunctions.singleColumn(types.get(symbol).getRawType(), inputLayout.get(symbol));
            projections.add(function);
            if (!outputMappings.containsKey(symbol)) {
                outputMappings.put(symbol, new Input(channel));
                channel++;
            }
        }

        return new IdentityProjectionInfo(ImmutableMap.copyOf(outputMappings), projections);
View Full Code Here

            OperatorFactory operatorFactory = new ExchangeOperatorFactory(context.getNextOperatorId(), node.getId(), exchangeClientSupplier, tupleInfos);

            ImmutableMap.Builder<Symbol, Input> outputMappings = ImmutableMap.builder();
            int channel = 0;
            for (Symbol symbol : node.getOutputSymbols()) {
                outputMappings.put(symbol, new Input(channel));
                channel++;
            }

            return new PhysicalOperation(operatorFactory, outputMappings.build());
        }
View Full Code Here

            }

            // window functions go in remaining channels starting after the last channel from the source operator, one per channel
            int channel = source.getTupleInfos().size();
            for (Symbol symbol : windowFunctionOutputSymbols) {
                outputMappings.put(symbol, new Input(channel));
                channel++;
            }

            OperatorFactory operatorFactory = new WindowOperatorFactory(
                    context.getNextOperatorId(),
View Full Code Here

            List<Integer> channels = getChannelsForSymbols(node.getDistinctSymbols(), source.getLayout());

            // Source channels are always laid out first, followed by the boolean output symbol
            Map<Symbol, Input> outputMappings = ImmutableMap.<Symbol, Input>builder()
                    .putAll(source.getLayout())
                    .put(node.getMarkerSymbol(), new Input(source.getLayout().size())).build();

            Optional<Integer> sampleWeightChannel = node.getSampleWeightSymbol().transform(source.channelGetter());

            MarkDistinctOperatorFactory operator = new MarkDistinctOperatorFactory(context.getNextOperatorId(), source.getTupleInfos(), channels, sampleWeightChannel);
            return new PhysicalOperation(operator, outputMappings, source);
View Full Code Here

                int value = entry.getValue().getChannel();
                if (value == sampleWeightChannel) {
                    continue;
                }
                // Because we've removed the sample weight channel, all channels after it have been renumbered
                outputMappings.put(entry.getKey(), new Input(value > sampleWeightChannel ? value - 1 : value));
            }

            List<TupleInfo> tupleInfos = new ArrayList<>();
            tupleInfos.addAll(source.getTupleInfos());
            tupleInfos.remove(sampleWeightChannel);
View Full Code Here

                columns = new ArrayList<>();
                int channel = 0;
                for (Symbol symbol : tableScanNode.getOutputSymbols()) {
                    columns.add(tableScanNode.getAssignments().get(symbol));

                    Input input = new Input(channel);
                    sourceLayout.put(symbol, input);

                    Type type = checkNotNull(context.getTypes().get(symbol), "No type for symbol %s", symbol);
                    sourceTypes.put(input, type);

                    channel++;
                }
            }
            else {
                // plan source
                source = sourceNode.accept(this, context);
                sourceLayout = source.getLayout();
                sourceTypes = getInputTypes(source.getLayout(), source.getTupleInfos());
            }

            // build output mapping
            ImmutableMap.Builder<Symbol, Input> outputMappingsBuilder = ImmutableMap.builder();
            for (int i = 0; i < outputSymbols.size(); i++) {
                Symbol symbol = outputSymbols.get(i);
                outputMappingsBuilder.put(symbol, new Input(i));
            }
            Map<Symbol, Input> outputMappings = outputMappingsBuilder.build();

            try {
                // compiler uses inputs instead of symbols, so rewrite the expressions first
View Full Code Here

            int channel = 0;
            for (Symbol symbol : node.getOutputSymbols()) {
                columns.add(node.getAssignments().get(symbol));

                outputMappings.put(symbol, new Input(channel)); // one column per channel
                channel++;
            }

            List<TupleInfo> tupleInfos = getSourceOperatorTupleInfos(node, context.getTypes());
            OperatorFactory operatorFactory = new TableScanOperatorFactory(context.getNextOperatorId(), node.getId(), dataStreamProvider, tupleInfos, columns);
View Full Code Here

            // inputs from build side of the join are laid out following the input from the probe side,
            // so adjust the channel ids but keep the field layouts intact
            int offset = probeSource.getTupleInfos().size();
            for (Map.Entry<Symbol, Input> entry : buildSource.getLayout().entrySet()) {
                Input input = entry.getValue();
                outputMappings.put(entry.getKey(), new Input(offset + input.getChannel()));
            }

            OperatorFactory operator = createJoinOperator(node.getType(), hashSupplier, probeSource.getTupleInfos(), probeChannels, context);
            return new PhysicalOperation(operator, outputMappings.build(), probeSource);
        }
View Full Code Here

            context.addDriverFactory(buildDriverFactory);

            // Source channels are always laid out first, followed by the boolean output symbol
            Map<Symbol, Input> outputMappings = ImmutableMap.<Symbol, Input>builder()
                    .putAll(probeSource.getLayout())
                    .put(node.getSemiJoinOutput(), new Input(probeSource.getLayout().size()))
                    .build();

            HashSemiJoinOperatorFactory operator = new HashSemiJoinOperatorFactory(context.getNextOperatorId(), setProvider, probeSource.getTupleInfos(), probeChannel);
            return new PhysicalOperation(operator, outputMappings, probeSource);
        }
View Full Code Here

TOP

Related Classes of com.facebook.presto.sql.tree.Input

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.