use of org.apache.ignite.internal.schema.marshaller.MarshallerException in project ignite-3 by apache.
the class RecordViewImpl method unmarshal.
/**
* Unmarshal value object from given binary row.
*
* @param binaryRow Binary row.
* @return Value object.
*/
private R unmarshal(BinaryRow binaryRow) {
if (binaryRow == null || !binaryRow.hasValue()) {
return null;
}
Row row = schemaReg.resolve(binaryRow);
RecordMarshaller<R> marshaller = marshaller(row.schemaVersion());
try {
return marshaller.unmarshal(row);
} catch (MarshallerException e) {
throw new IgniteException(e);
}
}
use of org.apache.ignite.internal.schema.marshaller.MarshallerException in project ignite-3 by apache.
the class KeyValueViewImpl method unmarshalKeys.
/**
* Marshal keys.
*
* @param rows Binary rows.
* @return Keys.
*/
@NotNull
public Collection<K> unmarshalKeys(Collection<BinaryRow> rows) {
if (rows.isEmpty()) {
return Collections.emptyList();
}
final KvMarshaller<K, V> marsh = marshaller(schemaReg.lastSchemaVersion());
List<K> keys = new ArrayList<>(rows.size());
try {
for (Row row : schemaReg.resolve(rows)) {
if (row != null) {
keys.add(marsh.unmarshalKey(row));
}
}
return keys;
} catch (MarshallerException e) {
throw new IgniteException(e);
}
}
use of org.apache.ignite.internal.schema.marshaller.MarshallerException in project ignite-3 by apache.
the class KeyValueViewImpl method marshal.
/**
* Marshal key-value pairs.
*
* @param pairs Key-value map.
* @return Binary rows.
*/
@NotNull
public List<BinaryRow> marshal(@NotNull Map<K, V> pairs) {
final KvMarshaller<K, V> marsh = marshaller(schemaReg.lastSchemaVersion());
List<BinaryRow> rows = new ArrayList<>(pairs.size());
try {
for (Map.Entry<K, V> pair : pairs.entrySet()) {
final BinaryRow row = marsh.marshal(Objects.requireNonNull(pair.getKey()), pair.getValue());
rows.add(row);
}
} catch (MarshallerException e) {
throw new IgniteException(e);
}
return rows;
}
use of org.apache.ignite.internal.schema.marshaller.MarshallerException in project ignite-3 by apache.
the class KeyValueViewImpl method unmarshalValue.
/**
* Unmarshal value object from given binary row.
*
* @param binaryRow Binary row.
* @return Value object.
*/
private V unmarshalValue(BinaryRow binaryRow) {
if (binaryRow == null || !binaryRow.hasValue()) {
return null;
}
Row row = schemaReg.resolve(binaryRow);
KvMarshaller<K, V> marshaller = marshaller(row.schemaVersion());
try {
return marshaller.unmarshalValue(row);
} catch (MarshallerException e) {
throw new IgniteException(e);
}
}
Aggregations