根据条件从 kafka 数据存储(Rocks DB)中获取记录
Fetch records from kafka data store (Rocks DB) based on condition
现在我正在使用 kafka 数据存储(Rocks DB)来存储来自主题的中间数据。我在此基础上使用 https://kafka.apache.org/20/documentation/streams/developer-guide/interactive-queries.html
编写了一些交互式查询
// 获取此应用程序实例中所有可用键的值
KeyValueIterator<String, Employee> range = keyValueStore.all();
while (range.hasNext()) {
KeyValue<String, Employee> next = range.next();
System.out.println("count for " + next.key + ": " + value);
}
Employee record saved is Employee(id, name)
Sr.No. Id Name
1 emp_1 John
2 emp_2 Jamie
3 emp_3 John
现在我需要所有名为 John 的员工。我找不到任何解决方案来根据 this(where) 子句获取数据。现在我正在获取所有记录并在我的 java 代码中对其进行过滤。请建议是否有其他解决方案。我希望在获取记录时过滤所有记录。
getting all the records and filtering that in my java code
这才是正确的做法。
如果你真的想要“WHERE 子句”,你会想看看 ksqlDB,which can be embedded in Java code
现在我正在使用 kafka 数据存储(Rocks DB)来存储来自主题的中间数据。我在此基础上使用 https://kafka.apache.org/20/documentation/streams/developer-guide/interactive-queries.html
编写了一些交互式查询// 获取此应用程序实例中所有可用键的值
KeyValueIterator<String, Employee> range = keyValueStore.all();
while (range.hasNext()) {
KeyValue<String, Employee> next = range.next();
System.out.println("count for " + next.key + ": " + value);
}
Employee record saved is Employee(id, name)
Sr.No. Id Name
1 emp_1 John
2 emp_2 Jamie
3 emp_3 John
现在我需要所有名为 John 的员工。我找不到任何解决方案来根据 this(where) 子句获取数据。现在我正在获取所有记录并在我的 java 代码中对其进行过滤。请建议是否有其他解决方案。我希望在获取记录时过滤所有记录。
getting all the records and filtering that in my java code
这才是正确的做法。
如果你真的想要“WHERE 子句”,你会想看看 ksqlDB,which can be embedded in Java code