test_class.declarator: EMPS = Linq4j.asEnumerable(
        Arrays.asList(
            new Emp(10, "Fred"),
            new Emp(20, "Theodore"),
            new Emp(20, "Sebastian"),
            new Emp(30, "Joe")))
test_class.modifier: private static final
test_class.original_string: private static final Enumerable<Emp> EMPS = Linq4j.asEnumerable(
        Arrays.asList(
            new Emp(10, "Fred"),
            new Emp(20, "Theodore"),
            new Emp(20, "Sebastian"),
            new Emp(30, "Joe")));
test_class.type: Enumerable<Emp>
test_class.var_name: EMPS
test_class.declarator: DEPTS = Linq4j.asEnumerable(
        Arrays.asList(
            new Dept(20, "Sales"),
            new Dept(15, "Marketing")))
test_class.modifier: private static final
test_class.original_string: private static final Enumerable<Dept> DEPTS = Linq4j.asEnumerable(
        Arrays.asList(
            new Dept(20, "Sales"),
            new Dept(15, "Marketing")));
test_class.type: Enumerable<Dept>
test_class.var_name: DEPTS
test_class.declarator: EMP_DEPT_TO_STRING =
        (v0, v1) -> "{" + (v0 == null ? null : v0.name)
            + ", " + (v0 == null ? null : v0.deptno)
            + ", " + (v1 == null ? null : v1.deptno)
            + ", " + (v1 == null ? null : v1.name)
            + "}"
test_class.modifier: private static final
test_class.original_string: private static final Function2<Emp, Dept, String> EMP_DEPT_TO_STRING =
        (v0, v1) -> "{" + (v0 == null ? null : v0.name)
            + ", " + (v0 == null ? null : v0.deptno)
            + ", " + (v1 == null ? null : v1.deptno)
            + ", " + (v1 == null ? null : v1.name)
            + "}";
test_class.type: Function2<Emp, Dept, String>
test_class.var_name: EMP_DEPT_TO_STRING
test_class.declarator: EQUAL_DEPTNO =
        (e, d) -> e.deptno == d.deptno
test_class.modifier: private static final
test_class.original_string: private static final Predicate2<Emp, Dept> EQUAL_DEPTNO =
        (e, d) -> e.deptno == d.deptno;
test_class.type: Predicate2<Emp, Dept>
test_class.var_name: EQUAL_DEPTNO
test_class.file: parser/src/test/java/com/qihoo/qsql/org/apache/calcite/runtime/EnumerablesTest.java
test_class.identifier: EnumerablesTest
test_case.body: @Test
    @Ignore // TODO fix this
    public void testMatch() {
      final Enumerable<Emp> emps = Linq4j.asEnumerable(
          Arrays.asList(
              new Emp(20, "Theodore"),
              new Emp(10, "Fred"),
              new Emp(20, "Sebastian"),
              new Emp(30, "Joe")));
  
      final Pattern p =
          Pattern.builder()
              .symbol("A")
              .symbol("B").seq()
              .build();
  
      final Matcher<Emp> matcher =
          Matcher.<Emp>builder(p.toAutomaton())
              .add("A", s -> s.get().deptno == 20)
              .add("B", s -> s.get().deptno != 20)
              .build();
  
      final Enumerables.Emitter<Emp, String> emitter =
          (rows, rowStates, rowSymbols, match, consumer) -> {
            for (int i = 0; i < rows.size(); i++) {
              if (rowSymbols == null) {
                continue;
              }
              if ("A".equals(rowSymbols.get(i))) {
                consumer.accept(
                    String.format(Locale.ENGLISH, "%s %s %d", rows, rowStates,
                        match));
              }
            }
          };
  
      final Enumerable<String> matches =
          Enumerables.match(emps, emp -> 0L, matcher, emitter, 1, 1);
      assertThat(matches.toList().toString(),
          equalTo("[[Emp(20, Theodore), Emp(10, Fred)] null 1, "
              + "[Emp(20, Sebastian), Emp(30, Joe)] null 2]"));
    }
test_case.class_method_signature: EnumerablesTest.testMatch()
test_case.full_signature: @Test @Ignore // TODO fix this public void testMatch()
test_case.identifier: testMatch
test_case.invocations: asEnumerable asList build seq symbol symbol builder build add add builder toAutomaton get get size equals get accept format match assertThat toString toList equalTo
test_case.modifiers: @Test @Ignore // TODO fix this public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testMatch()
focal_class.file: parser/src/main/java/com/qihoo/qsql/org/apache/calcite/runtime/Enumerables.java
focal_class.identifier: Enumerables
focal_class.class_method_signature: Enumerables.Enumerables()
focal_class.full_signature: private  Enumerables()
focal_class.identifier: Enumerables
focal_class.modifiers: private
focal_class.parameters: ()
focal_class.signature:  Enumerables()
focal_class.class_method_signature: Enumerables.slice0(Enumerable<E[]> enumerable)
focal_class.full_signature: public static Enumerable<E> slice0(Enumerable<E[]> enumerable)
focal_class.identifier: slice0
focal_class.modifiers: public static
focal_class.parameters: (Enumerable<E[]> enumerable)
focal_class.return: Enumerable<E>
focal_class.signature: Enumerable<E> slice0(Enumerable<E[]> enumerable)
focal_class.class_method_signature: Enumerables.toRow(final Enumerable<Object[]> enumerable)
focal_class.full_signature: public static Enumerable<Row> toRow(final Enumerable<Object[]> enumerable)
focal_class.identifier: toRow
focal_class.modifiers: public static
focal_class.parameters: (final Enumerable<Object[]> enumerable)
focal_class.return: Enumerable<Row>
focal_class.signature: Enumerable<Row> toRow(final Enumerable<Object[]> enumerable)
focal_class.class_method_signature: Enumerables.toRow(
        final Supplier<Enumerable<Object[]>> supplier)
focal_class.full_signature: public static Supplier<Enumerable<Row>> toRow(
        final Supplier<Enumerable<Object[]>> supplier)
focal_class.identifier: toRow
focal_class.modifiers: public static
focal_class.parameters: (
        final Supplier<Enumerable<Object[]>> supplier)
focal_class.return: Supplier<Enumerable<Row>>
focal_class.signature: Supplier<Enumerable<Row>> toRow(
        final Supplier<Enumerable<Object[]>> supplier)
focal_class.class_method_signature: Enumerables.toRow(
        final com.google.common.base.Supplier<Enumerable<Object[]>> supplier)
focal_class.full_signature: @SuppressWarnings("Guava") @Deprecated // to be removed before 2.0 public static com.google.common.base.Supplier<Enumerable<Row>> toRow(
        final com.google.common.base.Supplier<Enumerable<Object[]>> supplier)
focal_class.identifier: toRow
focal_class.modifiers: @SuppressWarnings("Guava") @Deprecated // to be removed before 2.0 public static
focal_class.parameters: (
        final com.google.common.base.Supplier<Enumerable<Object[]>> supplier)
focal_class.return: com.google.common.base.Supplier<Enumerable<Row>>
focal_class.signature: com.google.common.base.Supplier<Enumerable<Row>> toRow(
        final com.google.common.base.Supplier<Enumerable<Object[]>> supplier)
focal_class.class_method_signature: Enumerables.match(
        Enumerable<E> enumerable,
        final Function1<E, TKey> keySelector,
        Matcher<E> matcher,
        Emitter<E, TResult> emitter, int history, int future)
focal_class.full_signature: public static Enumerable<TResult> match(
        Enumerable<E> enumerable,
        final Function1<E, TKey> keySelector,
        Matcher<E> matcher,
        Emitter<E, TResult> emitter, int history, int future)
focal_class.identifier: match
focal_class.modifiers: public static
focal_class.parameters: (
        Enumerable<E> enumerable,
        final Function1<E, TKey> keySelector,
        Matcher<E> matcher,
        Emitter<E, TResult> emitter, int history, int future)
focal_class.return: Enumerable<TResult>
focal_class.signature: Enumerable<TResult> match(
        Enumerable<E> enumerable,
        final Function1<E, TKey> keySelector,
        Matcher<E> matcher,
        Emitter<E, TResult> emitter, int history, int future)
focal_method.body: public static <E, TKey, TResult> Enumerable<TResult> match(
        Enumerable<E> enumerable,
        final Function1<E, TKey> keySelector,
        Matcher<E> matcher,
        Emitter<E, TResult> emitter, int history, int future) {
      return new AbstractEnumerable<TResult>() {
        public Enumerator<TResult> enumerator() {
          return new Enumerator<TResult>() {
            final Enumerator<E> inputEnumerator = enumerable.enumerator();
  
            // State of each partition.
            final Map<TKey, Matcher.PartitionState<E>> partitionStates =
                new HashMap<>();
  
            int inputRow = -1;
  
            final Deque<TResult> emitRows = new ArrayDeque<>();
  
            /** Current result row. Null if no row is ready. */
            TResult resultRow;
  
            /** Match counter is 1 based in Oracle */
            final AtomicInteger matchCounter = new AtomicInteger(1);
  
            public TResult current() {
              Objects.requireNonNull(resultRow);
              return resultRow;
            }
  
            public boolean moveNext() {
              for (;;) {
                resultRow = emitRows.pollFirst();
                if (resultRow != null) {
                  return true;
                }
                // No rows are currently read to emit. Read the next input row,
                // see whether it completes a match (or matches), and if so, add
                // the resulting rows to the buffer.
                if (!inputEnumerator.moveNext()) {
                  return false;
                }
                ++inputRow;
                final E row = inputEnumerator.current();
                final TKey key = keySelector.apply(row);
                final Matcher.PartitionState<E> partitionState =
                    partitionStates.computeIfAbsent(key,
                        k -> matcher.createPartitionState(history, future));
  
                partitionState.getMemoryFactory().add(row);
  
  
                matcher.matchOne(partitionState.getRows(), partitionState,
                    // TODO 26.12.18 jf: add row states (whatever this is?)
                    list -> emitter.emit(list, null, null,
                        matchCounter.getAndIncrement(), emitRows::add));
  /*
                recentRows.add(e);
                int earliestRetainedRow = Integer.MAX_VALUE;
                for (int i = 0; i < partitionState.incompleteMatches.size(); i++) {
                  MatchState match = partitionState.incompleteMatches.get(i);
                  earliestRetainedRow = Math.min(earliestRetainedRow, match.firstRow);
                  final int state = automaton.nextState(match.state, e);
                  switch (state) {
                  case Automaton.ACCEPT:
                    final List<E> matchedRows =
                        recentRows.subList(0, 0); // TODO:
                    final List<Integer> rowStates = ImmutableList.of(); // TODO:
                    emitRows.addAll(
                        emitter.emit(matchedRows, rowStates,
                            partitionState.matchCount++));
                    // fall through
                  case Automaton.FAIL:
                    partitionState.incompleteMatches.remove(i--);
                    break;
                  default:
                    match.state = state;
                  }
                }
                // Try to start a match based on the current row
                final int state = automaton.nextState(Automaton.START_STATE, e);
                switch (state) {
                case Automaton.ACCEPT:
                  final List<E> matchedRows = ImmutableList.of(e);
                  final List<Integer> rowStates = ImmutableList.of(state);
                  emitRows.addAll(
                      emitter.emit(matchedRows, rowStates,
                          partitionState.matchCount++));
                  // fall through
                case Automaton.FAIL:
                  // since it immediately succeeded or failed, don't add
                  // it to the queue
                  break;
                default:
                  partitionState.incompleteMatches.add(
                      new MatchState(inputRow, state));
                }
  */
              }
            }
  
            public void reset() {
              throw new UnsupportedOperationException();
            }
  
            public void close() {
              inputEnumerator.close();
            }
          };
        }
      };
    }
focal_method.class_method_signature: Enumerables.match(
        Enumerable<E> enumerable,
        final Function1<E, TKey> keySelector,
        Matcher<E> matcher,
        Emitter<E, TResult> emitter, int history, int future)
focal_method.full_signature: public static Enumerable<TResult> match(
        Enumerable<E> enumerable,
        final Function1<E, TKey> keySelector,
        Matcher<E> matcher,
        Emitter<E, TResult> emitter, int history, int future)
focal_method.identifier: match
focal_method.invocations: enumerator requireNonNull pollFirst moveNext current apply computeIfAbsent createPartitionState add getMemoryFactory matchOne getRows emit getAndIncrement close
focal_method.modifiers: public static
focal_method.parameters: (
        Enumerable<E> enumerable,
        final Function1<E, TKey> keySelector,
        Matcher<E> matcher,
        Emitter<E, TResult> emitter, int history, int future)
focal_method.return: Enumerable<TResult>
focal_method.signature: Enumerable<TResult> match(
        Enumerable<E> enumerable,
        final Function1<E, TKey> keySelector,
        Matcher<E> matcher,
        Emitter<E, TResult> emitter, int history, int future)