Package xbird.xquery.dm.dtm

Examples of xbird.xquery.dm.dtm.IDocumentTable


        DbCollection xmark = DbCollection.getRootCollection().createCollection(COL_NAME);
        assert (xmark.getDirectory().exists());
        final DocumentTableModel dtm = new DocumentTableModel(false);
        File file = new File(TEST_FILE);
        dtm.loadDocument(new FileInputStream(file));
        IDocumentTable doc = dtm.getDocumentTable();
        //DbCollection coll = new DbCollection(true);
        xmark.putDocument(new Transaction(), file.getName(), doc);
        System.err.println(sw);
    }
View Full Code Here


    public void xtestPutDocumentPageOut() throws XQueryException, DbException,
            FileNotFoundException {
        DbCollection xmark = DbCollection.getRootCollection().createCollection(COL_NAME);
        assert (xmark.getDirectory().exists());
        File file = new File(TEST_FILE);
        IDocumentTable doc = new DocumentTable.PersistentDocumentTable(xmark, FileUtils.getFileName(file));
        final DocumentTableModel dtm = new DocumentTableModel(doc);
        dtm.loadDocument(new FileInputStream(file));
        xmark.putDocument(new Transaction(), file.getName(), doc);
    }
View Full Code Here

    public void xtestPutDocumentBig() throws XQueryException, DbException, FileNotFoundException {
        DbCollection xmark = DbCollection.getRootCollection().createCollection(COL_NAME);
        assert (xmark.getDirectory().exists());
        File file = new File(TEST_FILE);
        IDocumentTable doc = new BigDocumentTable();
        final DocumentTableModel dtm = new DocumentTableModel(doc);
        dtm.loadDocument(new FileInputStream(file));
        xmark.putDocument(new Transaction(), file.getName(), doc);
    }
View Full Code Here

            FileNotFoundException {
        StopWatch sw = new StopWatch("testPutDocumentPageOutBig");
        DbCollection xmark = DbCollection.getRootCollection().createCollection(COL_NAME);
        assert (xmark.getDirectory().exists());
        File file = new File(TEST_FILE);
        IDocumentTable doc = new BigDocumentTable.PersistentBigDocumentTable(xmark, FileUtils.getFileName(file));
        final DocumentTableModel dtm = new DocumentTableModel(doc);
        dtm.loadDocument(new FileInputStream(file));
        xmark.putDocument(new Transaction(), file.getName(), doc);
        System.err.println(sw);
    }
View Full Code Here

            XQueryException {
        Map<String, DTMDocument> map = col.listDocuments(DynamicContext.DUMMY);
        for(Map.Entry<String, DTMDocument> entry : map.entrySet()) {
            String docName = entry.getKey();
            DTMDocument doc = entry.getValue();
            IDocumentTable doctbl = doc.documentTable();
            DocumentTableModel dtm = doc.getDataModel();
            PropertyMap props = col.getCollectionProperties();
            LabelingHandler handler = new LabelingHandler(doctbl, col, docName, props);
            dtm.export(0L, handler);
            doctbl.close();
        }
        return true;
    }
View Full Code Here

    }

    public static IDocumentTable loadDocument(DbCollection col, File docFile)
            throws FileNotFoundException, XQueryException, DbException {
        long fileSize = docFile.length();
        IDocumentTable doc = preferedDocumentTable(col, docFile, fileSize);
        DocumentTableModel dtm = new DocumentTableModel(doc);
        dtm.loadDocument(new FileInputStream(docFile));
        col.putDocument(new Transaction(), docFile.getName(), doc);
        return doc;
    }
View Full Code Here

    }

    private V _put(String docName, V value) {
        V prev = _remove(docName);

        IDocumentTable doc = new DocumentTable(collection, docName);

        // cache the document
        String docid = collection.getAbsolutePath() + File.separatorChar + docName;
        DocumentTableLoader.putDocumentIfAbsent(docid, doc);
View Full Code Here

        }
    }

    public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
        this._docid = in.readInt();
        final IDocumentTable doctbl = (IDocumentTable) in.readObject();
        if(doctbl instanceof MemoryMappedDocumentTable) {
            this._mmapedStore = true;
            MemoryMappedDocumentTable mmDoctbl = (MemoryMappedDocumentTable) doctbl;
            String docId = mmDoctbl.getDocumentIdentifer();
            if(docId != null) {
View Full Code Here

        Strategy origStrategy = null;
        if(profile != null) {
            origStrategy = profile.getStrategy();
            profile.setStrategy(Strategy.serialization);
        }
        final IDocumentTable doctbl = _store;
        doctbl.ensureOpen();
        switch(doctbl.getNodeKindAt(nodeid)) {
            case NodeKind.DOCUMENT:
                receiver.evStartDocument();
                final long firstChild = doctbl.firstChild(nodeid);
                if(firstChild != -1L) {
                    export(firstChild, receiver);
                    long nextSib = doctbl.nextSibling(firstChild);
                    while(nextSib != 0L) {
                        export(nextSib, receiver);
                        nextSib = doctbl.nextSibling(firstChild);
                    }
                }
                receiver.evEndDocument();
                break;
            case NodeKind.ELEMENT:
                final QualifiedName qname = doctbl.getName(nodeid);
                receiver.evStartElement(nodeid, qname);
                // namespace decl
                final int nsdeclCnt = doctbl.getNamespaceCountAt(nodeid);
                for(int i = 0; i < nsdeclCnt; i++) {
                    final long nsid = doctbl.getNamespaceDecl(nodeid, i);
                    final QualifiedName nsName = doctbl.getAttributeName(nsid);
                    final String uri = doctbl.getText(nsid);
                    receiver.evNamespace(nsid, nsName, uri);
                }
                // attribute
                final int attrCnt = doctbl.getAttributeCountAt(nodeid);
                for(int i = 0; i < attrCnt; i++) {
                    final long attid = doctbl.getAttribute(nodeid, i);
                    final QualifiedName attName = doctbl.getAttributeName(attid);
                    final String attValue = doctbl.getText(attid);
                    receiver.evAttribute(attid, attName, attValue);
                }
                final long elemFirstChild = doctbl.firstChild(nodeid);
                if(elemFirstChild != -1L) {
                    export(elemFirstChild, receiver);
                    long nextSib = doctbl.nextSibling(elemFirstChild);
                    while(nextSib != 0L) {
                        export(nextSib, receiver);
                        nextSib = doctbl.nextSibling(nextSib);
                    }
                }
                receiver.evEndElement(nodeid, qname);
                break;
            case NodeKind.ATTRIBUTE:
                receiver.evAttribute(nodeid, doctbl.getAttributeName(nodeid), doctbl.getText(nodeid));
                break;
            case NodeKind.NAMESPACE:
                receiver.evNamespace(nodeid, doctbl.getAttributeName(nodeid), doctbl.getText(nodeid));
                break;
            case NodeKind.TEXT:
                receiver.evText(nodeid, doctbl.getText(nodeid));
                break;
            case NodeKind.COMMENT:
                receiver.evComment(nodeid, doctbl.getText(nodeid));
                break;
            case NodeKind.PROCESSING_INSTRUCTION:
                final QualifiedName pi = doctbl.getName(nodeid);
                receiver.evProcessingInstruction(nodeid, pi.getLocalPart(), pi.getNamespaceURI());
                break;
            default:
                throw new IllegalStateException("Invalid node kind '"
                        + NodeKind.resolveName(doctbl.getNodeKindAt(nodeid)) + "' for node#"
                        + nodeid);
        }
        if(profile != null) {
            profile.setStrategy(origStrategy);
        }
View Full Code Here

        public byte nodeKind() {
            return 0;
        }

        public DTMNodeBase nextSibling() {
            final IDocumentTable store = documentTable();
            final long nextsib = store.nextSibling(_id);
            if(nextsib == 0L) {
                return null;
            }
            final DocumentTableModel model = getDataModel();
            return model.createNode(store.getNodeKindAt(nextsib), nextsib);
        }
View Full Code Here

TOP

Related Classes of xbird.xquery.dm.dtm.IDocumentTable

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.