Package org.apache.marmotta.kiwi.loader.generic

Examples of org.apache.marmotta.kiwi.loader.generic.KiWiHandler


                log.info("- using MySQL bulk loader ... ");
                loaderConfiguration.setCommitBatchSize(100000);
                handler = new KiWiMySQLHandler(store,loaderConfiguration);
            } else {
                log.info("- using generic KiWi loader ... ");
                handler = new KiWiHandler(store,loaderConfiguration);
            }
            handler.initialise();
        } catch (RepositoryException e) {
            throw new RDFHandlerException("error initialising KiWi repository",e);
        } catch (InstantiationException | IllegalAccessException e) {
View Full Code Here


        testImport(cfg);
    }


    private void testImport(KiWiLoaderConfiguration c) throws RDFParseException, IOException, RDFHandlerException {
        KiWiHandler handler;
        if(store.getPersistence().getDialect() instanceof PostgreSQLDialect) {
            handler = new KiWiPostgresHandler(store, c);
        } else if(store.getPersistence().getDialect() instanceof MySQLDialect) {
            handler = new KiWiMySQLHandler(store, c);
        } else {
            handler = new KiWiHandler(store, c);
        }

        try {
            // bulk import
            long start = System.currentTimeMillis();
            RDFParser parser = Rio.createParser(RDFFormat.RDFXML);
            parser.setRDFHandler(handler);
            parser.parse(this.getClass().getResourceAsStream("demo-data.foaf"),"");

            logger.info("bulk import in {} ms", System.currentTimeMillis() - start);

            // check presence of data
            try {
                RepositoryConnection con = repository.getConnection();
                try {
                    con.begin();

                    Assert.assertTrue(con.hasStatement(null,null,null,true));

                    con.commit();
                } catch(RepositoryException ex) {
                    con.rollback();
                } finally {
                    con.close();
                }
            } catch(RepositoryException ex) {
                ex.printStackTrace(); // TODO: handle error
            }
        } finally {
            handler.shutdown();
        }

    }
View Full Code Here

TOP

Related Classes of org.apache.marmotta.kiwi.loader.generic.KiWiHandler

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.