Search in sources :

Example 1 with NoteList

use of org.openntf.domino.big.NoteList in project org.openntf.domino by OpenNTF.

the class DVertex method writeEdges.

protected boolean writeEdges() {
    boolean result = false;
    Map<String, NoteList> inMap = getInEdgesMap();
    FastSet<String> inDirtySet = getInDirtyKeySet();
    if (!inDirtySet.isEmpty()) {
        for (String key : inDirtySet) {
            NoteList edgeIds = inMap.get(key);
            if (edgeIds != null) {
                // }
                if (edgeIds.size() == 0) {
                    removeProperty(DVertex.IN_PREFIX + key);
                    removeProperty("_COUNT" + DVertex.IN_PREFIX + key);
                    result = true;
                } else {
                    setProperty(DVertex.IN_PREFIX + key, edgeIds);
                    setProperty("_COUNT" + DVertex.IN_PREFIX + key, edgeIds.size());
                    result = true;
                }
            // getInEdgeCache().remove(key);
            // inMap.remove(key);
            }
        }
        inDirtySet.clear();
    }
    Map<String, NoteList> outMap = getOutEdgesMap();
    FastSet<String> outDirtySet = getOutDirtyKeySet();
    if (!outDirtySet.isEmpty()) {
        for (String key : outDirtySet) {
            NoteList edgeIds = outMap.get(key);
            if (edgeIds != null) {
                // }
                if (edgeIds.size() == 0) {
                    removeProperty(DVertex.OUT_PREFIX + key);
                    removeProperty("_COUNT" + DVertex.OUT_PREFIX + key);
                    result = true;
                } else {
                    setProperty(DVertex.OUT_PREFIX + key, edgeIds);
                    setProperty("_COUNT" + DVertex.OUT_PREFIX + key, edgeIds.size());
                    result = true;
                }
            // getOutEdgeCache().remove(key);
            // outMap.remove(key);
            }
        }
        outDirtySet.clear();
    }
    return result;
}
Also used : NoteList(org.openntf.domino.big.NoteList)

Example 2 with NoteList

use of org.openntf.domino.big.NoteList in project org.openntf.domino by OpenNTF.

the class DVertex method getOutEdgeCache.

protected DEdgeList getOutEdgeCache(final String label) {
    Map<String, DEdgeList> outCache = getOutEdgeCache();
    DEdgeList result = null;
    result = outCache.get(label);
    if (result == null) {
        NoteList list = getOutEdgesSet(label);
        int count = getOutEdgeCount(label);
        if (count != list.size()) {
            setProperty("_COUNT" + DVertex.OUT_PREFIX + label, list.size());
            applyChanges();
        }
        result = new DFastEdgeList(this, getParent(), list, label);
        outCache.put(label, result);
    }
    return result.atomic();
}
Also used : NoteList(org.openntf.domino.big.NoteList) DEdgeList(org.openntf.domino.graph2.DEdgeList)

Example 3 with NoteList

use of org.openntf.domino.big.NoteList in project org.openntf.domino by OpenNTF.

the class DVertex method getInEdgeCache.

protected DEdgeList getInEdgeCache(final String label) {
    Map<String, DEdgeList> inCache = getInEdgeCache();
    DEdgeList result = null;
    result = inCache.get(label);
    if (result == null) {
        NoteList list = getInEdgesSet(label);
        int count = getInEdgeCount(label);
        if (count != list.size()) {
            setProperty("_COUNT" + DVertex.IN_PREFIX + label, list.size());
            applyChanges();
        }
        result = new DFastEdgeList(this, getParent(), list, label);
        inCache.put(label, result);
    // System.out.println("TEMP DEBUG Cache MISS for edge list " + label + " size " + result.size() + " for "
    // + result.getClass().getSimpleName() + ": " + System.identityHashCode(result) + " into inCache: "
    // + System.identityHashCode(inCache) + " from Vertex: " + System.identityHashCode(this));
    } else {
    // System.out.println("TEMP DEBUG Cache hit for edge list " + label + " size " + result.size() + " for "
    // + result.getClass().getSimpleName() + ": " + System.identityHashCode(result) + " from inCache: "
    // + System.identityHashCode(inCache) + " from Vertex: " + System.identityHashCode(this));
    }
    return result.atomic();
}
Also used : NoteList(org.openntf.domino.big.NoteList) DEdgeList(org.openntf.domino.graph2.DEdgeList)

Example 4 with NoteList

use of org.openntf.domino.big.NoteList in project org.openntf.domino by OpenNTF.

the class DVertex method getInEdgesSet.

protected NoteList getInEdgesSet(final String label) {
    NoteList edgeIds = getInEdgesMap().get(label);
    if (edgeIds == null) {
        edgeIds = new org.openntf.domino.big.impl.NoteList(true);
        String key = DVertex.IN_PREFIX + label;
        Map<String, Object> delegate = getDelegate();
        if (delegate.containsKey(key)) {
            if (delegate instanceof Document) {
                byte[] bytes = ((Document) delegate).readBinary(key);
                // Factory.println("Loading a NoteList from an item for label " + label + " for vertex " + getId());
                edgeIds.loadByteArray(bytes);
            } else {
                Object o = getProperty(key, java.util.Collection.class);
                if (o instanceof NoteList) {
                    edgeIds = ((NoteList) o);
                } else if (o instanceof java.util.Collection) {
                    for (Object raw : (Collection<?>) o) {
                        if (raw instanceof String) {
                            edgeIds.add(new org.openntf.domino.big.impl.NoteCoordinate("", /*TODO NTF This should be some default replid*/
                            (String) raw));
                        } else {
                        // TODO NTF
                        }
                    }
                } else {
                    log_.log(Level.SEVERE, "ALERT! InEdges returned something other than a Collection " + o.getClass().getName() + ". We are clearing the values and rebuilding the edges.");
                }
            }
        } else {
        // Factory.println("Created a new in NoteList for " + label + " in vertex " + getId());
        // Throwable t = new Throwable();
        // t.printStackTrace();
        }
        Map<String, NoteList> map = getInEdgesMap();
        map.put(label, edgeIds);
    } else {
    // Factory.println("Found a cached in NoteList for " + label + " in vertex " + getId());
    }
    return edgeIds;
}
Also used : NoteList(org.openntf.domino.big.NoteList) Collection(java.util.Collection) Document(org.openntf.domino.Document)

Example 5 with NoteList

use of org.openntf.domino.big.NoteList in project org.openntf.domino by OpenNTF.

the class DVertex method getOutEdgesSet.

protected NoteList getOutEdgesSet(final String label) {
    NoteList edgeIds = getOutEdgesMap().get(label);
    if (edgeIds == null) {
        edgeIds = new org.openntf.domino.big.impl.NoteList(true);
        String key = DVertex.OUT_PREFIX + label;
        Map<String, Object> delegate = getDelegate();
        if (delegate.containsKey(key)) {
            if (delegate instanceof Document) {
                byte[] bytes = ((Document) delegate).readBinary(key);
                // System.out.println("TEMP DEBUG: read Document-based NoteList binary for " + label + " and found " + bytes.length
                // + " bytes");
                edgeIds.loadByteArray(bytes);
            } else {
                Object o = getProperty(key, java.util.Collection.class);
                if (o != null) {
                    if (o instanceof NoteList) {
                        edgeIds = ((NoteList) o);
                    } else if (o instanceof java.util.Collection) {
                        for (Object raw : (Collection<?>) o) {
                            if (raw instanceof String) {
                                edgeIds.add(new org.openntf.domino.big.impl.NoteCoordinate("", /*TODO NTF This should be some default replid*/
                                (String) raw));
                            } else {
                            // TODO NTF
                            }
                        }
                    } else {
                        log_.log(Level.SEVERE, "ALERT! OutEdges returned something other than a Collection " + o.getClass().getName() + ". We are clearing the values and rebuilding the edges.");
                    }
                }
            }
        } else {
        // System.out.println("TEMP DEBUG Returning new out edge set for " + label);
        }
        Map<String, NoteList> map = getOutEdgesMap();
        map.put(label, edgeIds);
    }
    return edgeIds;
}
Also used : NoteList(org.openntf.domino.big.NoteList) Collection(java.util.Collection) Document(org.openntf.domino.Document)

Aggregations

NoteList (org.openntf.domino.big.NoteList)5 Collection (java.util.Collection)2 Document (org.openntf.domino.Document)2 DEdgeList (org.openntf.domino.graph2.DEdgeList)2