use of org.wikidata.query.rdf.common.uri.UrisScheme in project wikidata-query-rdf by wikimedia.
the class StreamingUpdate method build.
static StreamingUpdaterConsumer build(StreamingUpdateOptions options, MetricRegistry metrics) {
RDFChunkDeserializer deser = new RDFChunkDeserializer(new RDFParserSuppliers(RDFParserRegistry.getInstance()));
KafkaStreamConsumer consumer = KafkaStreamConsumer.build(options.brokers(), options.topic(), options.partition(), options.consumerGroup(), options.batchSize(), deser, parseInitialOffset(options), KafkaStreamConsumerMetricsListener.forRegistry(metrics), options.bufferedInputMessages(), buildFilter(StreamingUpdateOptions.entityFilterPattern(options)));
HttpClient httpClient = buildHttpClient(getHttpProxyHost(), getHttpProxyPort());
Retryer<ContentResponse> retryer = buildHttpClientRetryer();
Duration rdfClientTimeout = RdfRepositoryUpdater.getRdfClientTimeout();
RdfClient rdfClient = new RdfClient(httpClient, StreamingUpdateOptions.sparqlUri(options), retryer, rdfClientTimeout);
UrisScheme uris = UrisSchemeFactory.getURISystem();
return new StreamingUpdaterConsumer(consumer, new RdfRepositoryUpdater(rdfClient, uris), metrics, options.inconsistenciesWarningThreshold());
}
use of org.wikidata.query.rdf.common.uri.UrisScheme in project wikidata-query-rdf by wikimedia.
the class DefaultUrisSchemeUnitTest method testBNodeSkolemIRIPrefix.
@Test
public void testBNodeSkolemIRIPrefix() throws URISyntaxException {
UrisScheme uris = new DefaultUrisScheme(new URI("http://acme2.test"), WIKIBASE_ENTITY_PREFIX, WIKIBASE_ENTITY_DATA_PREFIX, WIKIBASE_INITIALS);
assertThat(uris.wellKnownBNodeIRIPrefix()).isEqualTo("http://acme2.test/.well-known/genid/");
}
use of org.wikidata.query.rdf.common.uri.UrisScheme in project wikidata-query-rdf by wikimedia.
the class DefaultUrisSchemeUnitTest method conceptUri.
@Test
public void conceptUri() throws URISyntaxException {
UrisScheme uris = new DefaultUrisScheme(new URI("http://acme.test/prefix"), WIKIBASE_ENTITY_PREFIX, WIKIBASE_ENTITY_DATA_PREFIX, WIKIBASE_INITIALS);
assertThat(uris.entityURIs()).contains("http://acme.test/prefix/entity/");
assertThat(uris.entityIdToURI("Q1")).isEqualTo("http://acme.test/prefix/entity/Q1");
assertThat(uris.entityIdToURI("P1")).isEqualTo("http://acme.test/prefix/entity/P1");
assertThat(uris.entityData()).isEqualTo("http://acme.test/prefix/wiki/Special:EntityData/");
assertThat(uris.entityDataHttps()).isEqualTo("https://acme.test/prefix/wiki/Special:EntityData/");
}
use of org.wikidata.query.rdf.common.uri.UrisScheme in project wikidata-query-rdf by wikimedia.
the class DefaultUrisSchemeUnitTest method conceptUriSlash.
@Test
public void conceptUriSlash() throws URISyntaxException {
UrisScheme uris = new DefaultUrisScheme(new URI("http://acme3.test/"), WIKIBASE_ENTITY_PREFIX, WIKIBASE_ENTITY_DATA_PREFIX, WIKIBASE_INITIALS);
assertThat(uris.entityURIs()).contains("http://acme3.test/entity/");
assertThat(uris.entityIdToURI("Q1")).isEqualTo("http://acme3.test/entity/Q1");
assertThat(uris.entityIdToURI("P1")).isEqualTo("http://acme3.test/entity/P1");
assertThat(uris.entityData()).isEqualTo("http://acme3.test/wiki/Special:EntityData/");
assertThat(uris.entityDataHttps()).isEqualTo("https://acme3.test/wiki/Special:EntityData/");
}
use of org.wikidata.query.rdf.common.uri.UrisScheme in project wikidata-query-rdf by wikimedia.
the class EntityMungingRdfHandlerUnitTest method testSmallDump.
@Test
public void testSmallDump() throws RDFParseException, IOException, RDFHandlerException {
UrisScheme uriScheme = UrisSchemeFactory.WIKIDATA;
Munger munger = Munger.builder(uriScheme).build();
RDFHandler childHandler = mock(RDFHandler.class);
AtomicLong nbEntities = new AtomicLong();
EntityMungingRdfHandler handler = new EntityMungingRdfHandler(uriScheme, munger, childHandler, nbEntities::set);
RDFParser parser = Rio.createParser(RDFFormat.TURTLE);
parser.setRDFHandler(handler);
parser.parse(this.getClass().getResourceAsStream("small_dump.ttl"), uriScheme.root());
verify(childHandler, atLeastOnce()).handleStatement(statements.capture());
assertThat(munger.getDumpFormatVersion()).isEqualTo("1.0.0");
assertThat(statements.getAllValues()).contains(// initial Dump statements are kept and passsed through
statement("http://wikiba.se/ontology#Dump", "http://www.w3.org/1999/02/22-rdf-syntax-ns#type", "http://schema.org/Dataset"), // a random statement
statement("https://en.wikipedia.org/wiki/Resource_Description_Framework", "http://schema.org/about", "http://www.wikidata.org/entity/Q54872"), statement("http://www.wikidata.org/entity/Q6825", "http://www.w3.org/2002/07/owl#sameAs", "http://www.wikidata.org/entity/Q26709563"), // redirect revision ID
statement("http://www.wikidata.org/entity/Q6825", "http://schema.org/version", 942411738), statement("https://it.wikivoyage.org/wiki/Belgio", "http://schema.org/about", "http://www.wikidata.org/entity/Q31"));
// Check that the blank node is kept
assertThat(statements.getAllValues()).filteredOn(s -> s.getSubject().stringValue().equals("http://www.wikidata.org/entity/Q54872") && s.getPredicate().stringValue().equals("http://www.wikidata.org/prop/direct/P576")).size().isEqualTo(1);
assertThat(nbEntities.intValue()).isEqualTo(3);
}
Aggregations