You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by am...@apache.org on 2021/10/27 11:06:35 UTC
[ignite-3] 02/02: Minor.
This is an automated email from the ASF dual-hosted git repository.
amashenkov pushed a commit to branch ignite-15783
in repository https://gitbox.apache.org/repos/asf/ignite-3.git
commit 344b2a4c0a7794ef8bb4c10d256607f73010535c
Author: Andrew Mashenkov <an...@gmail.com>
AuthorDate: Wed Oct 27 14:06:26 2021 +0300
Minor.
---
.../schema/marshaller/SerializerFactory.java | 6 ++--
.../ignite/internal/table/KeyValueViewImpl.java | 35 ++++++++++++++++------
2 files changed, 29 insertions(+), 12 deletions(-)
diff --git a/modules/schema/src/main/java/org/apache/ignite/internal/schema/marshaller/SerializerFactory.java b/modules/schema/src/main/java/org/apache/ignite/internal/schema/marshaller/SerializerFactory.java
index bbc173c..ca601d5 100644
--- a/modules/schema/src/main/java/org/apache/ignite/internal/schema/marshaller/SerializerFactory.java
+++ b/modules/schema/src/main/java/org/apache/ignite/internal/schema/marshaller/SerializerFactory.java
@@ -29,14 +29,14 @@ public interface SerializerFactory {
/**
* @return Serializer factory back by code generator.
*/
- public static SerializerFactory createGeneratedSerializerFactory() {
+ static SerializerFactory createGeneratedSerializerFactory() {
return new AsmSerializerGenerator();
}
/**
* @return Reflection-based serializer factory.
*/
- public static SerializerFactory createJavaSerializerFactory() {
+ static SerializerFactory createJavaSerializerFactory() {
return new JavaSerializerFactory();
}
@@ -48,5 +48,5 @@ public interface SerializerFactory {
* @param valClass Value class.
* @return Serializer.
*/
- public Serializer create(SchemaDescriptor schema, Class<?> keyClass, Class<?> valClass);
+ Serializer create(SchemaDescriptor schema, Class<?> keyClass, Class<?> valClass);
}
diff --git a/modules/table/src/main/java/org/apache/ignite/internal/table/KeyValueViewImpl.java b/modules/table/src/main/java/org/apache/ignite/internal/table/KeyValueViewImpl.java
index 3e5615f..91bd329 100644
--- a/modules/table/src/main/java/org/apache/ignite/internal/table/KeyValueViewImpl.java
+++ b/modules/table/src/main/java/org/apache/ignite/internal/table/KeyValueViewImpl.java
@@ -237,8 +237,7 @@ public class KeyValueViewImpl<K, V> extends AbstractTableView implements KeyValu
}
/** {@inheritDoc} */
- @Override
- public <R extends Serializable> R invoke(@NotNull K key, InvokeProcessor<K, V, R> proc, Serializable... args) {
+ @Override public <R extends Serializable> R invoke(@NotNull K key, InvokeProcessor<K, V, R> proc, Serializable... args) {
throw new UnsupportedOperationException("Not implemented yet.");
}
@@ -281,7 +280,7 @@ public class KeyValueViewImpl<K, V> extends AbstractTableView implements KeyValu
if (marsh.schemaVersion == schemaVersion)
return marsh;
- // TODO: Cache marshaller for schema or upgrade row?
+ // TODO: Cache marshaller for schema version or upgrade row?
marsh = new KVMarshallerImpl<>(
schemaVersion,
marshallerFactory.create(
@@ -304,36 +303,54 @@ public class KeyValueViewImpl<K, V> extends AbstractTableView implements KeyValu
return marsh.marshal(key, o);
}
+ /**
+ * Marshaller wrapper for KV view.
+ * Note: Serializer must be re-created if schema changed.
+ *
+ * @param <K> Key type.
+ * @param <V> Value type.
+ */
private static class KVMarshallerImpl<K, V> implements KVMarshaller<K, V> {
+ /** Schema version. */
private final int schemaVersion;
- private Serializer delegate;
+ /** Serializer. */
+ private Serializer serializer;
- public KVMarshallerImpl(int schemaVersion, Serializer delegate) {
+ /**
+ * Creates KV marshaller.
+ *
+ * @param schemaVersion Schema version.
+ * @param serializer Serializer.
+ */
+ public KVMarshallerImpl(int schemaVersion, Serializer serializer) {
this.schemaVersion = schemaVersion;
- this.delegate = delegate;
+ this.serializer = serializer;
}
+ /** {@inheritDoc} */
@Override public BinaryRow marshal(@NotNull K key, V val) {
try {
- return new ByteBufferRow(ByteBuffer.wrap(delegate.serialize(key, val)).order(ByteOrder.LITTLE_ENDIAN));
+ return new ByteBufferRow(ByteBuffer.wrap(serializer.serialize(key, val)).order(ByteOrder.LITTLE_ENDIAN));
} catch (SerializationException e) {
throw new IgniteException(e);
}
}
+ /** {@inheritDoc} */
@NotNull @Override public K unmarshalKey(@NotNull BinaryRow row) {
try {
- return delegate.deserializeKey(row.bytes());
+ return serializer.deserializeKey(row.bytes());
} catch (SerializationException e) {
throw new IgniteException(e);
}
}
+ /** {@inheritDoc} */
@Nullable @Override public V unmarshalValue(@NotNull BinaryRow row) {
try {
- return delegate.deserializeValue(row.bytes());
+ return serializer.deserializeValue(row.bytes());
} catch (SerializationException e) {
throw new IgniteException(e);
}