@Override protected Encoder newEncoder(ByteArrayOutputStream out) throws IOException { return new EncoderFactory().configureBlockSize(254).blockingBinaryEncoder(out, null); }
public Tests(int bufferSize, int depth, String input) throws IOException { this.depth = depth; byte[] in = input.getBytes("UTF-8"); JsonFactory f = new JsonFactory(); JsonParser p = f.createJsonParser( new ByteArrayInputStream(input.getBytes("UTF-8"))); ByteArrayOutputStream os = new ByteArrayOutputStream(); EncoderFactory factory = new EncoderFactory() .configureBlockSize(bufferSize); Encoder cos = factory.blockingBinaryEncoder(os, null); serialize(cos, p, os); cos.flush(); byte[] bb = os.toByteArray(); // dump(bb); this.input = DecoderFactory.get().binaryDecoder(bb, null); this.parser = f.createJsonParser(new ByteArrayInputStream(in)); }
public TestBlockingIO2 (int bufferSize, int skipLevel, String calls) throws IOException { ByteArrayOutputStream os = new ByteArrayOutputStream(); EncoderFactory factory = new EncoderFactory() .configureBlockSize(bufferSize); Encoder encoder = factory.blockingBinaryEncoder(os, null); this.values = TestValidatingIO.randomValues(calls); TestValidatingIO.generate(encoder, calls, values); encoder.flush(); byte[] bb = os.toByteArray(); decoder = DecoderFactory.get().binaryDecoder(bb, null); this.calls = calls; }
private static void checkBinary(ReflectData reflectData, Schema schema, Object datum, boolean equals, boolean blocking) throws IOException { ReflectDatumWriter<Object> writer = new ReflectDatumWriter<>(schema); ByteArrayOutputStream out = new ByteArrayOutputStream(); if (!blocking) { writer.write(datum, EncoderFactory.get().directBinaryEncoder(out, null)); } else { writer.write(datum, new EncoderFactory().configureBlockSize(64) .blockingBinaryEncoder(out, null)); } writer.write(datum, EncoderFactory.get().directBinaryEncoder(out, null)); byte[] data = out.toByteArray(); ReflectDatumReader<Object> reader = new ReflectDatumReader<>(schema); Object decoded = reader.read(null, DecoderFactory.get().binaryDecoder(data, null)); assertEquals(0, reflectData.compare(datum, decoded, schema, equals)); }
@Override public void open(OutputStream out) throws IOException { this.out = out; this.encoder = new EncoderFactory().configureBlockSize(512).binaryEncoder(out, null); }
@Override public void open(OutputStream out) throws IOException { this.out = out; this.encoder = new EncoderFactory().configureBlockSize(512).binaryEncoder(out, null); }