Repository navigation
Conversation
…terrupted calls with UNAVAILABLE
…gate Flat /rmeta-shaped documents with registry type hints; unary, streaming and bidi with in-band per-request errors; v1 and v2 share FetchParseRuntime. buf lint/breaking CI for both protos. MetadataTypeChangesTest requires declared type changes against a committed baseline. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
The main missing piece is typed values. @krickert @dpol1 wdyt of this, potentially? |
|
First - much better than what I did. Second - I think we can avoid the string conversion completely Here's a short version that builds on what you have so far: Protobuf already has a value type, Instead - how about this? In java, every protobuf message extends public interface MessageParser<T extends Message> {
Class<T> messageType();
List<Property> properties(); // the keys it writes and their types
List<Metadata> parse(T message) throws TikaException;
}So you'd have to just make a plugin jar ships its own generated stubs and one of these. The parser maps the message into Metadata the same way any Tika parser does, in plain Java. Tika never sees the .proto, and there's no mapping config or reflection. The service takes a The problem with swapping strings are the weirdo things that happen - dates and times are annoying :) And converting to strings is really heavy on the CPU under heavy load. |
|
Y, dates and times are a mess. We do have the date normalizing filter that slaps a user configured timezone on values that don't have them (some image metadata???) so that strict consumers don't complain. Can you tell me how value would work? |
|
Going back to #2961, would this work? Then: |
|
And, sorry, what is the plugin point? Are you proposing a different metadata schema/parser per file type? |
|
So the plugin - Protobufs are already strongly typed. Just write a java mapper class to make the object go from one type of object to antoher. Using SPI, it will bring the java protobuf class into the classpath. If it is an Any object, you can just proxy it too if you want. You really should try to have everything strongly typed and avoid converting it from type->string->type. You can just do type->type with this solution. public class WarcRecordParser implements MessageParser<WarcRecord> {
static final Property STATUS = Property.externalInteger("warc:http-status");
public Class<WarcRecord> messageType() { return WarcRecord.class; }
public List<Property> properties() { return List.of(STATUS); }
public List<Metadata> parse(WarcRecord record) {
Metadata m = new Metadata();
m.set(TikaCoreProperties.SOURCE_PATH, record.getTargetUri());
m.set(STATUS, record.getHttpStatus());
m.set(TikaCoreProperties.TIKA_CONTENT, record.getText());
return List.of(m);
}
}and also to serialize we'd just call pack(): ParseMessageResponse r = stub.parseMessage(
ParseMessageRequest.newBuilder().setMessage(Any.pack(record)).build());The idea is that you don't convert it to a string. Converting some types from data->string->data can cause serialization headaches. |
|
I'm gonna yell at bots to do it both ways so you'll see. |
|
Separate proto parser for each Tika parser? |
|
On #3451 (comment), I'm now getting on board with locking down value types. I had been worried that grpc would limit our flexibility to change value types in base Tika, but we really haven't done that very often. So, should I update this PR to follow the pattern with oneof() in #2961? |
|
@tballison so I made an update to the branch - it's a throwaway one because I implement both strategies. I'll push it in a sec |
I added a write up here: |
|
So let me know if this approach is clear. It's going to be a similar pattern I use for the grpc output we do for tika in OpenNLP - we'll have a document shape in there that'll get all the RAG folks excited including putting embeddings on the data (I'll build a plugin for you as well that decorates NLP data all over the place in Tika once we release 3.0). That being said, I imagine we would make OpenNLP's enhancements a direct integration, or we can make it so it's either-or (if they want to scale the OpenNLP work, they can use the gRPC and if they want to just directly integrate it they can do that as well). But the idea really falls around SPI and the ability to inject services into java now without reflection. Also, the fact that all protobufs carry the "Message" inheritance. FastWARC's grpc server is a good example - I can see a lot of Tika people having WARC files. But my intent with that parser is just to have a useful example. I can pick another service if you want as a demonstration. |
Yes, if it keeps what your Values had: the declared type and the original strings. #2961 (I worked on it) drops the type when one value fails to convert, so ParseBytes fits as the "Later" RPC in your design. Two things here, from the code (not run):
|
It's not one per Tika parser. A The jar would ship its own generated stubs and decides how its message maps onto Tika's document shape. Tika never has to know the message's schema, and nothing goes through strings. |
Proof of concept for grpc v2. This is 100% 🤖 generated.
Thanks to @krickert and @dpol1, whose #2961 this builds on.
Links: Design:TIKA-4776 and doc.