Package org.openntf.domino.big.impl

Examples of org.openntf.domino.big.impl.NoteList


    Document storeTest = log.createDocument();
    storeTest.replaceItemValue("form", "BinaryTest");
    Database db = session.getDatabase("", "imdb/movies.nsf");

    try {
      NoteList notelist = new NoteList();
      marktime = System.nanoTime();
      timelog("Beginning first notelist...");
      NoteCollection notecoll = db.createNoteCollection(false);
      notecoll.setSelectDocuments(true);
      notecoll.setSelectionFormula("@Begins(Title; \"B\")");
      notecoll.buildCollection();
      //      DocumentCollection coll = db.search("@Begins(Title; \"B\")");
      timelog("Starting note coordinates of " + notecoll.getCount() + " documents");
      //      for (Document doc : notecoll) {
      for (String nid : notecoll) {
        NoteCoordinate nc = new NoteCoordinate(notecoll, nid);
        notelist.add(nc);
      }

      //      Database eventDb = session.getDatabase("", "events4.nsf");
      //      NoteCollection eventNotecoll = eventDb.createNoteCollection(false);
      //      eventNotecoll.setSelectDocuments(true);
      //      eventNotecoll.buildCollection();
      //      timelog("Continuing note coordinates of " + eventNotecoll.getCount() + " documents");
      //      for (String nid : eventNotecoll) {
      //        NoteCoordinate nc = new NoteCoordinate(eventNotecoll, nid);
      //        notelist.add(nc);
      //      }
      //      Database xspextDb = session.getDatabase("", "openntf/xpagesext.nsf");
      //      NoteCollection xspextNotecoll = xspextDb.createNoteCollection(false);
      //      xspextNotecoll.setSelectDocuments(true);
      //      xspextNotecoll.buildCollection();
      //      timelog("Continuing note coordinates of " + xspextNotecoll.getCount() + " documents");
      //      for (String nid : xspextNotecoll) {
      //        NoteCoordinate nc = new NoteCoordinate(xspextNotecoll, nid);
      //        notelist.add(nc);
      //      }

      byte[] bytes = notelist.toByteArray();
      int byteSize = bytes.length;
      timelog("Resulting bytearray is " + bytes.length + " so we expect " + (bytes.length / (2500 * 24)) + " items");
      //      File file = File.createTempFile("foo", "bar");
      //      FileOutputStream fos = new FileOutputStream(file);
      //      fos.write(bytes);
      //      fos.close();

      storeTest.writeBinary("imdbNoteList", bytes, 2500 * 24);
      storeTest.save();
      String storeId = storeTest.getUniversalID();
      storeTest.recycle();
      storeTest = null;

      //      coll.recycle();
      //      coll = null;

      notecoll.recycle();
      notecoll = null;
      //      eventNotecoll.recycle();
      //      eventNotecoll = null;
      //      eventDb.recycle();
      //      eventDb = null;
      //      xspextNotecoll.recycle();
      //      xspextNotecoll = null;
      //      xspextDb.recycle();
      //      xspextDb = null;
      db.recycle();
      db = null;
      notelist = null;
      System.gc();

      timelog("Binary data serialized out. Reloading...");
      storeTest = log.getDocumentByUNID(storeId);
      //      FileInputStream fis = new FileInputStream(file);

      DbCache cache = new DbCache();
      NoteCoordinate.setDbCache(cache);
      NoteList notelist2 = new NoteList(cache, NoteList.getComparator("Title"));
      byte[] loaded = storeTest.readBinary("imdbNoteList");

      //      byte[] loaded = new byte[byteSize];
      //      fis.read(loaded);
      notelist2.loadByteArray(loaded);
      timelog("Done reloading " + notelist2.size() + " sorted notes. Iterating...");
      int notecount = 0;
      try {
        for (NoteCoordinate nc : notelist2) {
          Document doc = nc.getDocument();
          notecount++;
          //          System.out.println("doc " + doc.getNoteID() + " " + doc.getItemValue("$UpdatedBy", String.class));
        }
      } catch (Exception e) {
        e.printStackTrace();
      }
      timelog("iterated over " + notecount + " notes out of " + notelist2.size());
      long endTime = System.nanoTime();
    } catch (Throwable t) {
      t.printStackTrace();
    }
    long testEndTime = System.nanoTime();
View Full Code Here


  @Override
  public void addInEdge(final Edge edge) {
    boolean adding = false;
    String label = edge.getLabel();
    NoteList ins = getInEdgesSet(label);
    if (!ins.contains(edge.getId())) {
      adding = true;
      if (edge.getId() instanceof NoteCoordinate) {
        ins.add((NoteCoordinate) edge.getId());
      } else {
        //TODO
        //        ins.add((String) edge.getId());
      }
    }
View Full Code Here

  @Override
  public void addOutEdge(final Edge edge) {
    boolean adding = false;
    String label = edge.getLabel();
    NoteList outs = getOutEdgesSet(label);
    if (!outs.contains(edge.getId())) {
      adding = true;
      if (edge.getId() instanceof NoteCoordinate) {
        outs.add((NoteCoordinate) edge.getId());
      } else {
        //TODO
        //        outs.add((String) edge.getId());
      }
    }
View Full Code Here

  protected void removeEdge(final Edge edge) {
    getParent().startTransaction(this);
    String label = edge.getLabel();

    boolean inChanged = false;
    NoteList ins = getInEdgesSet(label);
    if (ins != null) {
      inChanged = ins.remove(edge.getId());
    }
    if (inChanged) {
      List<Edge> inObjs = getInEdgeCache(label);
      inObjs.remove(edge);
      getInDirtyKeySet().add(label);
    }

    boolean outChanged = false;
    NoteList outs = getOutEdgesSet(label);
    if (outs != null) {
      outChanged = outs.remove(edge.getId());
    }
    if (outChanged) {
      List<Edge> outObjs = getOutEdgeCache(label);
      outObjs.remove(edge);
      getOutDirtyKeySet().add(label);
View Full Code Here

    return outEdgeCache_;
  }

  @Override
  public int getInEdgeCount(final String label) {
    NoteList edgeIds = getInEdgesMap().get(label);
    if (edgeIds == null) {
      return getProperty("_COUNT" + DominoVertex.IN_PREFIX + label, Integer.class, false);
    } else {
      return edgeIds.size();
    }
  }
View Full Code Here

    }
  }

  @SuppressWarnings("unchecked")
  NoteList getInEdgesSet(final String label) {
    NoteList edgeIds = getInEdgesMap().get(label);
    if (edgeIds == null) {
      Object o = getProperty(DominoVertex.IN_PREFIX + label, java.util.Collection.class);
      if (o != null) {
        if (o instanceof NoteList) {
          edgeIds = ((NoteList) o);
        } else if (o instanceof java.util.Collection) {
          NoteList result = new NoteList(true);
          for (Object raw : (Collection) o) {
            if (raw instanceof String) {
              result.add(new NoteCoordinate(""/*TODO NTF This should be some default replid*/, (String) raw));
            } else {
              //TODO NTF
            }
          }
          edgeIds = result;
        } 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.");
          edgeIds = new NoteList(true);
        }
      } else {
        edgeIds = new NoteList(true);
      }
      Map map = getInEdgesMap();
      map.put(label, edgeIds);
    }
    return edgeIds;
View Full Code Here

    return edgeIds;
  }

  @Override
  public int getOutEdgeCount(final String label) {
    NoteList edgeIds = getOutEdgesMap().get(label);
    if (edgeIds == null) {
      return getProperty("_COUNT" + DominoVertex.OUT_PREFIX + label, Integer.class, false);
    } else {
      return edgeIds.size();
    }
  }
View Full Code Here

      return edgeIds.size();
    }
  }

  NoteList getOutEdgesSet(final String label) {
    NoteList edgeIds = getOutEdgesMap().get(label);
    if (edgeIds == null) {
      Object o = getProperty(DominoVertex.OUT_PREFIX + label, java.util.Collection.class);
      if (o != null) {
        if (o instanceof NoteList) {
          edgeIds = ((NoteList) o);
        } else if (o instanceof java.util.Collection) {
          NoteList result = new NoteList(true);
          for (Object raw : (Collection) o) {
            if (raw instanceof String) {
              result.add(new NoteCoordinate(""/*TODO NTF This should be some default replid*/, (String) raw));
            } else {
              //TODO NTF
            }
          }
          edgeIds = result;
        } 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.");
          edgeIds = new NoteList(true);
        }
      } else {
        edgeIds = new NoteList(true);
      }
      Map map = getOutEdgesMap();
      map.put(label, edgeIds);
    }
    return edgeIds;
View Full Code Here

    FastSet<String> inDirtySet = getInDirtyKeySet();
    if (!inDirtySet.isEmpty()) {
      Iterator<String> it = inDirtySet.iterator();
      while (it.hasNext()) {
        String key = it.next();
        NoteList edgeIds = inMap.get(key);
        if (edgeIds != null) {
          setProperty(DominoVertex.IN_PREFIX + key, edgeIds);
          setProperty("_COUNT" + DominoVertex.IN_PREFIX + key, edgeIds.size());
          result = true;
        }
        it.remove();
      }
    }

    Map<String, NoteList> outMap = getOutEdgesMap();
    FastSet<String> outDirtySet = getOutDirtyKeySet();
    if (!outDirtySet.isEmpty()) {
      Iterator<String> it = outDirtySet.iterator();
      while (it.hasNext()) {
        String key = it.next();
        NoteList edgeIds = outMap.get(key);
        if (edgeIds != null) {
          setProperty(DominoVertex.OUT_PREFIX + key, edgeIds);
          setProperty("_COUNT" + DominoVertex.OUT_PREFIX + key, edgeIds.size());
          result = true;
        }
        it.remove();
      }
View Full Code Here

      }
    } else if (labels.length == 1) {
      String label = labels[0];
      result = inCache.get(label);
      if (result == null) {
        NoteList edgeIds = getInEdgesSet(label);
        FastTable<Edge> edges = getParent().getEdgesFromIds(edgeIds);
        if (edges != null) {
          result = edges.atomic();
        }
        inCache.put(label, result);
View Full Code Here

TOP

Related Classes of org.openntf.domino.big.impl.NoteList

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.