public boolean setNextStem() { pos = 0; if (sit.hasNext()) { stemString = sit.next(); return true; } else { return false; } }
/** * Create a compound non-unique index, each pair is a {@link String} field and a {@link * Direction}. * * @param fieldsAndDirections Must be even number of arguments. * @return */ public static Index compound(Object... fieldsAndDirections) { final BasicDBObject indexObj = new BasicDBObject(); final UnmodifiableIterator<Object> iter = Iterators.forArray(fieldsAndDirections); while (iter.hasNext()) { final String field = (String) iter.next(); final Sort.Direction dir = (Direction) iter.next(); indexObj.put(field, dir == Direction.ASC ? 1 : -1); } return new Index(indexObj, false); }
private RelationPlan planCrossJoinUnnest(RelationPlan leftPlan, Join joinNode, Unnest node) { TupleDescriptor outputDescriptor = analysis.getOutputDescriptor(joinNode); TupleDescriptor unnestOutputDescriptor = analysis.getOutputDescriptor(node); // Create symbols for the result of unnesting ImmutableList.Builder<Symbol> unnestedSymbolsBuilder = ImmutableList.builder(); for (Field field : unnestOutputDescriptor.getVisibleFields()) { Symbol symbol = symbolAllocator.newSymbol(field); unnestedSymbolsBuilder.add(symbol); } ImmutableList<Symbol> unnestedSymbols = unnestedSymbolsBuilder.build(); // Add a projection for all the unnest arguments PlanBuilder planBuilder = initializePlanBuilder(leftPlan); planBuilder = appendProjections(planBuilder, node.getExpressions()); TranslationMap translations = planBuilder.getTranslations(); ProjectNode projectNode = checkType(planBuilder.getRoot(), ProjectNode.class, "planBuilder.getRoot()"); ImmutableMap.Builder<Symbol, List<Symbol>> unnestSymbols = ImmutableMap.builder(); UnmodifiableIterator<Symbol> unnestedSymbolsIterator = unnestedSymbols.iterator(); for (Expression expression : node.getExpressions()) { Type type = analysis.getType(expression); Symbol inputSymbol = translations.get(expression); if (type instanceof ArrayType) { unnestSymbols.put(inputSymbol, ImmutableList.of(unnestedSymbolsIterator.next())); } else if (type instanceof MapType) { unnestSymbols.put( inputSymbol, ImmutableList.of(unnestedSymbolsIterator.next(), unnestedSymbolsIterator.next())); } else { throw new IllegalArgumentException("Unsupported type for UNNEST: " + type); } } Optional<Symbol> ordinalitySymbol = node.isWithOrdinality() ? Optional.of(unnestedSymbolsIterator.next()) : Optional.empty(); checkState( !unnestedSymbolsIterator.hasNext(), "Not all output symbols were matched with input symbols"); UnnestNode unnestNode = new UnnestNode( idAllocator.getNextId(), projectNode, leftPlan.getOutputSymbols(), unnestSymbols.build(), ordinalitySymbol); return new RelationPlan( unnestNode, outputDescriptor, unnestNode.getOutputSymbols(), Optional.empty()); }
@Override public String next() { return values.get(0).apply(sit.next()); }
@Override public boolean hasNext() { return sit.hasNext(); }