return true; case ARRAY: return unionEquiv(w.getElementType(), r.getElementType(), seen); case MAP: return unionEquiv(w.getValueType(), r.getValueType(), seen); int i = 0; for (i = 0; i < wb.size(); i++) if (! unionEquiv(wb.get(i), rb.get(i), seen)) break; return i == wb.size(); int i = 0; for (i = 0; i < wb.size(); i++) if (! unionEquiv(wb.get(i).schema(), rb.get(i).schema(), seen)) break; seen.put(wsc, (i == wb.size()));
private Symbol resolveUnion(Schema writer, Schema reader, Map<LitS, Symbol> seen) throws IOException { boolean needsAdj = ! unionEquiv(writer, reader, new HashMap<>()); List<Schema> alts2 = (!needsAdj ? reader.getTypes() : null); List<Schema> alts = writer.getTypes(); final int size = alts.size(); Symbol[] symbols = new Symbol[size]; String[] labels = new String[size]; /** * We construct a symbol without filling the arrays. Please see * {@link Symbol#production} for the reason. */ int i = 0; for (Schema w : alts) { symbols[i] = generate(w, (needsAdj ? reader : alts2.get(i)), seen); labels[i] = w.getFullName(); i++; } if (! needsAdj) return Symbol.seq(Symbol.alt(symbols, labels), Symbol.UNION); return Symbol.seq(Symbol.alt(symbols, labels), Symbol.WRITER_UNION_ACTION); }