Package com.hp.hpl.jena.sdb

Examples of com.hp.hpl.jena.sdb.Store


       
       
        boolean explicitTransactions = false ;
        {
            SDBConnection sConn1 = SDBConnectionFactory.create(conn) ;
            Store store1 = StoreFactory.create(desc, sConn1) ;
           
            if ( explicitTransactions )
                store1.getConnection().getTransactionHandler().begin() ;
           
            Graph graph1 = SDBFactory.connectDefaultGraph(store1) ;
            graph1.getBulkUpdateHandler().removeAll() ;
            SSE.write(graph1) ; System.out.println();
            graph1.add(t1) ;
            SSE.write(graph1) ; System.out.println();
           
            // Look for temporary tables.
            TableUtils.hasTable(sConn1.getSqlConnection(), "#NNodeTriples", new String[0]) ;

            if ( explicitTransactions )
                store1.getConnection().getTransactionHandler().commit() ;
           
            //store1.close() ;
           
        }      
       
        // Mythically return conn to the pool.
        // Get from pool
        // i.e. same connection.  Make a store around it
       
        {
            SDBConnection sConn2 = SDBConnectionFactory.create(conn) ;
            Store store2 = StoreFactory.create(desc, sConn2) ;

            if ( explicitTransactions )
                store2.getConnection().getTransactionHandler().begin() ;
           
            Graph graph2 = SDBFactory.connectDefaultGraph(store2) ;
            graph2.add(t2) ;
            SSE.write(graph2) ; System.out.println();
           
            if ( explicitTransactions )
                store2.getConnection().getTransactionHandler().commit() ;

            store2.close() ;
        }
        System.exit(0) ;
    }
View Full Code Here


                SDBConnection sdbConn = SDBConnectionFactory.create(conn);         
                Model model = FileManager.get().loadModel("D.ttl");
               
                for (int i=0; i <= 150; i++)
                {
                    Store store = null;
                    try {
//                      System.out.println("RUN " + i);
                        System.out.println(". "+i);

                        // create store                
                        store = StoreFactory.create(desc, sdbConn);
       
                        // save model
                        Model m = SDBFactory.connectDefaultModel(store) ;              
                        m.begin();
                        m.removeAll();
                        m.add(model);
                        m.commit();

                    } catch (Exception e) {
                        System.out.println( "\nFailed on iteration " + i);
                        e.printStackTrace();
                        throw e;
                    } finally {
                        if (store != null) { store.close(); }
                    }
                }
            } finally {
                if (conn != null) {
                    conn.close();
View Full Code Here

   
    private static Store create(Model assem)
    {
        // Create a store and format
        Dataset ds = DatasetFactory.assemble(assem) ;
        Store store = ((DatasetStoreGraph)ds.asDatasetGraph()).getStore() ;
        store.getTableFormatter().create() ;
        return store ;
    }
View Full Code Here

            String dir = "testing/Assembler/" ;
            Model assem = FileManager.get().loadModel(dir+"graph-assembler.ttl") ;
            Resource xDft = assem.getResource("http://example/test#graphDft") ;
            Resource xNamed = assem.getResource("http://example/test#graphNamed") ;

            Store store = create(assem) ;

            Model model1 = (Model)Assembler.general.open(xDft) ;
            Model model2 = (Model)Assembler.general.open(xNamed) ;
           
            Resource s = model1.createResource() ;
            Property p = model1.createProperty("http://example/p") ;
            Literal o = model1.createLiteral("foo") ;
           
            model1.add(s,p,o) ;
            System.out.println(model1.contains(s, p, o)) ;
           
            System.out.println("----") ;
            model1.write(System.out, "TTL") ;
            System.out.println("----") ;
            model2.write(System.out, "TTL") ;
            System.out.println("----") ;
           
            model1.size() ;
           
            System.out.println("Size 1 : "+model1.size()) ;
            System.out.println("Size 2 : "+model2.size()) ;
           
//            System.out.println("model1:") ;
//            StmtIterator sIter1 = model1.listStatements() ;
//            for ( ; sIter1.hasNext() ; )
//                System.out.println(sIter1.next()) ;
//           
//            System.out.println("model2:") ;
//            StmtIterator sIter2 = model1.listStatements() ;
//            for ( ; sIter2.hasNext() ; )
//                System.out.println(sIter2.next()) ;
           
            System.out.println((model1.isIsomorphicWith(model2))) ;
            System.exit(0) ;
           
        }
        {
           
           
            //sdb.sdbconfig.main("--sdb=sdb.ttl", "--create") ;
            //sdb.sdbprint.main("--sdb=sdb.ttl", "select *  where { GRAPH<G> { ?s ?p ?o}} limit 5") ;
            sdb.sdbprint.main("--sdb=sdb.ttl", "--file=Q.rq") ;
            System.exit(0) ;
        }       
        {
            // Make sure the database is created but empty first.
            String modelName = "http://example/g1" ;
            Store store = SDBFactory.connectStore("sdb.ttl") ;
            // Update.

            Dataset dataset = SDBFactory.connectDataset(store);
            Model model = SDBFactory.connectNamedModel(store, modelName);
            FileManager.get().readModel(model, "D.ttl") ;
            Iterator<String> modelNameIterator = dataset.listNames();
            for ( ; modelNameIterator.hasNext() ; )
            {
                System.out.println("Model: "+modelNameIterator.next()) ;
            }
            System.out.println("1 -----") ;
            model.write(System.out, "N-TRIPLES") ;
            System.out.println("-----") ;
            model.removeAll() ;
            System.out.println("2 -----") ;
            model.write(System.out, "N-TRIPLES") ;
            System.out.println("-----") ;
            store.close() ;
           

            store = SDBFactory.connectStore("sdb.ttl") ;
            dataset = SDBFactory.connectDataset(store);
            modelNameIterator = dataset.listNames();
            for ( ; modelNameIterator.hasNext() ; )
            {
                System.out.println("Model: "+modelNameIterator.next()) ;
            }
            model = SDBFactory.connectNamedModel(store, modelName);
            System.out.println("3 -----") ;
            model.write(System.out, "N-TRIPLES") ;
            System.out.println("-----") ;
            System.exit(0) ;
        }
//        sdb.sdbtest.main("--sdb=sdb.ttl", "testing/manifest-sdb.ttl") ;
//        System.exit(0) ;
       
        //TestStores2Connections1.main(argv) ;
       
        runPrint("Q.rq") ; System.exit(0) ;

        {
            // SPARQL/Update
            Store store = SDBTestUtils.createInMemoryStore() ;
           
            GraphStore gs = SDBFactory.connectGraphStore(store) ;
            UpdateAction.readExecute("update.ru", gs) ;
           
            Iter<Node> iter = Iter.iter(gs.listGraphNodes()) ;
View Full Code Here

   
    public static void devEnsureProject()
    {
        // Hit ensureProject?
        // Constructors to read file and get a model.
        Store store = SDBFactory.connectStore("sdb.ttl") ;
        Model model = SDBFactory.connectDefaultModel(store) ;
        System.out.println(model.contains(null, null, (RDFNode)null)) ;
        System.exit(0) ;
    }
View Full Code Here

    }
   
   
    private static void runQuery(String queryFile)
    {
        Store store = SDBFactory.connectStore("sdb.ttl") ;
        Dataset ds = SDBFactory.connectDataset(store) ;
        DatasetGraph dsg = ds.asDatasetGraph() ;
        Iterator<?> iter = dsg.listGraphNodes() ;
        for ( ; iter.hasNext() ; )
        {
View Full Code Here

//        sdbconfig("--create") ;
//        sdbload("D.ttl") ;

        //sparql("--data="+DIR+"data.ttl","--query="+DIR+"struct-10.rq") ;
        //ARQ.getContext().setFalse(StageBasic.altMatcher) ;
        Store store = SDBFactory.connectStore("Store/sdb-hsqldb-mem.ttl") ;
        store.getTableFormatter().create() ;
        Model model = SDBFactory.connectDefaultModel(store) ;
        FileManager.get().readModel(model, "D.ttl") ;
        Query query = QueryFactory.read("Q.rq") ;
        QueryExecution qexec = QueryExecutionFactory.create(query, model) ;
        QueryExecUtils.executeQuery(query, qexec) ;
View Full Code Here

        InputStream in = System.in ;
        in = new FileInputStream("T.sse") ;
        Item x = SSE.parse(in) ;
        TransGraphNode tg = TransGraphNode.build(x) ;

        Store store = makeMemHash() ;
        TupleLoader loader = new TupleLoaderOneHash(store.getConnection()) ;

        // ---- Config
        String tableName = "classes" ;

        // ---- Load auxillary table
        String subColName = "sub" ;
        String superColName = "super" ;
        TableDesc tableDesc = new TableDesc(tableName, subColName, superColName) ;
        TupleTable tuples = new TupleTable(store, tableDesc) ;
       
        // ---- Create auxillary table
       
        String colType = store.getNodeTableDesc().getNodeRefTypeString() ;
        try {
            String sqlCreateStr =
                String.format("CREATE TABLE %s ( sub %s not null, super %s not null )",
                              tableName, colType, colType) ;
            store.getConnection().execUpdate(sqlCreateStr) ;
        } catch (SQLException ex) { throw new SDBExceptionSQL(ex) ; }
       
        loader.setTableDesc(tableDesc) ;
       
        loader.start() ;
        for (Pair<Node, Node> p : tg )
            loader.load(p.getLeft(), p.getRight()) ;
        loader.finish() ;
       
        // ---- Dump it.
        tuples.dump() ;
        store.close() ;
    }
View Full Code Here

    {
        JDBC.loadDriverHSQL();

        SDBConnection sdb = SDBFactory.createConnection(
                "jdbc:hsqldb:mem:aname", "sa", "");
        Store store = StoreFactory.create(sdb, LayoutType.LayoutTripleNodesHash, DatabaseType.HSQLDB) ;
        store.getTableFormatter().format();
        return store ;
    }
View Full Code Here

    /**
     * @param args
     * @throws SQLException
     */
    public static void main(String[] args) throws SQLException {
        Store store = StoreFactory.create("Store/sdb-hsqldb-mem.ttl");
        System.err.println("Formatted? " + formatted(store));
        store.getTableFormatter().create();
        System.err.println("Formatted? " + formatted(store));
    }
View Full Code Here

TOP

Related Classes of com.hp.hpl.jena.sdb.Store

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.