use of org.apache.drill.exec.cache.VectorSerializer.Reader in project drill by axbaretto.
the class TestBatchSerialization method verifySerialize.
/**
* Verify serialize and deserialize. Need to pass both the
* input and expected (even though the expected should be the same
* data as the input) because the act of serializing clears the
* input for obscure historical reasons.
*
* @param rowSet
* @param expected
* @throws IOException
*/
private void verifySerialize(SingleRowSet rowSet, SingleRowSet expected) throws IOException {
File dir = DirTestWatcher.createTempDir(dirTestWatcher.getDir());
FileChannel channel = FileChannel.open(new File(dir, "serialize.dat").toPath(), StandardOpenOption.CREATE, StandardOpenOption.WRITE);
VectorSerializer.Writer writer = VectorSerializer.writer(channel);
VectorContainer container = rowSet.container();
SelectionVector2 sv2 = rowSet.getSv2();
writer.write(container, sv2);
container.clear();
if (sv2 != null) {
sv2.clear();
}
writer.close();
File outFile = new File(dir, "serialize.dat");
assertTrue(outFile.exists());
assertTrue(outFile.isFile());
RowSet result;
try (InputStream in = new BufferedInputStream(new FileInputStream(outFile))) {
Reader reader = VectorSerializer.reader(fixture.allocator(), in);
result = fixture.wrap(reader.read(), reader.sv2());
}
new RowSetComparison(expected).verifyAndClearAll(result);
outFile.delete();
}
use of org.apache.drill.exec.cache.VectorSerializer.Reader in project drill by apache.
the class TestBatchSerialization method verifySerialize.
/**
* Verify serialize and deserialize. Need to pass both the
* input and expected (even though the expected should be the same
* data as the input) because the act of serializing clears the
* input for obscure historical reasons.
*
* @param rowSet
* @param expected
* @throws IOException
*/
private void verifySerialize(SingleRowSet rowSet, SingleRowSet expected) throws IOException {
File dir = DirTestWatcher.createTempDir(dirTestWatcher.getDir());
FileChannel channel = FileChannel.open(new File(dir, "serialize.dat").toPath(), StandardOpenOption.CREATE, StandardOpenOption.WRITE);
VectorSerializer.Writer writer = VectorSerializer.writer(channel);
VectorContainer container = rowSet.container();
SelectionVector2 sv2 = rowSet.getSv2();
writer.write(container, sv2);
container.clear();
if (sv2 != null) {
sv2.clear();
}
writer.close();
File outFile = new File(dir, "serialize.dat");
assertTrue(outFile.exists());
assertTrue(outFile.isFile());
RowSet result;
try (InputStream in = new BufferedInputStream(new FileInputStream(outFile))) {
Reader reader = VectorSerializer.reader(fixture.allocator(), in);
result = fixture.wrap(reader.read(), reader.sv2());
}
RowSetUtilities.verify(expected, result);
outFile.delete();
}
Aggregations