org.openanzo.common.rdb.layout
Class ValueLayoutCacheProxy

java.lang.Object
  extended by org.openanzo.common.rdb.layout.ValueLayoutCacheProxy
All Implemented Interfaces:
ILayoutCache<java.lang.String>, IValueLayout

public class ValueLayoutCacheProxy
extends java.lang.Object
implements IValueLayout, ILayoutCache<java.lang.String>

Wraps and caches data accessed by an IValueLayout object.

Author:
Joe Betz, Stephen Evanchik

Constructor Summary
ValueLayoutCacheProxy(IValueLayout base, java.util.Map<java.lang.Long,java.lang.String> byIdCache, java.util.Map<java.lang.String,java.lang.Long> byValueCache)
          Create Cache Proxy for the given base layout.
 
Method Summary
 void batchAdd(java.util.Iterator<java.lang.String> iter)
          Doesn't cached added nodes
 void batchAddAndCache(java.util.Iterator<java.lang.String> iter)
          Add set of strings into this layout and cache their values
 java.lang.String cache(java.lang.Long id, java.lang.String value, java.lang.Long modifierId)
          Create object from provided ID and value and cache result
 void clearCache()
          Clear all cached objects and IDs
 void clearUncommittedCache()
          Clear any uncommitted cache entries
 void commitUncommittedCache()
          Commit any uncommitted cache entries
 ClosableIterator<NodeSQL.FetchAllCommonValuesResult> fetchAll()
          Doesn't cache fetched Nodes
 java.lang.Long fetchId(java.lang.String value)
          Fetch the ID for this value
 java.lang.String fetchValue(java.lang.Long id)
          Fetch the value for this ID
 java.lang.String getIfCached(java.lang.Long id)
          Get the Object for this ID, if already cached
 java.lang.Long getIfCached(java.lang.String value)
          Get the ID for this Object, if already cached
 boolean isCached(java.lang.Long id)
          Return true if an Object with this ID is already cached
 boolean isCached(java.lang.String value)
          Return true if a ID for this Object is already cached
 java.lang.Long store(java.lang.String value)
          Store String value
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ValueLayoutCacheProxy

public ValueLayoutCacheProxy(IValueLayout base,
                             java.util.Map<java.lang.Long,java.lang.String> byIdCache,
                             java.util.Map<java.lang.String,java.lang.Long> byValueCache)
Create Cache Proxy for the given base layout.

Parameters:
base - Base layout to add caching layer onto
byIdCache - ID cache for this layout
byValueCache - Value cache for this layout
Method Detail

clearCache

public void clearCache()
Description copied from interface: ILayoutCache
Clear all cached objects and IDs

Specified by:
clearCache in interface ILayoutCache<java.lang.String>

commitUncommittedCache

public void commitUncommittedCache()
Description copied from interface: ILayoutCache
Commit any uncommitted cache entries

Specified by:
commitUncommittedCache in interface ILayoutCache<java.lang.String>

clearUncommittedCache

public void clearUncommittedCache()
Description copied from interface: ILayoutCache
Clear any uncommitted cache entries

Specified by:
clearUncommittedCache in interface ILayoutCache<java.lang.String>

cache

public java.lang.String cache(java.lang.Long id,
                              java.lang.String value,
                              java.lang.Long modifierId)
Description copied from interface: ILayoutCache
Create object from provided ID and value and cache result

Specified by:
cache in interface ILayoutCache<java.lang.String>
Parameters:
id - ID of node
value - String value of node
modifierId - modifierId for literals
Returns:
converted object for provided data

isCached

public boolean isCached(java.lang.String value)
Description copied from interface: ILayoutCache
Return true if a ID for this Object is already cached

Specified by:
isCached in interface ILayoutCache<java.lang.String>
Parameters:
value - object to check
Returns:
true if a ID for this Object is already cached

isCached

public boolean isCached(java.lang.Long id)
Description copied from interface: ILayoutCache
Return true if an Object with this ID is already cached

Specified by:
isCached in interface ILayoutCache<java.lang.String>
Parameters:
id - id to check
Returns:
true if an Object with this ID is already cached

getIfCached

public java.lang.Long getIfCached(java.lang.String value)
Description copied from interface: ILayoutCache
Get the ID for this Object, if already cached

Specified by:
getIfCached in interface ILayoutCache<java.lang.String>
Parameters:
value - object to find cached ID
Returns:
the ID for this Object, if already cached

getIfCached

public java.lang.String getIfCached(java.lang.Long id)
Description copied from interface: ILayoutCache
Get the Object for this ID, if already cached

Specified by:
getIfCached in interface ILayoutCache<java.lang.String>
Parameters:
id - id of Object to retrieve
Returns:
the Object for this ID, if already cached

fetchId

public java.lang.Long fetchId(java.lang.String value)
Description copied from interface: IValueLayout
Fetch the ID for this value

Specified by:
fetchId in interface IValueLayout
Parameters:
value - value to lookup
Returns:
ID of stored value

fetchValue

public java.lang.String fetchValue(java.lang.Long id)
Description copied from interface: IValueLayout
Fetch the value for this ID

Specified by:
fetchValue in interface IValueLayout
Parameters:
id - id to lookup
Returns:
the value for this ID

store

public java.lang.Long store(java.lang.String value)
Description copied from interface: IValueLayout
Store String value

Specified by:
store in interface IValueLayout
Parameters:
value - value to store
Returns:
ID of stored value

batchAdd

public void batchAdd(java.util.Iterator<java.lang.String> iter)
Doesn't cached added nodes

Specified by:
batchAdd in interface IValueLayout
Parameters:
iter - Set of strings to store

fetchAll

public ClosableIterator<NodeSQL.FetchAllCommonValuesResult> fetchAll()
Doesn't cache fetched Nodes

Specified by:
fetchAll in interface IValueLayout
Returns:
all values for this type

batchAddAndCache

public void batchAddAndCache(java.util.Iterator<java.lang.String> iter)
Add set of strings into this layout and cache their values

Parameters:
iter - set of strings to store and cache


Copyright © 2007 Cambridge Semantics Inc.. All Rights Reserved.