Package org.openrdf.sail

Examples of org.openrdf.sail.Sail


        RepositorySail sail = new RepositorySail(repo);
        sail.disableInference();

        if (enableLogging) {
            File logFile = new File("/tmp/twitlogic-ag-sail.log");
            Sail recorderSail;
            try {
                recorderSail = new RecorderSail(sail, new FileOutputStream(logFile));
            } catch (FileNotFoundException e) {
                throw new SailException(e);
            }
View Full Code Here


    }

    public Sail makeSail() throws SailException, PropertyException {
        LOGGER.info("instantiating MemoryStore");

        Sail sail = new MemoryStore();
        sail.initialize();
        return sail;
    }
View Full Code Here

        File dir = conf.getFile(TwitLogic.NEO4J_DIRECTORY);

        LOGGER.info("instantiating GraphSail-on-Neo4j in directory: " + dir);
        Neo4jGraph graph = new Neo4jGraph(dir.getAbsolutePath());
        //graph.setMaxBufferSize(1);
        Sail sail = new GraphSail(graph);
        sail.initialize();

        File dump = conf.getFile("dump", null);
        if (null != dump) {
            LOGGER.info("loading from dump file: " + dump);

            try {
                SailConnection sc = sail.getConnection();
                try {
                    sc.begin();
                    RDFParser parser = Rio.createParser(RDFFormat.NQUADS);
                    parser.setRDFHandler(new StatementAdder(sc));
                    InputStream is = new FileInputStream(dump);
View Full Code Here

        String portsStr = config.getString(TwitLogic.UDP_REMOTEPORTS);
        int[] ports = parsePorts(portsStr);

        InetAddress address = InetAddress.getByName(host);

        Sail workingSail = new MemoryStore();
        workingSail.initialize();

        try {
            Sail streamingSail = new UdpTransactionSail(workingSail, address, ports);

            try {
                TweetStore store = new TweetStore(streamingSail);
                store.doNotRefreshCoreMetadata();
                store.initialize();

                try {
                    // A connection with which to repeatedly clear the working store
                    final SailConnection c = workingSail.getConnection();

                    try {
                        c.begin();

                        // Offline persister
                        final TweetPersister persister = new TweetPersister(store, null);

                        try {
                            CustomTwitterClient client = new CustomTwitterClient();

                            // Note: this is only for serving local files.
                            store.startServer(client);

                            TweetPersistedLogger pLogger = new TweetPersistedLogger(client.getStatistics(), persister);
                            TweetFilterCriterion crit = new TweetFilterCriterion(TwitLogic.getConfiguration());
                            Filter<Tweet> f = new Filter<Tweet>(crit, pLogger);

                            // Add a "topic sniffer".
                            TopicSniffer topicSniffer = new TopicSniffer(f);

                            // Add a tweet annotator.
                            Matcher matcher = new MultiMatcher(
                                    new DemoAfterthoughtMatcher());

                            final Handler<Tweet> annotator
                                    = new TweetAnnotator(matcher, topicSniffer);

                            Handler<Tweet> adder = new Handler<Tweet>() {
                                public boolean isOpen() {
                                    return annotator.isOpen();
                                }

                                public void handle(final Tweet tweet) throws HandlerException {
                                    try {
                                        c.clear();
                                        c.commit();
                                        c.begin();
                                    } catch (SailException e) {
                                        throw new HandlerException(e);
                                    }

                                     annotator.handle(tweet);
                                }
                            };
                            Handler<Tweet> deleter = new TweetDeleter(store);

                            TweetReceivedLogger rLogger = new TweetReceivedLogger(client.getStatistics(), adder);

                            Set<User> users = TwitLogic.findFollowList(client);
                            Set<String> terms = TwitLogic.findTrackTerms();

                            if (0 < users.size() || 0 < terms.size()) {
                                client.processFilterStream(users, terms, null, rLogger, deleter, 0);
                            } else {
                                client.processSampleStream(rLogger, deleter);
                            }
                        } finally {
                            persister.close();
                        }
                    } finally {
                        c.rollback();
                        c.close();
                    }
                } finally {
                    store.shutDown();
                }
            } finally {
                streamingSail.shutDown();
            }
        } finally {
            workingSail.shutDown();
        }
    }
View Full Code Here

        }
        //*/
    }

    private static void rdfTransactionStuff() throws Exception {
        Sail baseSail = new MemoryStore();
        baseSail.initialize();

        RDFTransactionSail sail = new RDFTransactionSail(baseSail) {
            public void handleTransaction(final List<TransactionOperation> operations) throws SailException {
                System.out.println(new String(createTransactionEntity(operations)));
            }
        };

        SailConnection sc = sail.getConnection();
        try {
            sc.removeStatements(RDF.TYPE, null, null, (URI) null);
            sc.commit();
        } finally {
            sc.rollback();
            sc.close();
        }

        sail.shutDown();
        baseSail.shutDown();
    }
View Full Code Here

        stressTest(h, 10000);
    }

    // Quickly reaches a peak of around 1,900 t/s before slowing down and failing due to lack of memory.
    private void testMemoryPersister() throws Exception {
        Sail sail = new MemoryStore();
        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

        }
    }

    // Reaches a peak of around 2,100 t/s and remains there indefinitely
    private void testTransientMemoryPersister() throws Exception {
        Sail sail = new MemoryStore();
        sail.initialize();

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

                    Handler<Tweet> h = new Handler<Tweet>() {
                        public boolean isOpen() {
                            return p.isOpen();
                        }

                        public void handle(final Tweet tweet) throws HandlerException {
                            try {
                                sc.clear();
                                sc.commit();
                                sc.begin();
                            } catch (SailException e) {
                                throw new HandlerException(e);
                            }
                            p.handle(tweet);
                        }
                    };

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

        }
    }

    // Around 900 t/s (up from 500 t/s before omitting read-operation logging)
    private void testLoggingTransientMemoryPersister() throws Exception {
        Sail baseSail = new MemoryStore();
        baseSail.initialize();

        OutputStream out = new FileOutputStream(new File("/tmp/throughput-test.log"));
        RecorderSail sail = new RecorderSail(baseSail, out);
        sail.getConfiguration().logReadOperations = false;
        //sail.getConfiguration().logTransactions = false;

        try {
            TweetStore store = new TweetStore(sail);
            store.initialize();
            try {
                final SailConnection sc = baseSail.getConnection();
                try {
                    final TweetPersister p = new TweetPersister(store, null);

                    Handler<Tweet> h = new Handler<Tweet>() {
                        public boolean isOpen() {
View Full Code Here

        repo.initialize();
        try {
            AGRepositoryConnection rc = repo.getConnection();
            try {
                //rc.begin();
                Sail tSail = new MemoryStore();
                tSail.initialize();

                try {
                    Sail sail = new AGTransactionSail(tSail, rc, commitsPerUpload);
                    try {

                        TweetStore store = new TweetStore(sail);
                        store.doNotRefreshCoreMetadata();
                        store.initialize();
                        try {
                            final SailConnection tc = tSail.getConnection();
                            try {
                                final TweetPersister p = new TweetPersister(store, null);

                                Handler<Tweet> h = new Handler<Tweet>() {
                                    public boolean isOpen() {
                                        return p.isOpen();
                                    }

                                    public void handle(final Tweet tweet) throws HandlerException {
                                        try {
                                            tc.clear();
                                            tc.commit();
                                            tc.begin();
                                        } catch (SailException e) {
                                            throw new HandlerException(e);
                                        }

                                        p.handle(tweet);
                                    }
                                };

                                stressTest(h, 100);
                            } finally {
                                tc.close();
                            }
                        } finally {
                            store.shutDown();
                        }
                    } finally {
                        sail.shutDown();
                    }
                } finally {
                    tSail.shutDown();
                }
View Full Code Here

        }
    }

    // Around 1000 t/s on the reference machine.  No network requests are made.
    private void testTrivialRdfTransactionPersister() throws Exception {
        Sail transientSail = new MemoryStore();
        transientSail.initialize();

        try {
            Sail sail = new TrivialTransactionSail(transientSail);
            try {
                TweetStore store = new TweetStore(sail);
                store.initialize();

                try {
                    final SailConnection tc = transientSail.getConnection();

                    try {
                        tc.begin();
                        final TweetPersister p = new TweetPersister(store, null);

                        Handler<Tweet> h = new Handler<Tweet>() {
                            public boolean isOpen() {
                                return p.isOpen();
                            }

                            public void handle(final Tweet tweet) throws HandlerException {
                                try {
                                    tc.clear();
                                    tc.commit();
                                    tc.begin();
                                } catch (SailException e) {
                                    throw new HandlerException(e);
                                }
                                p.handle(tweet);
                            }
                        };

                        stressTest(h, 1000);
                    } finally {
                        tc.rollback();
                        tc.close();
                    }
                } finally {
                    store.shutDown();
                }
            } finally {
                sail.shutDown();
            }
        } finally {
            transientSail.shutDown();
        }
    }
View Full Code Here

TOP

Related Classes of org.openrdf.sail.Sail

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.