Examples of Sail


Examples of org.openrdf.sail.Sail

    public NativeStoreSailGraph(final String directory, final String tripleIndices) {
        super(createNativeStore(new File(directory), tripleIndices));
    }

    private static Sail createNativeStore(final File directory, final String tripleIndices) {
        Sail s = null == tripleIndices ? new NativeStore(directory) : new NativeStore(directory, tripleIndices);
        /*try {
            s.initialize();
        } catch (SailException e) {
            // FIXME: RuntimeExceptions are the root of all evil
            throw new RuntimeException(e);
View Full Code Here

Examples of org.openrdf.sail.Sail

        }
    }

    @Test
    public void testCodePlay() throws Exception {
        Sail sail = new GraphSail(new TinkerGraph());
        sail.initialize();
        try {
            SailConnection sc = sail.getConnection();
            try {
                sc.begin();
                ValueFactory vf = sail.getValueFactory();
                sc.addStatement(vf.createURI("http://tinkerpop.com#1"), vf.createURI("http://tinkerpop.com#knows"), vf.createURI("http://tinkerpop.com#3"), vf.createURI("http://tinkerpop.com"));
                sc.addStatement(vf.createURI("http://tinkerpop.com#1"), vf.createURI("http://tinkerpop.com#name"), vf.createLiteral("marko"), vf.createURI("http://tinkerpop.com"));
                sc.addStatement(vf.createURI("http://tinkerpop.com#3"), vf.createURI("http://tinkerpop.com#name"), vf.createLiteral("josh"), vf.createURI("http://tinkerpop.com"));
                CloseableIteration<? extends Statement, SailException> results = sc.getStatements(null, null, null, false);
                try {
                    System.out.println("get statements: ?s ?p ?o ?g");
                    while (results.hasNext()) {
                        System.out.println(results.next());
                    }
                } finally {
                    results.close();
                }

                System.out.println("\nget statements: http://tinkerpop.com#3 ?p ?o ?g");
                results = sc.getStatements(vf.createURI("http://tinkerpop.com#3"), null, null, false);
                try {
                    while (results.hasNext()) {
                        System.out.println(results.next());
                    }
                } finally {
                    results.close();
                }

                SPARQLParser parser = new SPARQLParser();
                CloseableIteration<? extends BindingSet, QueryEvaluationException> sparqlResults;
                String queryString = "SELECT ?x ?y WHERE { ?x <http://tinkerpop.com#knows> ?y }";
                ParsedQuery query = parser.parseQuery(queryString, "http://tinkerPop.com");

                System.out.println("\nSPARQL: " + queryString);
                sparqlResults = sc.evaluate(query.getTupleExpr(), query.getDataset(), new EmptyBindingSet(), false);
                try {
                    while (sparqlResults.hasNext()) {
                        System.out.println(sparqlResults.next());
                    }
                } finally {
                    sparqlResults.close();
                }

                Graph graph = ((GraphSail) sail).getBaseGraph();
                System.out.println();
                for (Vertex v : graph.getVertices()) {
                    System.out.println("------");
                    System.out.println(v);
                    for (String key : v.getPropertyKeys()) {
                        System.out.println(key + "=" + v.getProperty(key));
                    }
                }
                for (Edge e : graph.getEdges()) {
                    System.out.println("------");
                    System.out.println(e);
                    for (String key : e.getPropertyKeys()) {
                        System.out.println(key + "=" + e.getProperty(key));
                    }
                }
            } finally {
                sc.rollback();
                sc.close();
            }
        } finally {
            sail.shutDown();
        }
    }
View Full Code Here

Examples of org.openrdf.sail.Sail

*/
public class SailLoaderTest {
    @Test
    public void testAll() throws Exception {
        KeyIndexableGraph g = new TinkerGraph();
        Sail sail = new GraphSail(g);
        sail.initialize();
        try {
            SailLoader loader = new SailLoader(sail);

            File f = resourceToFile("graph-example-sail-test.trig");

            SailConnection sc = sail.getConnection();
            try {
                sc.begin();
                assertEquals(0, sc.size());

                loader.load(f);

                sc.rollback();

                assertEquals(29, sc.size());
            } finally {
                sc.close();
            }
        } finally {
            sail.shutDown();
        }
    }
View Full Code Here

Examples of org.openrdf.sail.Sail

  @Override
  protected Sail createSail()
    throws SailException
  {
    Sail sail = new PgSqlStore("sesame_test");
    sail.initialize();
    SailConnection conn = sail.getConnection();
    try {
      conn.clear();
      conn.clearNamespaces();
      conn.commit();
    } finally {
View Full Code Here

Examples of org.openrdf.sail.Sail

  @Override
  protected Sail createSail()
    throws SailException
  {
    Sail sail = new MySqlStore("sesame_test");
    sail.initialize();
    SailConnection conn = sail.getConnection();
    try {
      conn.clear();
      conn.clearNamespaces();
      conn.commit();
    } finally {
View Full Code Here

Examples of org.openrdf.sail.Sail

  {
    if (config instanceof SailRepositoryConfig) {
      SailRepositoryConfig sailRepConfig = (SailRepositoryConfig)config;

      try {
        Sail sail = createSailStack(sailRepConfig.getSailImplConfig());
        return new SailRepository(sail);
      }
      catch (SailConfigException e) {
        throw new RepositoryConfigException(e.getMessage(), e);
      }
View Full Code Here

Examples of org.openrdf.sail.Sail

  }

  private Sail createSailStack(SailImplConfig config)
    throws RepositoryConfigException, SailConfigException
  {
    Sail sail = createSail(config);

    if (config instanceof DelegatingSailImplConfig) {
      SailImplConfig delegateConfig = ((DelegatingSailImplConfig)config).getDelegate();
      if (delegateConfig != null) {
        addDelegate(delegateConfig, sail);
View Full Code Here

Examples of org.openrdf.sail.Sail

  }

  private void addDelegate(SailImplConfig config, Sail sail)
    throws RepositoryConfigException, SailConfigException
  {
    Sail delegateSail = createSailStack(config);

    try {
      ((StackableSail)sail).setBaseSail(delegateSail);
    }
    catch (ClassCastException e) {
View Full Code Here

Examples of org.openrdf.sail.Sail

public class MemInferencingTest extends TestCase {

  public static Test suite()
    throws SailException
  {
    Sail sailStack = new ForwardChainingRDFSInferencer(new MemoryStore());
    return InferencingTest.suite(sailStack);
  }
View Full Code Here

Examples of org.openrdf.sail.Sail

  @Override
  protected Sail createSail()
    throws SailException
  {
    Sail sail = new MemoryStore();
    sail.initialize();
    return sail;
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.