Skip navigation links

Oracle® Coherence Java API Reference
Release 3.7.0.0

E18683-01


com.tangosol.net.cache
Class BackingMapBinaryEntry

java.lang.Object
  extended by com.tangosol.util.Base
      extended by com.tangosol.net.cache.BackingMapBinaryEntry

All Implemented Interfaces:
BinaryEntry, InvocableMap.Entry, QueryMap.Entry, java.util.Map.Entry
Direct Known Subclasses:
ReadWriteBackingMap.Entry

public class BackingMapBinaryEntry
extends Base
implements BinaryEntry

An implementation of the BinaryEntry interface that is based on specified binary key, binary value and BackingMapManagerContext. Analogous to the MapTrigger.Entry, it represents a pending change to an Entry that is about to committed to the underlying Map. For example, the original binary value of null indicates pending insert (a non-existing entry), while the binary value of null represents a pending remove operation.

It is currently only used by the ReadWriteBackingMap to communicate with the BinaryEntryStore.

This implementation is not thread safe.

Author:
gg 2009.11.22

Field Summary
protected  Binary m_binKey
          The Binary key.
protected  Binary m_binValue
          The Binary value.
protected  Binary m_binValueOrig
          The original Binary value.
protected  long m_cExpiryDelay
          Field holding the getExpiryDelay() property.
protected  BackingMapManagerContext m_ctx
          The backing map context.
protected  java.lang.Object m_oKey
          Lazily converted key in Object format.
protected  java.lang.Object m_oValue
          Lazily converted value in Object format.
protected  java.lang.Object m_oValueOrig
          Lazily converted original value in Object format.
protected static Binary NO_VALUE
          Marker object used to indicate that a lazily converted value has not yet been calculated.

 

Constructor Summary
BackingMapBinaryEntry(Binary binKey, Binary binValue, Binary binValueOrig, BackingMapManagerContext ctx)
          Construct a BackingMapBinaryEntry with the specified binary key, values and BackingMapManagerContext.

 

Method Summary
 boolean equals(java.lang.Object o)
          Compares the specified object with this entry for equality.
 void expire(long cMillis)
          Update the entry with the specified expiry delay.
 java.lang.Object extract(ValueExtractor extractor)
          Extract a value out of the Entry's value.
 ObservableMap getBackingMap()
          Obtain a reference to the backing map that this Entry corresponds to.
 BackingMapContext getBackingMapContext()
          Obtain a reference to the backing map context for the cache that this Entry corresponds to.
 Binary getBinaryKey()
          Return a raw binary key for this entry.
 Binary getBinaryValue()
          Return a raw binary value for this entry.
 BackingMapManagerContext getContext()
          Return the context this entry operates within.
 long getExpiryDelay()
          Get the "time to live" value for this entry.
 java.lang.Object getKey()
          Return the key corresponding to this entry.
 Binary getOriginalBinaryValue()
          Return a raw original binary value for this entry.
 java.lang.Object getOriginalValue()
          Return an original value for this entry.
 Serializer getSerializer()
          Return a Serializer that is used to serialize/deserialize this entry.
 java.lang.Object getValue()
          Return the value corresponding to this entry.
 int hashCode()
          Returns the hash code value for this entry.
 boolean isPresent()
          Determine if this Entry exists in the Map.
 boolean isReadOnly()
          Check whether this BinaryEntry allows data modification operations.
 void remove(boolean fSynthetic)
          Remove this Entry from the Map if it is present in the Map.
 java.lang.Object setValue(java.lang.Object oValue)
          Store the value corresponding to this entry.
 void setValue(java.lang.Object oValue, boolean fSynthetic)
          Store the value corresponding to this entry.
 java.lang.String toString()
          Render the entry as a String.
 void update(ValueUpdater updater, java.lang.Object oValue)
          Update the Entry's value.
 void updateBinaryValue(Binary binValue)
          Update the binary value for this entry.

 

Field Detail

m_ctx

protected BackingMapManagerContext m_ctx
The backing map context.

m_binKey

protected Binary m_binKey
The Binary key. This object reference will not change for the life of the Entry.

m_binValue

protected Binary m_binValue
The Binary value.

m_binValueOrig

protected Binary m_binValueOrig
The original Binary value.

m_cExpiryDelay

protected long m_cExpiryDelay
Field holding the getExpiryDelay() property.

m_oKey

protected java.lang.Object m_oKey
Lazily converted key in Object format.

m_oValue

protected java.lang.Object m_oValue
Lazily converted value in Object format.

m_oValueOrig

protected java.lang.Object m_oValueOrig
Lazily converted original value in Object format.

NO_VALUE

protected static final Binary NO_VALUE
Marker object used to indicate that a lazily converted value has not yet been calculated.

Constructor Detail

BackingMapBinaryEntry

public BackingMapBinaryEntry(Binary binKey,
                             Binary binValue,
                             Binary binValueOrig,
                             BackingMapManagerContext ctx)
Construct a BackingMapBinaryEntry with the specified binary key, values and BackingMapManagerContext.
Parameters:
binKey - the Binary key
binValue - the Binary value; could be null representing a non-existing entry
binValueOrig - an original Binary value; could be null representing an insert operation
ctx - a BackingMapManagerContext

Method Detail

getBinaryKey

public Binary getBinaryKey()
Return a raw binary key for this entry.
Specified by:
getBinaryKey in interface BinaryEntry
Returns:
a raw binary key for this entry

getBinaryValue

public Binary getBinaryValue()
Return a raw binary value for this entry.
Specified by:
getBinaryValue in interface BinaryEntry
Returns:
a raw binary value for this entry; null if the value does not exist

getOriginalBinaryValue

public Binary getOriginalBinaryValue()
Return a raw original binary value for this entry.
Specified by:
getOriginalBinaryValue in interface BinaryEntry
Returns:
a raw original binary value for this entry; null if the original value did not exist

getKey

public java.lang.Object getKey()
Return the key corresponding to this entry. The resultant key does not necessarily exist within the containing Map, which is to say that InvocableMap.this.containsKey(getKey()) could return false. To test for the presence of this key within the Map, use InvocableMap.Entry.isPresent(), and to create the entry for the key, use InvocableMap.Entry.setValue(java.lang.Object).
Specified by:
getKey in interface InvocableMap.Entry
Specified by:
getKey in interface java.util.Map.Entry
Returns:
the key corresponding to this entry; may be null if the underlying Map supports null keys

getValue

public java.lang.Object getValue()
Return the value corresponding to this entry. If the entry does not exist, then the value will be null. To differentiate between a null value and a non-existent entry, use InvocableMap.Entry.isPresent().

Note: any modifications to the value retrieved using this method are not guaranteed to persist unless followed by a InvocableMap.Entry.setValue(java.lang.Object) or InvocableMap.Entry.update(com.tangosol.util.ValueUpdater, java.lang.Object) call.

Specified by:
getValue in interface InvocableMap.Entry
Specified by:
getValue in interface java.util.Map.Entry
Returns:
the value corresponding to this entry; may be null if the value is null or if the Entry does not exist in the Map

getOriginalValue

public java.lang.Object getOriginalValue()
Return an original value for this entry.
Specified by:
getOriginalValue in interface BinaryEntry
Returns:
an original value for this entry

setValue

public java.lang.Object setValue(java.lang.Object oValue)
Store the value corresponding to this entry. If the entry does not exist, then the entry will be created by invoking this method, even with a null value (assuming the Map supports null values).
Specified by:
setValue in interface InvocableMap.Entry
Specified by:
setValue in interface java.util.Map.Entry
Parameters:
oValue - the new value for this Entry
Returns:
the previous value of this Entry, or null if the Entry did not exist

setValue

public void setValue(java.lang.Object oValue,
                     boolean fSynthetic)
Store the value corresponding to this entry. If the entry does not exist, then the entry will be created by invoking this method, even with a null value (assuming the Map supports null values).

Unlike the other form of setValue, this form does not return the previous value, and as a result may be significantly less expensive (in terms of cost of execution) for certain Map implementations.

Specified by:
setValue in interface InvocableMap.Entry
Parameters:
oValue - the new value for this Entry
fSynthetic - pass true only if the insertion into or modification of the Map should be treated as a synthetic event

updateBinaryValue

public void updateBinaryValue(Binary binValue)
Update the binary value for this entry.

Passing a non-null binary is functionally equivalent to:

   setValue(getContext().getValueFromInternalConverter().convert(binValue));
 
Passing null value is functionally equivalent to removing the entry.
   remove(false);
 
Specified by:
updateBinaryValue in interface BinaryEntry
Parameters:
binValue - a raw binary value to for this entry or null

getSerializer

public Serializer getSerializer()
Return a Serializer that is used to serialize/deserialize this entry.
Specified by:
getSerializer in interface BinaryEntry
Returns:
a Serializer that is used to serialize/deserialize this entry

getContext

public BackingMapManagerContext getContext()
Return the context this entry operates within.

Note: This method is a shortcut for the getBackingMapContext.getManagerContext() call.

Specified by:
getContext in interface BinaryEntry
Returns:
the BackingMapManagerContext for this entry

getBackingMap

public ObservableMap getBackingMap()
Obtain a reference to the backing map that this Entry corresponds to. The returned Map should be used in a read-only manner.

Note: This method is a shortcut for the getBackingMapContext.getBackingMap() call. As of Coherence 3.7, the returned type has been narrowed to ObservableMap.

Specified by:
getBackingMap in interface BinaryEntry
Returns:
the backing map reference; null if the entry does not have any backing map association

getBackingMapContext

public BackingMapContext getBackingMapContext()
Obtain a reference to the backing map context for the cache that this Entry corresponds to.
Specified by:
getBackingMapContext in interface BinaryEntry
Returns:
the corresponding BackingMapContext; null if the entry does not have any backing map association

expire

public void expire(long cMillis)
Update the entry with the specified expiry delay.

Note: this method only has an effect only if the associated backing map implements the CacheMap interface

Specified by:
expire in interface BinaryEntry
Parameters:
cMillis - the number of milliseconds until the entry will expire; pass CacheMap.EXPIRY_DEFAULT to use the default expiry setting; pass CacheMap.EXPIRY_NEVER to indicate that the entry should never expire

isReadOnly

public boolean isReadOnly()
Check whether this BinaryEntry allows data modification operations.
Specified by:
isReadOnly in interface BinaryEntry
Returns:
true iff the entry is "read-only"

update

public void update(ValueUpdater updater,
                   java.lang.Object oValue)
Update the Entry's value. Calling this method is semantically equivalent to:
   Object oTarget = entry.getValue();
   updater.update(oTarget, oValue);
   entry.setValue(oTarget, false);
 
The benefit of using this method is that it may allow the Entry implementation to significantly optimize the operation, such as for purposes of delta updates and backup maintenance.
Specified by:
update in interface InvocableMap.Entry
Parameters:
updater - a ValueUpdater used to modify the Entry's value
oValue - the new value for this Entry

isPresent

public boolean isPresent()
Determine if this Entry exists in the Map. If the Entry is not present, it can be created by calling InvocableMap.Entry.setValue(Object) or InvocableMap.Entry.setValue(Object, boolean). If the Entry is present, it can be destroyed by calling InvocableMap.Entry.remove(boolean).
Specified by:
isPresent in interface InvocableMap.Entry
Returns:
true iff this Entry is existent in the containing Map

remove

public void remove(boolean fSynthetic)
Remove this Entry from the Map if it is present in the Map.

This method supports both the operation corresponding to Map.remove(java.lang.Object) as well as synthetic operations such as eviction. If the containing Map does not differentiate between the two, then this method will always be identical to InvocableMap.this.remove(getKey()).

Specified by:
remove in interface InvocableMap.Entry
Parameters:
fSynthetic - pass true only if the removal from the Map should be treated as a synthetic event

extract

public java.lang.Object extract(ValueExtractor extractor)
Extract a value out of the Entry's value. Calling this method is semantically equivalent to extractor.extract(entry.getValue()), but this method may be significantly less expensive. For example, the resultant value may be obtained from a forward index, avoiding a potential object de-serialization.
Specified by:
extract in interface QueryMap.Entry
Parameters:
extractor - a ValueExtractor to apply to the Entry's value
Returns:
the extracted value

getExpiryDelay

public long getExpiryDelay()
Get the "time to live" value for this entry. The BackingMapBinaryEntry is commonly used as a "sandbox" for entry processors. This expiry value represents the time that the entry will live from the moment that it is committed to the backing map.
Returns:
the number of milliseconds from the moment this entry is committed until the entry expires, or CacheMap.EXPIRY_DEFAULT if the entry uses the default expiry setting; or CacheMap.EXPIRY_NEVER if the entry never expires

equals

public boolean equals(java.lang.Object o)
Compares the specified object with this entry for equality.
Specified by:
equals in interface java.util.Map.Entry
Parameters:
o - object to be compared for equality with this entry
Returns:
true if the specified object is equal to this entry

hashCode

public int hashCode()
Returns the hash code value for this entry.
Specified by:
hashCode in interface java.util.Map.Entry
Returns:
the hash code value for this entry.
See Also:
Object.hashCode(), Object.equals(Object), Map.Entry.equals(Object)

toString

public java.lang.String toString()
Render the entry as a String.
Returns:
the readable description for this entry

Skip navigation links

Oracle® Coherence Java API Reference
Release 3.7.0.0

E18683-01


Copyright © 2000, 2011, Oracle and/or its affiliates. All rights reserved.