@Override public void writeTo(StreamOutput out) throws IOException { ExecutionPhases.toStream(out, executionPhase); out.writeVInt(downstreamExecutionPhaseId); out.writeByte(downstreamExecutionPhaseInputId); out.writeVInt(downstreamNodes.size()); for (String executionNode : downstreamNodes) { out.writeString(executionNode); } }
@Test public void testStreaming() throws Exception { TableIdent t1 = new TableIdent(null, "t1"); TreeMap<String, Integer> bases = new TreeMap<String, Integer>(); bases.put(t1.name(), 0); bases.put("i2", 1); Multimap<TableIdent, String> tableIndices = HashMultimap.create(); tableIndices.put(t1, t1.name()); tableIndices.put(new TableIdent(null, "i2"), "i2_s1"); tableIndices.put(new TableIdent(null, "i2"), "i2_s2"); ReferenceIdent nameIdent = new ReferenceIdent(t1, "name"); Reference name = new Reference(new ReferenceInfo(nameIdent, RowGranularity.DOC, DataTypes.STRING)); FetchPhase orig = new FetchPhase( 1, ImmutableSet.<String>of("node1", "node2"), bases, tableIndices, ImmutableList.of(name)); BytesStreamOutput out = new BytesStreamOutput(); ExecutionPhases.toStream(out, orig); BytesStreamInput in = new BytesStreamInput(out.bytes()); FetchPhase streamed = (FetchPhase) ExecutionPhases.fromStream(in); assertThat(orig.executionPhaseId(), is(streamed.executionPhaseId())); assertThat(orig.executionNodes(), is(streamed.executionNodes())); assertThat(orig.fetchRefs(), is(streamed.fetchRefs())); assertThat(orig.bases(), is(streamed.bases())); assertThat(orig.tableIndices(), is(streamed.tableIndices())); }