atlasdb icon indicating copy to clipboard operation
atlasdb copied to clipboard

[Generated Code] Field Deserialization Done On Every Columnar Get

Open jeremyk-91 opened this issue 5 years ago • 0 comments

Consider the schema

        schema.addTableDefinition("table", new TableDefinition() {{
            rowName();
            rowComponent("row", ValueType.STRING);
            columns();
            column("column", "c", JPersister.class);
        }});

Produces generated code

        public SomeType getColumn() {
            byte[] bytes = row.getColumns().get(PtBytes.toCachedBytes("c"));
            if (bytes == null) {
                return null;
            }
            Column value = Column.BYTES_HYDRATOR.hydrateFromBytes(bytes);
            return value.getValue();
        }

In particular, if you have something like

TableRowResult row = table.getRow(someRow).orElseThrow(() -> new IllegalStateException());
doStuff(row.getColumn(), row.getColumn());

This does the deserialization twice, which is unnecessary and probably unexpected - I imagine most users treat the RowResult like they would one of the Immutables data objects.

jeremyk-91 avatar Jul 12 '19 13:07 jeremyk-91