Package org.apache.jackrabbit.oak.plugins.document.util

Examples of org.apache.jackrabbit.oak.plugins.document.util.StringValue


                w.tag('-').value(p).newline();
            }
            for (String p : changed) {
                w.tag('^').key(p).object().endObject().newline();
            }
            diffCache.put(key, new StringValue(w.toString()));
        }
        // update docChildrenCache
        if (!added.isEmpty()) {
            CacheValue docChildrenKey = new StringValue(path);
            NodeDocument.Children docChildren = docChildrenCache.getIfPresent(docChildrenKey);
            if (docChildren != null) {
                int currentSize = docChildren.childNames.size();
                NavigableSet<String> names = Sets.newTreeSet(docChildren.childNames);
                // incomplete cache entries must not be updated with
View Full Code Here


                base.getLastRevision(), node.getLastRevision());
        try {
            return diffCache.get(key, new Callable<StringValue>() {
                @Override
                public StringValue call() throws Exception {
                    return new StringValue(diffImpl(base, node));
                }
            }).toString();
        } catch (ExecutionException e) {
            if (e.getCause() instanceof MicroKernelException) {
                throw (MicroKernelException) e.getCause();
View Full Code Here

            JsopWriter writer = new JsopStream();
            diffProperties(from, to, writer);
            return writer.toString() + diffCache.get(key, new Callable<StringValue>() {
                @Override
                public StringValue call() throws Exception {
                    return new StringValue(diffImpl(from, to));
                }
            });
        } catch (ExecutionException e) {
            if (e.getCause() instanceof MicroKernelException) {
                throw (MicroKernelException) e.getCause();
View Full Code Here

    @Override
    public <T extends Document> void invalidateCache(Collection<T> collection, String key) {
        if (collection == Collection.NODES) {
            Lock lock = getAndLock(key);
            try {
                nodesCache.invalidate(new StringValue(key));
            } finally {
                lock.unlock();
            }
        }
    }
View Full Code Here

                                       final String key,
                                       int maxCacheAge) {
        if (collection != Collection.NODES) {
            return findUncached(collection, key);
        }
        CacheValue cacheKey = new StringValue(key);
        NodeDocument doc;
        if (maxCacheAge > 0) {
            // first try without lock
            doc = nodesCache.getIfPresent(cacheKey);
            if (doc != null) {
View Full Code Here

                    T doc = convertFromDBObject(collection, o);
                    if (collection == Collection.NODES && doc != null) {
                        doc.seal();
                        String id = doc.getId();
                        Lock lock = getAndLock(id);
                        CacheValue cacheKey = new StringValue(id);
                        try {
                            // do not overwrite document in cache if the
                            // existing one in the cache is newer
                            NodeDocument cached = nodesCache.getIfPresent(cacheKey);
                            if (cached != null && cached != NodeDocument.NULL) {
View Full Code Here

            // get modCount of cached document
            Number modCount = null;
            T cachedDoc = null;
            if (collection == Collection.NODES) {
                @SuppressWarnings("unchecked")
                T doc = (T) nodesCache.getIfPresent(new StringValue(updateOp.getId()));
                cachedDoc = doc;
                if (cachedDoc != null) {
                    modCount = cachedDoc.getModCount();
                }
            }
View Full Code Here

        try {
            Map<String, NodeDocument> cachedDocs = Collections.emptyMap();
            if (collection == Collection.NODES) {
                cachedDocs = Maps.newHashMap();
                for (String key : keys) {
                    cachedDocs.put(key, nodesCache.getIfPresent(new StringValue(key)));
                }
            }
            try {
                WriteResult writeResult = dbCollection.update(query.get(), update, false, true, WriteConcern.SAFE);
                if (writeResult.getError() != null) {
                    throw new MicroKernelException("Update failed: " + writeResult.getError());
                }
                // update cache
                for (Entry<String, NodeDocument> entry : cachedDocs.entrySet()) {
                    Lock lock = getAndLock(entry.getKey());
                    try {
                        if (entry.getValue() == null) {
                            // make sure concurrently loaded document is invalidated
                            nodesCache.invalidate(new StringValue(entry.getKey()));
                        } else {
                            applyToCache(Collection.NODES, entry.getValue(),
                                    updateOp.shallowCopy(entry.getKey()));
                        }
                    } finally {
View Full Code Here

    CachedNodeDocument getCachedNodeDoc(String id) {
        if (nodesCache instanceof OffHeapCache) {
            return ((OffHeapCache) nodesCache).getCachedDocument(id);
        }

        return nodesCache.getIfPresent(new StringValue(id));
    }
View Full Code Here

    public <T extends Document> T getIfCached(Collection<T> collection, String key) {
        if (collection != Collection.NODES) {
            return null;
        }
        @SuppressWarnings("unchecked")
        T doc = (T) nodesCache.getIfPresent(new StringValue(key));
        return doc;
    }
View Full Code Here

TOP

Related Classes of org.apache.jackrabbit.oak.plugins.document.util.StringValue

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.