Search in sources :

Example 1 with NoteCoordinate

use of org.openntf.domino.big.impl.NoteCoordinate in project org.openntf.domino by OpenNTF.

the class NoteListTest method run1.

public void run1() {
    long testStartTime = System.nanoTime();
    Session session = this.getSession();
    Database log = session.getDatabase("", "log.nsf");
    Document storeTest = log.createDocument();
    storeTest.replaceItemValue("form", "BinaryTest");
    Database db = session.getDatabase("", "imdb/movies.nsf");
    try {
        marktime = System.nanoTime();
        NoteSet noteset = new NoteSet();
        timelog("Beginning first noteset...");
        NoteCollection notecoll2 = db.createNoteCollection(false);
        notecoll2.setSelectDocuments(true);
        notecoll2.setSelectionFormula("@Begins(Title; \"B\")");
        notecoll2.buildCollection();
        // DocumentCollection coll = db.search("@Begins(Title; \"B\")");
        timelog("Starting note coordinates of " + notecoll2.getCount() + " documents");
        // for (Document doc : notecoll) {
        for (String nid : notecoll2) {
            NoteCoordinate nc = new NoteCoordinate(notecoll2, nid);
            noteset.add(nc);
        }
        timelog("Done note coordinates of " + noteset.size() + " documents. Doing again...");
        int i = 0;
        for (String nid : notecoll2) {
            if (i++ < 10000) {
                NoteCoordinate nc = new NoteCoordinate(notecoll2, nid);
                noteset.add(nc);
            } else {
                break;
            }
        }
        timelog("Complete note coordinates of " + noteset.size() + " documents.");
        NoteList notelist = new NoteList();
        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);
        }
        timelog("Done note coordinates of " + notelist.size() + " documents. Doing again...");
        i = 0;
        for (String nid : notecoll) {
            if (i++ < 10000) {
                NoteCoordinate nc = new NoteCoordinate(notecoll, nid);
                notelist.add(nc);
            } else {
                break;
            }
        }
        timelog("Complete note coordinates of " + notelist.size() + " documents.");
        // 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;
        notelist = null;
        // timelog("Binary data serialized out. Reloading...");
        db.recycle();
        db = null;
        System.gc();
        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();
    System.out.println("Completed " + getClass().getSimpleName() + " run in " + ((testEndTime - testStartTime) / 1000000) + " ms");
}
Also used : NoteCoordinate(org.openntf.domino.big.impl.NoteCoordinate) NoteSet(org.openntf.domino.big.impl.NoteSet) NoteCollection(org.openntf.domino.NoteCollection) NoteList(org.openntf.domino.big.impl.NoteList) Database(org.openntf.domino.Database) Document(org.openntf.domino.Document) Session(org.openntf.domino.Session)

Example 2 with NoteCoordinate

use of org.openntf.domino.big.impl.NoteCoordinate in project org.openntf.domino by OpenNTF.

the class JsonGraphWriter method outLiteral.

@Override
protected void outLiteral(Object paramObject, final boolean paramBoolean) throws IOException, JsonException {
    // paramObject.getClass().getName()));
    if (paramObject != null) {
        Class<?> objClass = paramObject.getClass();
        IJsonWriterAdapter adapter = factory_.getJsonWriterAdapter(objClass);
        if (adapter != null) {
            paramObject = adapter.toJson(paramObject);
        }
    }
    if (this.getFactory().isNull(paramObject)) {
        outNull();
    // } else if (paramObject instanceof Term) {
    // JsonSearchAdapter adapter = new JsonSearchAdapter(graph_, (Term) paramObject, parameters_,
    // isCollectionRoute_);
    // super.outObject(adapter);
    // } else if (paramObject instanceof Value) {
    // JsonSearchAdapter adapter = new JsonSearchAdapter(graph_, (Value) paramObject, parameters_,
    // isCollectionRoute_);
    // super.outObject(adapter);
    // } else if (paramObject instanceof RichTextReference) {
    // JsonSearchAdapter adapter = new JsonSearchAdapter(graph_, (RichTextReference) paramObject, parameters_,
    // isCollectionRoute_);
    // super.outObject(adapter);
    } else if (paramObject instanceof VertexFrame) {
        JsonFrameAdapter adapter = new JsonFrameAdapter(graph_, (VertexFrame) paramObject, parameters_, isCollectionRoute_);
        outObject(adapter);
    } else if (paramObject instanceof EdgeFrame) {
        JsonFrameAdapter adapter = new JsonFrameAdapter(graph_, (EdgeFrame) paramObject, parameters_, isCollectionRoute_);
        outObject(adapter);
    } else if (paramObject instanceof Class<?>) {
        String className = ((Class) paramObject).getName();
        outStringLiteral(className);
    } else if (paramObject instanceof RichTextItem) {
        outRichTextItem((RichTextItem) paramObject);
    } else if (paramObject instanceof Enum) {
        String className = ((Enum) paramObject).getClass().getName();
        String enumName = ((Enum) paramObject).name();
        outStringLiteral(className + " " + enumName);
    } else if (paramObject instanceof CharSequence) {
        outStringLiteral(paramObject.toString());
    } else if (paramObject instanceof Set) {
        // System.out.println("TEMP DEBUG Got a set!");
        outArrayLiteral(((Set) paramObject).toArray());
    } else if (this.getFactory().isString(paramObject)) {
        outStringLiteral(this.getFactory().getString(paramObject));
    } else if (this.getFactory().isNumber(paramObject)) {
        outNumberLiteral(this.getFactory().getNumber(paramObject));
    } else if (this.getFactory().isBoolean(paramObject)) {
        outBooleanLiteral(this.getFactory().getBoolean(paramObject));
    } else if (this.getFactory().isObject(paramObject)) {
        outObject(paramObject, paramBoolean);
    } else if (this.getFactory().isArray(paramObject)) {
        outArrayLiteral(paramObject, paramBoolean);
    } else if (paramObject instanceof JsonReference) {
        outReference((JsonReference) paramObject);
    } else if (paramObject instanceof DateTime) {
        DateTime dt = (DateTime) paramObject;
        outDateLiteral_(dt.toJavaDate());
    } else if (paramObject instanceof DateRange) {
        DateRange dt = (DateRange) paramObject;
        outDateRangeLiteral(dt);
    } else if (paramObject instanceof NoteCoordinate) {
        outNoteCoordinate((NoteCoordinate) paramObject);
    } else if (paramObject instanceof Date) {
        outDateLiteral_((Date) paramObject);
    } else {
        outStringLiteral("JsonGenerator cannot process unknown type of " + ((paramObject != null) ? paramObject.getClass().getName() : "<null>"));
    }
}
Also used : NoteCoordinate(org.openntf.domino.big.impl.NoteCoordinate) EdgeFrame(com.tinkerpop.frames.EdgeFrame) Set(java.util.Set) JsonFrameAdapter(org.openntf.domino.rest.resources.frames.JsonFrameAdapter) IJsonWriterAdapter(org.openntf.domino.rest.json.JsonGraphFactory.IJsonWriterAdapter) DateTime(org.openntf.domino.DateTime) Date(java.util.Date) JsonReference(com.ibm.commons.util.io.json.JsonReference) DateRange(org.openntf.domino.DateRange) VertexFrame(com.tinkerpop.frames.VertexFrame) RichTextItem(org.openntf.domino.RichTextItem)

Example 3 with NoteCoordinate

use of org.openntf.domino.big.impl.NoteCoordinate in project org.openntf.domino by OpenNTF.

the class JsonGraphWriter method outObject.

@Override
public void outObject(Object paramObject) throws IOException, JsonException {
    // + (paramObject == null ? "NULL" : paramObject.getClass().getName()));
    try {
        if (paramObject != null) {
            Class<?> objClass = paramObject.getClass();
            IJsonWriterAdapter adapter = factory_.getJsonWriterAdapter(objClass);
            if (adapter != null) {
                paramObject = adapter.toJson(paramObject);
            }
        }
        if (paramObject == null) {
            super.outNull();
        // } else if (paramObject instanceof Term) {
        // JsonSearchAdapter adapter = new JsonSearchAdapter(graph_, (Term) paramObject, parameters_,
        // isCollectionRoute_);
        // super.outObject(adapter);
        // } else if (paramObject instanceof Value) {
        // JsonSearchAdapter adapter = new JsonSearchAdapter(graph_, (Value) paramObject, parameters_,
        // isCollectionRoute_);
        // super.outObject(adapter);
        // } else if (paramObject instanceof RichTextReference) {
        // JsonSearchAdapter adapter = new JsonSearchAdapter(graph_, (RichTextReference) paramObject, parameters_,
        // isCollectionRoute_);
        // super.outObject(adapter);
        } else if (paramObject instanceof EdgeFrame) {
            JsonFrameAdapter adapter = new JsonFrameAdapter(graph_, (EdgeFrame) paramObject, parameters_, isCollectionRoute_);
            super.outObject(adapter);
        } else if (paramObject instanceof VertexFrame) {
            JsonFrameAdapter adapter = new JsonFrameAdapter(graph_, (VertexFrame) paramObject, parameters_, isCollectionRoute_);
            super.outObject(adapter);
        } else if (paramObject instanceof Class<?>) {
            String className = ((Class<?>) paramObject).getName();
            super.outStringLiteral(className);
        } else if (paramObject instanceof RichTextItem) {
            outRichTextItem((RichTextItem) paramObject);
        } else if (paramObject instanceof Enum) {
            String className = ((Enum<?>) paramObject).getClass().getName();
            String enumName = ((Enum<?>) paramObject).name();
        } else if (paramObject instanceof NoteCoordinate) {
            String nc = ((NoteCoordinate) paramObject).toString();
            super.outStringLiteral(nc);
        } else if (paramObject instanceof org.openntf.domino.impl.View.DominoColumnInfo) {
            String itemName = ((org.openntf.domino.impl.View.DominoColumnInfo) paramObject).getItemName();
            super.outStringLiteral(itemName);
        } else if (paramObject instanceof Set) {
            // System.out.println("TEMP DEBUG outObject received a Set");
            outArrayLiteral(((Set) paramObject).toArray());
        } else if (paramObject instanceof DateTime) {
            outDateLiteral((DateTime) paramObject);
        } else if (paramObject instanceof DateRange) {
            outDateRangeLiteral((DateRange) paramObject);
        } else if (paramObject instanceof NoteCoordinate) {
            outNoteCoordinate((NoteCoordinate) paramObject);
        } else if (paramObject instanceof Throwable) {
            outException((Throwable) paramObject);
        } else {
            // Class<?> clazz = paramObject.getClass();
            // String name = clazz.getName();
            super.outObject(paramObject);
        }
    } catch (UserAccessException uae) {
        throw uae;
    } catch (RuntimeException re) {
        throw re;
    } catch (Throwable t) {
        t.printStackTrace();
    }
}
Also used : NoteCoordinate(org.openntf.domino.big.impl.NoteCoordinate) EdgeFrame(com.tinkerpop.frames.EdgeFrame) Set(java.util.Set) JsonFrameAdapter(org.openntf.domino.rest.resources.frames.JsonFrameAdapter) IJsonWriterAdapter(org.openntf.domino.rest.json.JsonGraphFactory.IJsonWriterAdapter) UserAccessException(org.openntf.domino.exceptions.UserAccessException) DateTime(org.openntf.domino.DateTime) DateRange(org.openntf.domino.DateRange) VertexFrame(com.tinkerpop.frames.VertexFrame) RichTextItem(org.openntf.domino.RichTextItem)

Aggregations

NoteCoordinate (org.openntf.domino.big.impl.NoteCoordinate)3 EdgeFrame (com.tinkerpop.frames.EdgeFrame)2 VertexFrame (com.tinkerpop.frames.VertexFrame)2 Set (java.util.Set)2 DateRange (org.openntf.domino.DateRange)2 DateTime (org.openntf.domino.DateTime)2 RichTextItem (org.openntf.domino.RichTextItem)2 IJsonWriterAdapter (org.openntf.domino.rest.json.JsonGraphFactory.IJsonWriterAdapter)2 JsonFrameAdapter (org.openntf.domino.rest.resources.frames.JsonFrameAdapter)2 JsonReference (com.ibm.commons.util.io.json.JsonReference)1 Date (java.util.Date)1 Database (org.openntf.domino.Database)1 Document (org.openntf.domino.Document)1 NoteCollection (org.openntf.domino.NoteCollection)1 Session (org.openntf.domino.Session)1 NoteList (org.openntf.domino.big.impl.NoteList)1 NoteSet (org.openntf.domino.big.impl.NoteSet)1 UserAccessException (org.openntf.domino.exceptions.UserAccessException)1