Cache configuration changes
Adding ability to set a marshaller to cache configuration:
...
Code Block |
---|
|
/**
* 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);
} |
...
New component: CacheObjectManager
Default implementation of CacheObjectManager assumes that it is impossible to read a field from an object without deserialization.
Code Block |
---|
language | java |
---|
title | CacheObjectManager |
---|
|
/**
*
*/
public interface CacheObjectFactory {
/**
* @paramGets objthe Object.
source input stream that was *used @paramto userObjcreate If {@code true} then given object is object provided by user and should be copied
* before stored in cache.
* @return Cache objectthis IgniteObject.
*/
@Nullable public CacheObjectSeekableDataInput toCacheObjectsource(SeekableDataInput input);
/**
} |
IgniteObjectMarshaller
Code Block |
---|
|
public interface IgniteObjectMarshaller extends Marshaller {
* @param type Object type. /**
* @param bytesinput ObjectSeekable bytesinput.
* @return Cache object.
*/
@Nullable public abstractIgniteObject CacheObject toCacheObjecttoIgniteObject(byte type, byte[] bytesSeekableDataInput input);
/**
* @param valPtrinput Value pointer.
* @param tmp If {@code true} can return temporary instance which is valid while entry lock is heldSeekable input.
* @return Cache object.
* @throws IgniteCheckedException If failed./
*/
@Nullable public abstractIgniteObject CacheObject toCacheObject(long valPtr, boolean tmp) throws IgniteCheckedExceptiontoIgniteObject(byte[] data);
/**
* @param typeName Type name.
* @return Type ID.
*/
public abstract int typeId(String typeName);
/**}
|
Code Block |
---|
|
public interface SeekableDataInput extends DataInput {
public * @param obj Object to get type ID for.
* @return Type ID.
*/long position();
public void seek(long pos) throws IOException;
public abstractvoid int typeId(Object obj);
...
} |
If marshaller implementation supports fields read without deserialization, it should provide an implementation of CacheObjectManager that is able to convert a user object to the specific CacheObject implementation.
Code Block |
---|
|
@CacheObjectProcessor(impl=MyCacheObjectProcessor.class)
public class MyMarshaller implements Marshaller {ensureOnHeap();
} |