示例#1
0
 @Override
 protected T nextImpl() throws IOException {
   String encodedElementString = encodedElements.get(nextIndex++);
   // TODO: Replace with the real encoding used by the
   // front end, when we know what it is.
   byte[] encodedElement = StringUtils.jsonStringToByteArray(encodedElementString);
   notifyElementRead(encodedElement.length);
   return CoderUtils.decodeFromByteArray(coder, encodedElement);
 }
  @Test
  public void testCombineValuesFnCoders() throws Exception {
    CoderRegistry registry = new CoderRegistry();
    registry.registerStandardCoders();

    MeanInts meanInts = new MeanInts();
    MeanInts.CountSum countSum = meanInts.new CountSum(6, 27);

    Coder<MeanInts.CountSum> coder =
        meanInts.getAccumulatorCoder(
            registry, registry.getDefaultCoder(TypeDescriptor.of(Integer.class)));

    assertEquals(
        countSum,
        CoderUtils.decodeFromByteArray(coder, CoderUtils.encodeToByteArray(coder, countSum)));
  }