Skip to content

Commit

Permalink
[producer] Allow deleting records via the shell producer (#646)
Browse files Browse the repository at this point in the history
The shell producer can allow deleting records by accepting the value null regardless of the fact that it is compatible with the store schema or not. Note that other forms of null like "null", 'null', etc are not allowed.
  • Loading branch information
nisargthakkar authored Sep 21, 2023
1 parent 28ac911 commit 7931a17
Showing 1 changed file with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -184,10 +184,14 @@ private static void writeToStore(ProducerContext producerContext) throws Excepti
RouterBasedStoreSchemaFetcher schemaFetcher = new RouterBasedStoreSchemaFetcher(castClient);
Schema keySchema = schemaFetcher.getKeySchema();
Object key = adaptDataToSchema(producerContext.key, keySchema);
Object value = getValueObject(producerContext.value, schemaFetcher);

producer.asyncPut(key, value).get();
System.out.println("Data written to Venice!");
if (producerContext.value.equals("null")) { // Only allow `null`. Not "null", or 'null', or whatever.
producer.asyncDelete(key).get();
System.out.println("Record deleted from Venice!");
} else {
Object value = getValueObject(producerContext.value, schemaFetcher);
producer.asyncPut(key, value).get();
System.out.println("Data written to Venice!");
}
} catch (Exception e) {
System.err.println(ExceptionUtils.stackTraceToString(e));
System.exit(1);
Expand Down

0 comments on commit 7931a17

Please sign in to comment.