You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 3 Next »

Cache configuration changes

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);
}

 

New component: CacheObjectManager

Default implementation of CacheObjectManager assumes that it is impossible to read a field from an object without deserialization.

 

CacheObjectManager
/**
 *
 */
public abstract class CacheObjectManager extends GridCacheManagerAdapter {
    /**
     * Checks whether this functionality is globally supported.
     *
     * @return {@code true} if enabled.
     */
    public abstract boolean isFieldsIndexingEnabled();

    /**
     * @param obj Key value.
     * @param userObj If {@code true} then given object is object provided by user and should be copied
     * before stored in cache.
     * @return Cache key object.
     */
    public abstract KeyCacheObject toCacheKeyObject(Object obj, boolean userObj);

    /**
     * @param obj Object.
     * @param userObj If {@code true} then given object is object provided by user and should be copied
     * before stored in cache.
     * @return Cache object.
     */
    @Nullable public abstract CacheObject toCacheObject(@Nullable Object obj, boolean userObj);

    /**
     * @param type Object type.
     * @param bytes Object bytes.
     * @return Cache object.
     */
    public abstract CacheObject toCacheObject(byte type, byte[] bytes);

    /**
     * @param valPtr Value pointer.
     * @param tmp If {@code true} can return temporary instance which is valid while entry lock is held.
     * @return Cache object.
     * @throws IgniteCheckedException If failed.
     */
    public abstract CacheObject toCacheObject(long valPtr, boolean tmp) throws IgniteCheckedException;

    /**
     * @param typeName Type name.
     * @return Type ID.
     */
    public abstract int typeId(String typeName);

    /**
     * @param obj Object to get type ID for.
     * @return Type ID.
     */
    public abstract 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.

@CacheObjectProcessor(impl=MyCacheObjectProcessor.class)
public class MyMarshaller implements Marshaller {
}

 

 
  • No labels