Adding ability to set a marshaller to cache configuration:
public class CacheConfiguration { // ... public void setMarshaller(Marshaller marshaller) {...} public Marshaller getMarshaller() {...} // ... }
Public API: New Interface
/** * Abstracted binary representation of objects. */ public interface IgniteObject { /** * Gets portable object type ID. * * @return Type ID. */ public int typeId(); /** * Gets fully deserialized instance of portable object. * * @return Fully deserialized instance of portable object. */ @Nullable public <T> T deserialize() throws IgniteException; /** * Gets field value. * * @param fieldName Field name. * @return Field value. */ @Nullable public <T> T field(String fieldName); /** * Checks whether field is set. * * @param fieldName Field name. * @return {@code true} if field is set. */ public boolean hasField(String fieldName); /** * Gets the source input stream that was used to create this IgniteObject. */ public SeekableDataInput source(); }
public interface IgniteObjectMarshaller extends Marshaller { /** * @param input Seekable input. * @return Cache object. */ @Nullable public IgniteObject toIgniteObject(SeekableDataInput input); /** * @param input Seekable input. * @return Cache object. */ @Nullable public IgniteObject toIgniteObject(byte[] data); /** * @param typeName Type name. * @return Type ID. */ public abstract int typeId(String typeName);}
public interface SeekableDataInput extends DataInput { public long position(); public void seek(long pos) throws IOException; public void ensureOnHeap(); }
4 Comments
Dmitriy Setrakyan
I have a question on
IgniteObject.source()
method. How will you be able to provide the source if you cannot really cache a reference to it?Alexey Goncharuk
In cases when an input stream is passed to the object factory, the input stream will be store in the object. Otherwise, source stream can be created from byte array.
Dmitriy Setrakyan
Can you please provide more details? I don't see an object factory in the design.
Dmitriy Setrakyan
I still don't like this
source()
method name. Why do we care if it is the original source or a new one just created? I think a specific implementation of IgniteObject should always know how to create theSeekableDataInput
based on its internal state, regardless if it was created from a byte array or an off-heap pointer. Perhaps we should rename the method todataInput()
?