Package com.hp.hpl.jena.query

Examples of com.hp.hpl.jena.query.Dataset


        assertFalse(ds.isInTransaction()) ;
    }

    @Test public void factoryTxn5()
    {
        Dataset ds = create() ;
        ds.begin(ReadWrite.WRITE) ;
        assertTrue(ds.isInTransaction()) ;
        ds.abort() ;
        assertFalse(ds.isInTransaction()) ;
        ds.end() ;
        assertFalse(ds.isInTransaction()) ;
    }
View Full Code Here


   
    private void createTest(String filename, Resource type)
    {
        Object thing = AssemblerUtils.build(filename, type) ;
        assertTrue(thing instanceof Dataset) ;
        Dataset ds = (Dataset)thing ;
        assertTrue(ds.asDatasetGraph() instanceof DatasetGraphTransaction) ;
        assertTrue(ds.supportsTransactions()) ;
        ds.close();
       
    }
View Full Code Here

      graphLocation.clearDirectory() // Does nto have the desired effect on Windows.
    }
   
    @Test public void dataset1()
    {
        Dataset ds = graphLocation.getDataset() ;
        //assertTrue( ds.asDatasetGraph() instanceof DatasetGraphTDB ) ;
        assertTrue( ds.getDefaultModel().getGraph() instanceof GraphTriplesTDB ) ;
        assertTrue( ds.getNamedModel("http://example/").getGraph() instanceof GraphNamedTDB ) ;
    }
View Full Code Here

        assertTrue( ds.getNamedModel("http://example/").getGraph() instanceof GraphNamedTDB ) ;
    }
   
    @Test public void dataset2()
    {
        Dataset ds = graphLocation.getDataset() ;
        Graph g1 = ds.getDefaultModel().getGraph() ;
        Graph g2 = ds.getNamedModel("http://example/").getGraph() ;
       
        g1.add(new Triple(n0,n1,n2) ) ;
        assertTrue(g1.contains(n0,n1,n2) ) ;
        assertFalse(g2.contains(n0,n1,n2) ) ;
    }
View Full Code Here

        assertFalse(g2.contains(n0,n1,n2) ) ;
    }

    @Test public void dataset3()
    {
        Dataset ds = graphLocation.getDataset() ;
        Graph g1 = ds.getDefaultModel().getGraph() ;
        // Sometimes, under windows, deleting the files by
        // graphLocation.clearDirectory does not work. 
        // Needed for safe tests on windows.
        g1.getBulkUpdateHandler().removeAll() ;
       
        Graph g2 = ds.getNamedModel("http://example/").getGraph() ;
        g2.add(new Triple(n0,n1,n2) ) ;
        assertTrue(g2.contains(n0,n1,n2) ) ;
        assertFalse(g1.contains(n0,n1,n2) ) ;
    }
View Full Code Here

    {
        String graphName = "http://example/" ;
        Triple triple = SSE.parseTriple("(<x> <y> <z>)") ;
        Node gn = Node.createURI(graphName) ;

        Dataset ds = graphLocation.getDataset() ;
        // ?? See TupleLib.
        ds.asDatasetGraph().deleteAny(gn, null, null, null) ;
       
        Graph g2 = ds.asDatasetGraph().getGraph(gn) ;
       
//        if ( true )
//        {
//            PrintStream ps = System.err ;
//            ps.println("Dataset names: ") ;
//            Iter.print(ps, ds.listNames()) ;
//        }
       
        // Graphs only exists if they have a triple in them
        assertFalse(ds.containsNamedModel(graphName)) ;
       
        List<String> names = Iter.toList(ds.listNames()) ;
        assertEquals(0, names.size()) ;
        assertEquals(0, ds.asDatasetGraph().size()) ;
    }
View Full Code Here

   
    @Test public void dataset5()
    {
        String graphName = "http://example/" ;
        Triple triple = SSE.parseTriple("(<x> <y> <z>)") ;
        Dataset ds = graphLocation.getDataset() ;
        Graph g2 = ds.asDatasetGraph().getGraph(Node.createURI(graphName)) ;
        // Graphs only exists if they have a triple in them
        g2.add(triple) ;
       
        assertTrue(ds.containsNamedModel(graphName)) ;
        List<String> x = Iter.toList(ds.listNames()) ;
        List<String> y = Arrays.asList(graphName) ;
        assertEquals(x,y) ;
       
        assertEquals(1, ds.asDatasetGraph().size()) ;
    }
View Full Code Here

        // This assumes you have two datasets on the same location.
        // That's not necessarily true for uncached memory datasets,
        // where you get two separate datasets so changes to one are
        // not seen by the other at all.
       
        Dataset ds1 = create() ;
        Dataset ds2 = create() ;
       
        ds1.begin(ReadWrite.WRITE) ;
        ds1.getDefaultModel().getGraph().add(triple1) ;
       
        ds2.begin(ReadWrite.READ) ;
        assertTrue(ds2.getDefaultModel().isEmpty()) ;
        ds2.commit() ;
       
        ds1.commit() ;

        ds2.begin(ReadWrite.READ) ;
        assertFalse(ds2.getDefaultModel().isEmpty()) ;
        assertEquals(1, ds2.getDefaultModel().size()) ;
        ds2.commit() ;
    }
View Full Code Here

    //String baseGraphName = "com.ibm.test.graphNamePrefix.";  

    long totalExecTime = 0L;
    long size = 0;
    Dataset dataset = TDBFactory.createDataset(location);
   
    Dataset dataset1 = TDBFactory.createDataset(location);
   
    if ( bracketWithReader )
        dataset1.begin(ReadWrite.READ) ;
   
    for (int i = 0; i < TOTAL; i++) {
      List<String> lastProcessedUris = new ArrayList<String>();
      for (int j = 0; j < 10*i; j++) {
        String lastProcessedUri = "http://test.net/xmlns/test/1.0/someUri" + j;
        lastProcessedUris.add(lastProcessedUri);
      }
      //Dataset dataset = TDBFactory.createDataset(location);
      //String graphName = baseGraphName + i;
      long t = System.currentTimeMillis();

      try {
        dataset.begin(ReadWrite.WRITE);
        Model m = dataset.getDefaultModel();

        m.removeAll();
        Resource subject = m.createResource(INDEX_INFO_SUBJECT);
        Property predicate = m.createProperty(TIMESTAMP_PREDICATE);
        m.addLiteral(subject, predicate, System.currentTimeMillis());
        predicate = m.createProperty(URI_PREDICATE);
        for (String uri : lastProcessedUris) {
          m.add(subject, predicate, m.createResource(uri));
        }
        predicate = m.createProperty(VERSION_PREDICATE);
        m.addLiteral(subject, predicate, 1.0);

        size += m.size() + 1;

        predicate = m.createProperty(INDEX_SIZE_PREDICATE);
        m.addLiteral(subject, predicate, size);

        dataset.commit();
      } catch (Throwable e) {
        dataset.abort();
        throw new RuntimeException(e);
      } finally {
        dataset.end();
        long writeOperationDuration = System.currentTimeMillis() - t;
        totalExecTime += writeOperationDuration;
        System.out.println("Write operation " + i + " took " + writeOperationDuration + "ms");
      }
    }
        if ( bracketWithReader )
            dataset1.end() ;

    System.out.println("All " + TOTAL + " write operations wrote " + size + " triples and took " + totalExecTime + "ms");
  }
View Full Code Here

        }
       
        if (file == null)
            throw new CmdException("No dataset specified") ;
        // Assumes a single test dataset description in the assembler file.
        Dataset ds = TextDatasetFactory.create(file) ;
        if (ds == null)
            throw new CmdException("No dataset description found") ;
        // get index.
        dataset = (DatasetGraphText)(ds.asDatasetGraph()) ;
        textIndex = dataset.getTextIndex() ;
        if (textIndex == null)
            throw new CmdException("Dataset has no text index") ;
        entityDefinition = textIndex.getDocDef() ;
    }
View Full Code Here

TOP

Related Classes of com.hp.hpl.jena.query.Dataset

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.