ygerzhedovich commented on a change in pull request #474:
URL: https://github.com/apache/ignite-3/pull/474#discussion_r766526287
##########
File path:
modules/schema/src/main/java/org/apache/ignite/internal/schema/marshaller/reflection/Marshaller.java
##########
@@ -141,94 +133,112 @@ public static Marshaller createMarshaller(Columns cols,
Class<? extends Object>
*
* @param obj Object.
* @param writer Row writer.
- * @throws MarshallerException If failed.
+ * @throws MarshallerException If failed to marshall given object to a row.
*/
public abstract void writeObject(Object obj, RowAssembler writer) throws
MarshallerException;
/**
- * Marshaller for objects of natively supported types.
+ * Marshaller for key/value objects of natively supported types. The case
when a whole object maps to a single column.
*/
static class SimpleMarshaller extends Marshaller {
- /** Identity accessor. */
- private final FieldAccessor fieldAccessor;
+ /** Individual column binding. */
+ private final ColumnBinding columnBinding;
/**
* Creates a marshaller for objects of natively supported type.
*
- * @param fieldAccessor Identity field accessor for objects of
natively supported type.
+ * @param columnBinding Identity field binding for objects of natively
supported type.
*/
- SimpleMarshaller(FieldAccessor fieldAccessor) {
- this.fieldAccessor = fieldAccessor;
+ SimpleMarshaller(ColumnBinding columnBinding) {
+ this.columnBinding = columnBinding;
}
/** {@inheritDoc} */
@Override
- public @Nullable
- Object value(Object obj, int fldIdx) {
+ public @Nullable Object value(Object obj, int fldIdx) throws
MarshallerException {
assert fldIdx == 0;
- return fieldAccessor.value(obj);
+ return columnBinding.value(obj);
}
/** {@inheritDoc} */
@Override
- public Object readObject(Row reader) {
- return fieldAccessor.read(reader);
+ public Object readObject(Row reader) throws MarshallerException {
+ try {
+ return columnBinding.columnValue(reader);
+ } catch (Throwable e) {
+ throw new MarshallerException("Failed to read column: colIdx"
+ columnBinding.colIdx, e);
+ }
}
/** {@inheritDoc} */
@Override
public void writeObject(Object obj, RowAssembler writer) throws
MarshallerException {
- fieldAccessor.write(writer, obj);
+ try {
+ columnBinding.write(writer, obj);
+ } catch (Throwable e) {
+ throw new MarshallerException("Failed to write column: colIdx"
+ columnBinding.colIdx, e);
+ }
}
}
/**
- * Marshaller for POJOs.
+ * Marshaller for POJOs/ The case when an object fields map to the columns.
Review comment:
```suggestion
* Marshaller for POJOs. The case when an object fields map to the
columns.
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]