How do I stop Avro from autoboxing primitive types?
Asked Answered
W

0

6

When I put this into my avro schema:

{ "name": "the_id", "type": "int" },

And then I:

mvn generate-sources

A class file is generated that contains the following:

private int the_id;
/**
* All-args constructor.
*/
public TheObject(java.lang.Integer the_id, ...

public java.lang.Integer getTheId() {
 return the_id;
}

"the_id" is declared as an int and then boxed into an Integer in the constructor, and the getter(and the setter although I haven't included that in the code example).

Applying the "autoboxing is bad for performance" principle I would like to stop this from happening. I've checked the docs and scoured the forums and haven't found anything useful: (This Avro mail archive post suggests that autoboxing is "free" in modern JVMs, but this post from Oracle disagrees). Meanwhile this post to the Avro mail archive has gone unanswered.

Does anyone know of a way to stop Avro from autoboxing?

Weightlessness answered 18/12, 2015 at 14:27 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.