public void accept()

in asterix-graphix/src/main/java/org/apache/asterix/graphix/lang/rewrite/canonical/CanonicalElementExpansionConsumer.java [78:121]


    public void accept(AbstractExpression ambiguousElement, List<? extends AbstractExpression> canonicalElements)
            throws CompilationException {
        Deque<SelectBlock> readStack, writeStack;
        if (blackSelectBlockStack.isEmpty()) {
            writeStack = blackSelectBlockStack;
            readStack = redSelectBlockStack;

        } else {
            writeStack = redSelectBlockStack;
            readStack = blackSelectBlockStack;
        }

        ICanonicalPatternUpdater pathPatternReplacer;
        if (ambiguousElement instanceof VertexPatternExpr) {
            pathPatternReplacer = new VertexPatternUpdater(ambiguousElement);

        } else { // ambiguousElement instanceof EdgePatternExpr
            EdgePatternExpr ambiguousEdgePattern = (EdgePatternExpr) ambiguousElement;
            EdgeDescriptor ambiguousEdgeDescriptor = ambiguousEdgePattern.getEdgeDescriptor();
            if (ambiguousEdgeDescriptor.getPatternType() == EdgeDescriptor.PatternType.EDGE) {
                pathPatternReplacer = new EdgePatternUpdater(ambiguousElement);

            } else { // ambiguousEdgeDescriptor().getPatternType() == EdgeDescriptor.PatternType.PATH
                pathPatternReplacer = new PathPatternUpdater(ambiguousElement);
            }
        }

        // Consume all of our read stack.
        while (!readStack.isEmpty()) {
            SelectBlock workingSelectBlock = readStack.pop();
            for (AbstractExpression canonicalElement : canonicalElements) {
                SelectBlock workingSelectBlockCopy = deepCopyVisitor.visit(workingSelectBlock, null);
                workingSelectBlockCopy.accept(new AbstractGraphixQueryVisitor() {
                    @Override
                    public Expression visit(PathPatternExpr pathPatternExpr, ILangExpression arg)
                            throws CompilationException {
                        pathPatternReplacer.accept(canonicalElement, pathPatternExpr);
                        return pathPatternExpr;
                    }
                }, null);
                writeStack.push(workingSelectBlockCopy);
            }
        }
    }