Package org.openrdf.sail.nativerdf

Examples of org.openrdf.sail.nativerdf.NativeStore


        File dir = new File("/tmp/twitlogic-stresstest-ns");
        if (dir.exists()) {
            deleteDirectory(dir);
        }

        Sail sail = new NativeStore(dir);
        sail.initialize();

        try {
            TweetStore store = new TweetStore(sail);
            store.initialize();
            try {
                TweetPersister p = new TweetPersister(store, null);

                stressTest(p, 1000);
            } finally {
                store.shutDown();
            }
        } finally {
            sail.shutDown();
        }
    }
View Full Code Here


        OutputStream os;

        String[] names = new String[]{"tweet", "screenName", "replyTo", "createdAt", "text"};

        File dir = new File("/tmp/sparqljdbc/nativestore");
        Sail sail = new NativeStore(dir);
        sail.initialize();
        try {
            Repository repo = new SailRepository(sail);
            RepositoryConnection rc = repo.getConnection();
            try {
                rc.begin();
                rc.clear();
                rc.commit();
                rc.begin();

                rc.add(new File("/tmp/twitlogic-dump.nq"), "", RDFFormat.NQUADS);
                rc.commit();
                rc.begin();

                ////////////////////////////////////////////////////////////////

                query = "PREFIX dc: <http://purl.org/dc/terms/>\n" +
                        "PREFIX sioc: <http://rdfs.org/sioc/ns#>\n" +
                        "SELECT DISTINCT ?tweet1 ?tweet2 ?time1 ?time2 WHERE {\n" +
                        "    ?tweet1 dc:created ?time1 .\n" +
                        "    ?tweet2 dc:created ?time2 .\n" +
                        "    ?tweet2 sioc:reply_of ?tweet1 .\n" +
                        "}";

                os = new FileOutputStream("/tmp/replies.csv");
                try {
                    doQuery(query, rc, new PrintStream(os), new CSVOutputter() {
                        public void output(final BindingSet b,
                                           final StringBuilder sb) {
                            sb.append(esc(((URI) b.getValue("tweet1")).getLocalName()));
                            sb.append(", ");
                            long l1 = ((Literal) b.getValue("time1")).calendarValue().toGregorianCalendar().getTime().getTime();
                            sb.append(esc("" + l1));

                            sb.append(", ");

                            sb.append(esc(((URI) b.getValue("tweet2")).getLocalName()));
                            sb.append(", ");
                            long l2 = ((Literal) b.getValue("time2")).calendarValue().toGregorianCalendar().getTime().getTime();
                            sb.append(esc("" + l2));
                        }
                    });
                } finally {
                    os.close();
                }

                ////////////////////////////////////////////////////////////////

                query = "PREFIX dc: <http://purl.org/dc/terms/>\n" +
                        "PREFIX sioc: <http://rdfs.org/sioc/ns#>\n" +
                        "SELECT DISTINCT ?tweet ?account ?replyTo ?createdAt ?text WHERE {\n" +
                        "    ?tweet dc:created ?createdAt .\n" +
                        "    ?tweet sioc:content ?text .\n" +
                        "    ?tweet sioc:has_creator ?account .\n" +
                        // "    ?account sioc:id ?screenName .\n" +
                        "    OPTIONAL { ?tweet sioc:reply_of ?replyTo . } .\n" +
                        "}";

                os = new FileOutputStream("/tmp/tweets.csv");
                try {
                    doQuery(query, rc, new PrintStream(os), new CSVOutputter() {
                        public void output(final BindingSet b,
                                           final StringBuilder sb) {
                            sb.append(esc(((URI) b.getValue("tweet")).getLocalName()));
                            sb.append(", ");
                            sb.append(esc(((URI) b.getValue("account")).getLocalName()));
                            //  sb.append(esc(((Literal) b.getValue("screenName")).getLabel()));
                            sb.append(", ");
                            Value v = b.getValue("replyTo");
                            if (null == v) {
                                sb.append("\"\"");
                            } else {
                                sb.append(esc(((URI) v).getLocalName()));
                            }
                            sb.append(", ");
                            sb.append(esc(((Literal) b.getValue("createdAt")).getLabel()));
                            sb.append(", ");
                            sb.append(esc(((Literal) b.getValue("text")).getLabel()));
                        }
                    });
                } finally {
                    os.close();
                }

                ////////////////////////////////////////////////////////////////

                query = "PREFIX sioc: <http://rdfs.org/sioc/ns#>\n" +
                        "PREFIX sioct: <http://rdfs.org/sioc/types#>\n" +
                        "SELECT DISTINCT ?tweet ?topic WHERE {\n" +
                        "    ?tweet a sioct:MicroblogPost .\n" +
                        "    ?tweet sioc:topic ?topic .\n" +
                        "}";

                os = new FileOutputStream("/tmp/tweet_topics.csv");
                try {
                    doQuery(query, rc, new PrintStream(os), new CSVOutputter() {
                        public void output(final BindingSet b,
                                           final StringBuilder sb) {
                            sb.append(esc(((URI) b.getValue("tweet")).getLocalName()));
                            sb.append(", ");
                            sb.append(esc(((URI) b.getValue("topic")).getLocalName()));
                        }
                    });
                } finally {
                    os.close();
                }

                ////////////////////////////////////////////////////////////////

                query = "PREFIX sioc: <http://rdfs.org/sioc/ns#>\n" +
                        "PREFIX sioct: <http://rdfs.org/sioc/types#>\n" +
                        "SELECT DISTINCT ?tweet ?url WHERE {\n" +
                        "    ?tweet a sioct:MicroblogPost .\n" +
                        "    ?tweet sioc:links_to ?url .\n" +
                        "}";

                os = new FileOutputStream("/tmp/tweet_links.csv");
                try {
                    doQuery(query, rc, new PrintStream(os), new CSVOutputter() {
                        public void output(final BindingSet b,
                                           final StringBuilder sb) {
                            sb.append(esc(((URI) b.getValue("tweet")).getLocalName()));
                            sb.append(", ");
                            sb.append(esc(((URI) b.getValue("url")).stringValue()));
                        }
                    });
                } finally {
                    os.close();
                }

                ////////////////////////////////////////////////////////////////

            } finally {
                rc.rollback();
                rc.close();
            }
        } finally {
            sail.shutDown();
        }
    }
View Full Code Here

        RippleProperties props = Ripple.getConfiguration();
        File dir = props.getFile(Ripple.NATIVESTORE_DIRECTORY);
        String indexes = props.getString(Ripple.NATIVESTORE_INDEXES, null);

        Sail sail = (null == indexes)
                ? new NativeStore(dir)
                : new NativeStore(dir, indexes.trim());
        try {
            sail.initialize();
        } catch (SailException e) {
            throw new RippleException(e);
        }
View Full Code Here

        recordManager = RecordManagerFactory.createRecordManager(dataDirectory.getAbsolutePath()+File.separator+"resource_cache.cache");

        cacheEntries = recordManager.treeMap("resources");

        try {
            Repository repository = new SailRepository(new NativeStore(tripleStore));
            repository.initialize();
            setRepository(repository);

        } catch (RepositoryException e) {
            log.error("error initialising connection to Sesame in-memory repository",e);
View Full Code Here

        }

        File tripleDir = new File(storageDir,"triples");

        try {
            cacheRepository = new SailRepository(new NativeStore(tripleDir, "spoc"));
            cacheRepository.initialize();
        } catch (RepositoryException ex) {
            log.error("could not initialize cache directory",ex);
        }
    }
View Full Code Here

TOP

Related Classes of org.openrdf.sail.nativerdf.NativeStore

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.