/** * Adds all triples or quads from the file at the given path to the store.<br /> * This method uses 2/3 of the connected hosts threads to insert into * Cassandra. * * @param file The path to the file to read from. * @param format The format of the file. * @throws CumulusStoreException If an error occurs during adding the data. * @throws IOException If an error occurs during reading from the given file. */ public void bulkLoad(final String file, final RDFFormat format) throws CumulusStoreException, IOException { bulkLoad(new File(file), format); }
/** * Shutdown repository and store. * * @throws Exception mmm...hopefully never otherwise tests will fail. */ @AfterClass public static void shutdown() throws Exception { if (_repository != null) { _repository.shutDown(); } if (_sail != null) { _sail.shutDown(); } if (_tripleStore != null) { if (_tripleStore.isOpen()) { _tripleStore.clear(); } _tripleStore.close(); } if (_quadStore != null) { if (_quadStore.isOpen()) { _quadStore.clear(); } _quadStore.close(); } }
/** * Removes the test data from the quad store. * @throws CumulusStoreException If the test data could not be removed. */ @After public void clear() throws CumulusStoreException { _quadStore.removeData(asList(_data).iterator()); assertEmptyIterator(Arrays.toString(SELECT_ALL_QUADS_PATTERN), _quadStore.query(SELECT_ALL_QUADS_PATTERN)); }
@Override protected void initializeInternal() throws SailException { try { _store.open(); _valueFactory = new CumulusRDFValueFactory(_store.getDictionary()); } catch (final CumulusStoreException exception) { LOGGER.error(MessageCatalog._00025_CUMULUS_SYSTEM_INTERNAL_FAILURE, exception); throw new SailException(exception); } }
store.setDefaultBatchLimit(batchSize); store.bulkLoad(inputFile, rdfFormat);
/** * Test if the triple store works with large iterators. * * @throws Exception If something bad happens... */ @Test public void testLargeTripleOperations() throws Exception { _tripleStore = newTripleStore(); _tripleStore.open(); try { Random random = new Random(452662401L); List<Statement> statements = randomStatements(random, (int) (1000 * 3.1415)); InputStream statementStream = statementIteratorToRdfStream(statements.iterator(), RDFFormat.NTRIPLES); _tripleStore.bulkLoad(statementStream, RDFFormat.NTRIPLES); assertEquals("Store contains different amount of triples than inserted!", statements.size(), numOfRes(_tripleStore.query(SELECT_ALL_TRIPLES_PATTERN))); _tripleStore.removeData(_tripleStore.query(SELECT_ALL_QUADS_PATTERN)); assertEquals( "Store should be empty after deleting everything!", 0, numOfRes(_tripleStore.query(SELECT_ALL_QUADS_PATTERN))); } finally { _tripleStore.close(); } } }
/** * Builds a new Describe iterator with the given data. * * @param resource the target resource. * @param include2Hop * @param subjects max subjects in results. * @param objects max objects in results. * @throws CumulusStoreException in case of CumulusRDF internal failure. */ public DescribeIterator(final Value resource, final boolean include2Hop, final int subjects, final int objects) throws CumulusStoreException { _mResource = resource; _mInclude2Hop = include2Hop; _mSubjects = subjects; _mObjects = objects; _mSit = query(new Value[] {_mResource, null, null}, _mSubjects); _mOit = query(new Value[] {null, null, _mResource}, _mObjects); }
if (isOpen()) { _log.info(MessageCatalog._00049_STORE_ALREADY_OPEN); return; ManagementRegistrar.registerStore( this, String.valueOf(storageLayout()), getDataAccessLayerFactory().getUnderlyingStorageInfo()); } catch (InstanceAlreadyExistsException exception) { _log.error(MessageCatalog._00111_MBEAN_ALREADY_REGISTERED, getId()); throw new CumulusStoreException(exception); } catch (final Exception exception) { _log.error(MessageCatalog._00109_UNABLE_TO_REGISTER_MBEAN, exception, getId()); throw new CumulusStoreException(exception); _factory = getDataAccessLayerFactory(); _rdfIndexDAO = getRdfIndexDAO(); _rdfIndexDAO.initialiseRdfIndex(); } catch (final DataAccessLayerException exception) { final CounterFactory counterFactory = getCounterFactory(); counterFactory.initialise(_factory); } catch (final InitialisationException exception) { _selectEstimator = new HeuristicsBasedSelectivityEstimator(getCounterFactory()); _status = new StatusListener(); _changeListeners = new LinkedList<ITriplesChangesListener>();
/** * Adds and then removes triples. * * @throws Exception never, otherwise the tests fail. */ @Test public void testAddAndRemove() throws Exception { _tripleStore.addData(parseNX( "<http://izeus1.scc.kit.edu/id/i1> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://gridpedia.org/id/TestType> . ") .iterator()); _tripleStore.addData(parseNX( "<http://izeus1.scc.kit.edu/id/i2> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://gridpedia.org/id/TestType> . ") .iterator()); assertEquals(2, numOfRes(_tripleStore.query(new Value[] { null, RDF.TYPE, buildResource("http://gridpedia.org/id/TestType") }))); _tripleStore.removeData(_tripleStore.query(new Value[] { buildResource("http://izeus1.scc.kit.edu/id/i1"), null, null })); assertEquals(1, numOfRes(_tripleStore.query(new Value[] { null, RDF.TYPE, buildResource("http://gridpedia.org/id/TestType") }))); }
/** * Setup fixture for this test case. * * @throws Exception never, otherwise the test fails. */ @BeforeClass public static void setUp() throws Exception { _repository = new SailRepository(new MemoryStore()); _repository.initialize(); _tripleStore = newTripleStore(); _tripleStore.enableRangeIndexesSupport(); _tripleStore.open(); assertTrue("Ranges have not been enabled for this triple store!", _tripleStore.isRangeIndexesSupportEnabled()); _tripleStore.bulkLoad(DATA, RDFFormat.NTRIPLES); _repositoryConnection = _repository.getConnection(); _repositoryConnection.add(new File(DATA), "http://nb-base-uri-not-actually-used", RDFFormat.NTRIPLES); }
/** * Loads the test data into the quad store. * @throws CumulusStoreException If the test data could not be loaded. */ @Before public void load() throws CumulusStoreException { _quadStore.addData(asList(_data).iterator()); assertEquals(_data.length, numOfRes(_quadStore.query(SELECT_ALL_QUADS_PATTERN))); }
final Value[] rangeQuery = { null, buildResource(_predicate) }; final Iterator<Statement> queryResultIterator = _tripleStore.query(query); final Set<BigDecimal> rangeItems = new TreeSet<BigDecimal>(); for (; queryResultIterator.hasNext();) { final Iterator<Statement> iter = _tripleStore.range(rangeQuery, null, true, null, true, false, Integer.MAX_VALUE); assertTrue(iter != null && iter.hasNext());
/** * If a "uri" parameter is specified {@link CRUDServlet} will delete the * corresponding entity. On top of receiving a valid URI parameter it will * use a DESCRIBE to delete the whole entity description (i.e. triples where * that URI is subject or object). * * If there are no matching triples that describe the given entity then * delete won't have any effect on the store. * * @throws Exception * hopefully never, otherwise the test fails. */ @Test public void deleteEntityWithNoMatchingData() throws Exception { for (final String uriAsString : _unmatchingUri) { final URI uri = buildResource(uriAsString); final int howManyTriplesForThatEntityBeforeDeleting = numOfRes(TRIPLE_STORE.describe(uri, false)); final int howManyTriplesOnStoreBeforeDeleting = numOfRes(TRIPLE_STORE.query(SELECT_ALL_TRIPLES_PATTERN)); assertEquals("There must be no triple matching for entity " + uriAsString, 0, howManyTriplesForThatEntityBeforeDeleting); assertTrue("At least one triple must exist and it mustn't match DESCRIBE " + uriAsString, howManyTriplesOnStoreBeforeDeleting > 0); final HttpServletResponse response = mock(HttpServletResponse.class); final HttpServletRequest request = createMockHttpRequest(uri, null, null, null, null); _classUnderTest.doDelete(request, response); verify(response).setStatus(HttpServletResponse.SC_NOT_FOUND); final int howManyTriplesOnStoreAfterDeleting = numOfRes(TRIPLE_STORE.query(SELECT_ALL_TRIPLES_PATTERN)); assertEquals(howManyTriplesOnStoreBeforeDeleting, howManyTriplesOnStoreAfterDeleting); } }
@BeforeClass public static void beforeAllTests() throws Exception { _tripleStore = newTripleStore(); _tripleStore.open(); map = new PersistentMap<String, String>(String.class, String.class, "MAP_" + randomString(), false, null); map.initialise(_tripleStore.getDataAccessLayerFactory()); }
@BeforeClass public static void beforeAllTests() throws Exception { _tripleStore = newTripleStore(); _tripleStore.open(); _counter_factory = _tripleStore.getCounterFactory(); }
@BeforeClass public static void setUp() throws Exception { _quadStore = newQuadStore(); _quadStore.open(); }
@Override protected void shutDownInternal() throws SailException { if (_store != null) { _store.close(); } } }