use of org.wikidata.query.rdf.tool.rdf.client.UpdateMetricsResponseHandler in project wikidata-query-rdf by wikimedia.
the class RdfRepositoryUpdaterUnitTest method testReconcile.
@Test
public void testReconcile() {
entitiesToReconcile.put("Q123", Arrays.asList(statement("http://acme.test/entity/Q123", "http://actme.test/prop/direct/P123", "uri:something"), statement("http://acme.test/entity/Q123", "http://actme.test/prop/P123", "http://acme.test/entity/statement/Q123-S-123"), statement("http://acme.test/entity/statement/Q123-S-123", "http://actme.test/property/P123", "http://acme.test/property/statement/Q123"), statement("https://oc.wikipedia.org/Affachade", "http://actme.test/property/P123", "http://acme.test/entity/Q123")));
ConsumerPatch patch = new ConsumerPatch(statements(), statements(), statements(), statements(), entityIdsToDelete, entitiesToReconcile);
RdfRepositoryUpdater rdfRepositoryUpdater = new RdfRepositoryUpdater(client, urisScheme);
UpdateMetricsResponseHandler handler = new UpdateMetricsResponseHandler(false, false, true);
CollectedUpdateMetrics metrics = new CollectedUpdateMetrics();
metrics.setMutationCount(10);
when(client.update(anyString(), any())).thenReturn(metrics);
RDFPatchResult result = rdfRepositoryUpdater.applyPatch(patch, avgEventTime);
ArgumentCaptor<String> captor = ArgumentCaptor.forClass(String.class);
verify(client, times(1)).update(captor.capture(), any());
assertThat(result.getReconciliationMutations()).isEqualTo(10);
assertThat(captor.getValue()).isEqualTo(reconciliationQueryString);
}
use of org.wikidata.query.rdf.tool.rdf.client.UpdateMetricsResponseHandler in project wikidata-query-rdf by wikimedia.
the class RdfRepository method sendUpdateBatch.
private CollectedUpdateMetrics sendUpdateBatch(Set<String> entityIds, List<Statement> insertStatements, ClassifiedStatements classifiedStatements, Set<String> valueSet, Set<String> refSet, boolean verifyResult, boolean withTimestamp) {
log.debug("Processing {} IDs and {} statements", entityIds.size(), insertStatements.size());
String query = multiSyncUpdateQueryFactory.buildQuery(entityIds, insertStatements, classifiedStatements, valueSet, refSet, fetchLexemeSubIds(entityIds), withTimestamp ? Optional.of(Instant.now()) : Optional.empty());
log.debug("Sending query {} bytes", query.length());
long start = System.nanoTime();
CollectedUpdateMetrics collectedUpdateMetrics = rdfClient.update(query, new UpdateMetricsResponseHandler(!refSet.isEmpty(), !valueSet.isEmpty(), withTimestamp));
log.debug("Update query took {} nanos and modified {} statements", System.nanoTime() - start, collectedUpdateMetrics.getMutationCount());
if (verifyResult) {
try {
verifyStatements(entityIds, insertStatements);
} catch (QueryEvaluationException e) {
throw new FatalException("Can't load verify results: " + e, e);
}
}
return collectedUpdateMetrics;
}
Aggregations