use of org.apache.ignite.internal.schema.marshaller.MarshallerException in project ignite-3 by apache.
the class KeyValueViewImpl method marshal.
/**
* Marshal keys to a row.
*
* @param keys Key objects.
* @return Binary rows.
*/
@NotNull
public Collection<BinaryRow> marshal(@NotNull Collection<K> keys) {
final KvMarshaller<K, V> marsh = marshaller(schemaReg.lastSchemaVersion());
List<BinaryRow> keyRows = new ArrayList<>(keys.size());
try {
for (K key : keys) {
final BinaryRow keyRow = marsh.marshal(Objects.requireNonNull(key));
keyRows.add(keyRow);
}
} catch (MarshallerException e) {
throw new IgniteException(e);
}
return keyRows;
}
use of org.apache.ignite.internal.schema.marshaller.MarshallerException in project ignite-3 by apache.
the class KeyValueViewImpl method unmarshalPairs.
/**
* Marshal key-value pairs.
*
* @param rows Binary rows.
* @return Key-value pairs.
*/
@NotNull
public Map<K, V> unmarshalPairs(Collection<BinaryRow> rows) {
if (rows.isEmpty()) {
return Collections.emptyMap();
}
final KvMarshaller<K, V> marsh = marshaller(schemaReg.lastSchemaVersion());
Map<K, V> pairs = new HashMap<>(rows.size());
try {
for (Row row : schemaReg.resolve(rows)) {
if (row != null) {
pairs.put(marsh.unmarshalKey(row), marsh.unmarshalValue(row));
}
}
return pairs;
} catch (MarshallerException e) {
throw new IgniteException(e);
}
}
use of org.apache.ignite.internal.schema.marshaller.MarshallerException in project ignite-3 by apache.
the class RecordViewImpl method unmarshal.
/**
* Unmarshal records.
*
* @param rows Row collection.
* @return Records collection.
*/
@NotNull
public Collection<R> unmarshal(Collection<BinaryRow> rows) {
if (rows.isEmpty()) {
return Collections.emptyList();
}
final RecordMarshaller<R> marsh = marshaller(schemaReg.lastSchemaVersion());
List<R> recs = new ArrayList<>(rows.size());
try {
for (Row row : schemaReg.resolve(rows)) {
if (row != null) {
recs.add(marsh.unmarshal(row));
}
}
return recs;
} catch (MarshallerException e) {
throw new IgniteException(e);
}
}
use of org.apache.ignite.internal.schema.marshaller.MarshallerException in project ignite-3 by apache.
the class RecordViewImpl method marshalKeys.
/**
* Marshal key-records.
*
* @param recs Records collection.
* @return Binary rows collection.
*/
private Collection<BinaryRow> marshalKeys(@NotNull Collection<R> recs) {
final RecordMarshaller<R> marsh = marshaller(schemaReg.lastSchemaVersion());
List<BinaryRow> rows = new ArrayList<>(recs.size());
try {
for (R rec : recs) {
final BinaryRow row = marsh.marshalKey(Objects.requireNonNull(rec));
rows.add(row);
}
return rows;
} catch (MarshallerException e) {
throw new IgniteException(e);
}
}
use of org.apache.ignite.internal.schema.marshaller.MarshallerException in project ignite-3 by apache.
the class RecordViewImpl method marshal.
/**
* Marshal records.
*
* @param recs Records collection.
* @return Binary rows collection.
*/
private Collection<BinaryRow> marshal(@NotNull Collection<R> recs) {
final RecordMarshaller<R> marsh = marshaller(schemaReg.lastSchemaVersion());
List<BinaryRow> rows = new ArrayList<>(recs.size());
try {
for (R rec : recs) {
final BinaryRow row = marsh.marshal(Objects.requireNonNull(rec));
rows.add(row);
}
return rows;
} catch (MarshallerException e) {
throw new IgniteException(e);
}
}
Aggregations