Description
Currently, anytime you set or get values from the Event class, you either set or receive copies of your data which have been deeply copied and converted into the correct types for their respective runtime contexts. The main reason this was done was to create a strict division between what is in ruby-land and java-land. This meant two things; 1) it is simpler to reason about types from within the Event object and 2) any future plugins that used a raw java API to interact with the pipeline would not be contaminated with Ruby objects that it does not know what to do with.
The Proposal made in this issue is to stop doing this conversion in the context of JRuby. In short, there is no reason why the Event object's internal Map cannot contain references to IRubyObjects. There may be some data structures that need some wrapping, but both RubyArray and RubyHash implement Java library interfaces like List and Map (respectively). Since this is the case, we mainly have to only worry about the keys of these objects. For example, internal RubyHash objects need to become compatible for FieldReference retrieval by the Accessors class.
Changes needed in Accessors/PathCache/FieldReference
- Ability to extract the responsibility of parsing the string references (e.g. "[foo][bar]") into RubyString components will enable the nested key lookups that occur in Accessors against RubyHashes.
- I propose that this responsibility of
FieldReference.parse
be moved up intoruby_set_field
andruby_get_field
of JrubyEventExtLibrary. This way we remove the need to pass a Ruby Runtime Context to javaland.
- I propose that this responsibility of
TODO
- continue evaluating what steps and situations are missing from the above plan
- introduce ruby-eval tests against Event from within
logstash-core-event-java
instead of just relying on rspec tests outside of the project.- involves: introducing
src/test/resources/fixtures
ruby scripts to be executed against jruby runtimes from within junit tests
- involves: introducing