@Override public void delete(final URI type, final URI id) throws IOException, IllegalStateException { // Obtain the statements to delete throuh a lookup final List<Statement> statements = Record.encode( lookup(type, ImmutableSet.of(id), null), ImmutableList.of(type)).toList(); // Perform the deletion this.transaction.remove(statements); }
@Override public synchronized void init() throws IOException, IllegalStateException { Preconditions.checkState(!this.initialized && !this.closed); this.initialized = true; InputStream stream = null; try { if (this.fileSystem.exists(this.filePath)) { stream = Files.readWithBackup(this.fileSystem, this.filePath); final RDFFormat format = RDFFormat.forFileName(this.filePath.getName()); final List<Record> records = Record.decode( RDFUtil.readRDF(stream, format, null, null, false), ImmutableSet.of(KS.RESOURCE, KS.MENTION, KS.ENTITY, KS.CONTEXT), false) .toList(); for (final Record record : records) { final URI id = Preconditions.checkNotNull(record.getID()); final URI type = Preconditions.checkNotNull(record.getSystemType()); MemoryDataStore.this.tables.get(type).put(id, record); } MemoryDataStore.LOGGER.info("{} initialized, {} records loaded", this.getClass() .getSimpleName(), records.size()); } else { MemoryDataStore.LOGGER.info("{} initialized, no record loaded", this.getClass() .getSimpleName()); } } finally { Util.closeQuietly(stream); } }
@Override public void handle(final Record record) throws Throwable { if (record == null || this.records > 0 && this.records % 1000 == 0) { LOGGER.info(this.records + " records, " + this.triples + " triples processed"); } if (record != null) { final List<Statement> statements = Record.encode(Stream.create(record), ImmutableSet.of()).toList(); writer.handleComment(record.getID().toString()); for (final Statement statement : statements) { writer.handleStatement(statement); } ++this.records; this.triples += statements.size(); } }
@Override public void store(final URI type, final Record record) throws IOException, IllegalStateException { // Delete existing data for the record URI delete(type, record.getID()); // Add statements final List<Statement> statements = Record.encode(Stream.create(record), ImmutableList.of(type)).toList(); this.transaction.add(statements); }
delegate().lookup(type, missingIDs, null).toList(); CachingDataStore.this.fetchCount.addAndGet(missingIDs.size());
final InputStream stream = retrieveURL(configLocation).openStream(); final RDFFormat format = RDFFormat.forFileName(configLocation); config = RDFUtil.readRDF(stream, format, Data.getNamespaceMap(), null, false).toList(); stream.close();