use of org.apache.ignite.internal.sql.engine.externalize.RelJsonReader in project ignite-3 by apache.
the class AbstractPlannerTest method checkSplitAndSerialization.
protected void checkSplitAndSerialization(IgniteRel rel, IgniteSchema publicSchema) {
assertNotNull(rel);
rel = Cloner.clone(rel);
List<Fragment> fragments = new Splitter().go(rel);
List<String> serialized = new ArrayList<>(fragments.size());
for (Fragment fragment : fragments) {
serialized.add(toJson(fragment.root()));
}
assertNotNull(serialized);
List<String> nodes = new ArrayList<>(4);
for (int i = 0; i < 4; i++) {
nodes.add(UUID.randomUUID().toString());
}
List<RelNode> deserializedNodes = new ArrayList<>();
Map<UUID, IgniteTable> tableMap = publicSchema.getTableNames().stream().map(publicSchema::getTable).map(IgniteTable.class::cast).collect(Collectors.toMap(IgniteTable::id, Function.identity()));
for (String s : serialized) {
RelJsonReader reader = new RelJsonReader(new SqlSchemaManagerImpl(tableMap));
deserializedNodes.add(reader.read(s));
}
List<RelNode> expectedRels = fragments.stream().map(Fragment::root).collect(Collectors.toList());
assertEquals(expectedRels.size(), deserializedNodes.size(), "Invalid deserialization fragments count");
for (int i = 0; i < expectedRels.size(); ++i) {
RelNode expected = expectedRels.get(i);
RelNode deserialized = deserializedNodes.get(i);
clearTraits(expected);
clearTraits(deserialized);
if (!expected.deepEquals(deserialized)) {
assertTrue(expected.deepEquals(deserialized), "Invalid serialization / deserialization.\n" + "Expected:\n" + RelOptUtil.toString(expected) + "Deserialized:\n" + RelOptUtil.toString(deserialized));
}
}
}
Aggregations