Author: vgritsenko Date: Tue Nov 13 08:59:33 2007 New Revision: 594581 URL: http://svn.apache.org/viewvc?rev=594581&view=rev Log: add putEntryMeta method. javadoc changes.
Modified: xml/xindice/trunk/java/src/org/apache/xindice/core/Collection.java xml/xindice/trunk/java/src/org/apache/xindice/core/cache/DocumentCache.java xml/xindice/trunk/java/src/org/apache/xindice/core/cache/DocumentCacheImpl.java Modified: xml/xindice/trunk/java/src/org/apache/xindice/core/Collection.java URL: http://svn.apache.org/viewvc/xml/xindice/trunk/java/src/org/apache/xindice/core/Collection.java?rev=594581&r1=594580&r2=594581&view=diff ============================================================================== --- xml/xindice/trunk/java/src/org/apache/xindice/core/Collection.java (original) +++ xml/xindice/trunk/java/src/org/apache/xindice/core/Collection.java Tue Nov 13 08:59:33 2007 @@ -1255,7 +1255,6 @@ */ byte[] documentBytes; - String documentChars = null; // FIXME: concurrent symbol table access. if (compressed) { @@ -1276,7 +1275,7 @@ } } else { // Create uncompressed document bytes to be stored in the filer - documentChars = TextWriter.toString(document); + String documentChars = TextWriter.toString(document); try { documentBytes = documentChars.getBytes("utf-8"); } catch (UnsupportedEncodingException e) { @@ -1582,7 +1581,7 @@ Key key = getIdentityKey(createNewKey(id)); synchronized (key) { - if (getEntry(id) == null) { + if (getEntryMeta(id) == null) { throw new DBException(FaultCodes.COL_DOCUMENT_NOT_FOUND, "Resource '" + id + "' does not exist in '" + getCanonicalName() + "'"); } @@ -1635,12 +1634,12 @@ Key key = getIdentityKey(createNewKey(id)); synchronized (key) { - if (null == getEntry(id)) { + if (getEntryMeta(id) == null) { throw new DBException(FaultCodes.COL_DOCUMENT_NOT_FOUND, "Resource '" + id + "' does not exist in '" + getCanonicalName() + "'"); } - if (null != meta) { + if (meta != null) { if (meta.getType() == MetaData.UNKNOWN || meta.getType() == MetaData.COLLECTION) { throw new DBException(FaultCodes.GEN_UNKNOWN, "Mismatch type of meta data for document " + getCanonicalDocumentName(id)); Modified: xml/xindice/trunk/java/src/org/apache/xindice/core/cache/DocumentCache.java URL: http://svn.apache.org/viewvc/xml/xindice/trunk/java/src/org/apache/xindice/core/cache/DocumentCache.java?rev=594581&r1=594580&r2=594581&view=diff ============================================================================== --- xml/xindice/trunk/java/src/org/apache/xindice/core/cache/DocumentCache.java (original) +++ xml/xindice/trunk/java/src/org/apache/xindice/core/cache/DocumentCache.java Tue Nov 13 08:59:33 2007 @@ -27,26 +27,24 @@ import java.util.Map; /** - * DocumentCache implements a simple database Entry caching system for - * Collections. + * DocumentCache implements a simple caching system for + * Collection resources. * * @version $Revision$, $Date$ */ public interface DocumentCache { - // Cache Entry types constants - - /** Entry type for the compressed XML document entry */ + /** Compressed document resource type */ int COMPRESSED = 1; - /** Entry type for the uncompressed XML document entry */ + /** Uncompressed document resource type */ int UNCOMPRESSED = 2; - /** Entry type for the binary entry */ + /** Binary resource type */ int BINARY = 3; /** - * Cache key consists of collection and entry key + * Cache key consists of collection and resource key */ class CacheKey { private final Collection col; @@ -90,39 +88,49 @@ } /** - * Obtains entry from the cache + * Obtains resource entry from the cache * - * @param col entry collection - * @param key entry key - * @return entry from the cache or null if not present + * @param col resource collection + * @param key resource key + * @return entry cached resource entry or null if not present */ Entry getEntry(Collection col, Key key); /** - * Obtains entry metadata from cache. + * Obtains resource entry metadata from cache. * - * @param col entry collection - * @param key entry key - * @return entry meta data from the cache or null if not present + * @param col resource collection + * @param key resource key + * @return entry cached resource metadata or null if not present */ Entry getEntryMeta(Collection col, Key key); /** - * Stores entry value in the cache + * Stores resource entry value in the cache * - * @param col document entry collection - * @param key document entry key - * @param type entry type: COMPRESSED, UNCOMPRESSED, BINARY + * @param col resource collection + * @param key resource key + * @param type resource type: COMPRESSED, UNCOMPRESSED, BINARY * @param value entry value - * @param meta document meta attributes map + * @param meta resource meta attributes map */ void putEntry(Collection col, Key key, int type, Value value, Map meta); /** - * Remove entry from the cache + * Stores resource meta entry in the cache + * + * @param col resource collection + * @param key resource key + * @param type resource type: COMPRESSED, UNCOMPRESSED, BINARY + * @param meta resource metadata attributes map + */ + void putEntryMeta(Collection col, Key key, int type, Map meta); + + /** + * Remove resource entry from the cache * - * @param col entry collection - * @param key entry key + * @param col resource collection + * @param key resource key */ void removeEntry(Collection col, Key key); } Modified: xml/xindice/trunk/java/src/org/apache/xindice/core/cache/DocumentCacheImpl.java URL: http://svn.apache.org/viewvc/xml/xindice/trunk/java/src/org/apache/xindice/core/cache/DocumentCacheImpl.java?rev=594581&r1=594580&r2=594581&view=diff ============================================================================== --- xml/xindice/trunk/java/src/org/apache/xindice/core/cache/DocumentCacheImpl.java (original) +++ xml/xindice/trunk/java/src/org/apache/xindice/core/cache/DocumentCacheImpl.java Tue Nov 13 08:59:33 2007 @@ -61,7 +61,7 @@ private final int type; private final Key key; private final Value value; - private final Map meta; + private Map meta; public CacheEntry(int type, Key key, Value value, Map meta) { this.type = type; @@ -85,6 +85,10 @@ public Map getMeta() { return meta; } + + void setMeta(Map meta) { + this.meta = meta; + } } @@ -144,6 +148,19 @@ CacheKey ckey = new CacheKey(col, key); synchronized (table) { table.put(ckey, new CacheEntry(type, key, value, meta)); + } + } + + public void putEntryMeta(Collection col, Key key, int type, Map meta) { + CacheKey ckey = new CacheKey(col, key); + synchronized (table) { + CacheEntry e = (CacheEntry) table.get(ckey); + if (e == null) { + e = new CacheEntry(type, key, null, meta); + } else { + e.setMeta(meta); + } + table.put(ckey, e); } }