Reduce memory consumption of EntityInfoImpl objects.

Description

Every instance of EntityInfoImpl references a LinkedList which is used to store the indexes of the entity in the projection even when ProjectionConstants.THIS was not specified in the projection fields. This can be easily avoided. We can use a placeholder in the projection array which will be replaced later in the #populateWithEntityInstance-method.

Additionally the constructor of EntityInfoImpl makes a copy of the projected values array. This is not needed as the array was just created before the call to the constructor and the array is not modified after the call to the constructor.

Activity

Show:

Andrej GolovninApril 4, 2016 at 7:21 PM

The pull request for this issue contains three bonuses:
1. It fixes a small possible NullPointerException in ElasticsearchHSQueryImpl which may occur when the FullTextQuery's projection has null as field name:
FullTextQuery query = ....;
query.setProjection("field1", null, "field2");
2. DocumentExtractorImpl iterates over the projection to set values for projection fields defined in ProjectionConstants only when it is needed. In the current version of Hibernate Search it does it always.
3. The HasMap for the field "DocumentExtractorImpl.targetedClasses" is only created when it is needed.

Fixed

Details

Assignee

Reporter

Fix versions

Priority

Created April 4, 2016 at 7:07 PM
Updated May 21, 2016 at 6:43 PM
Resolved April 6, 2016 at 10:29 AM