[
https://issues.apache.org/jira/browse/LUCENE-5640?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13989504#comment-13989504
]
Uwe Schindler edited comment on LUCENE-5640 at 5/5/14 1:33 PM:
---------------------------------------------------------------
bq. I haven't looked closely here, but why does simplifying Token.java required
new hairy things like MethodHandle / getConstructorForInterface / etc.?
That's unrelated. This should improve the reflective default AttributeFactory
(because it no longer uses refection, only initially to look up the instance).
Whenever addAttribute() has to create a new attribute implementation it can
create the instance without any overhead, almost as fast as "new
SomethingImpl()". Before it was using reflection on every call with access
checks, security manager,... Now its doing the reflective access only one time
and then does a hard-linked invocation using the method handle. Its no hairy
trick, its just Java 7 as documented. We were just not able to do this before.
So this is a general improvement,
bq. {{getConstructorForInterface}}
... was already there before the change we just moved the impl to a new class.
In the old code this was just using reflection to get the constructor. The
method was renamed from {getClassForInterface}} to
{{getConstructorForInterface}} to make it more typesafe - so no reflective
access is needed.
This is only partly related to Token, its just a general refactoring to have a
packed attribute for the default attributes. This is just one big patch, sorry.
was (Author: thetaphi):
bq. I haven't looked closely here, but why does simplifying Token.java required
new hairy things like MethodHandle / getConstructorForInterface / etc.?
That's unrelated. This should improve the reflective default AttributeFactory
(because it no longer uses refection, only initially to look up the instance).
Whenever addAttribute() has to create a new attribute implementation it can
create the instance without any overhead, almost as fast as "new
SomethingImpl()". Before it was using reflection on every call with access
checks, security manager,... Now its doing the reflective access only one time
and then does a hard-linked invocation using the method handle. Its no hairy
trick, its just Java 7 as documented. We were just not able to do this before.
So this is a general improvement,
This is only partly related to Token, its just a general refactoring to have a
packed attribute for the default attributes. This is just one big patch, sorry.
> Cleanup Token class
> -------------------
>
> Key: LUCENE-5640
> URL: https://issues.apache.org/jira/browse/LUCENE-5640
> Project: Lucene - Core
> Issue Type: Sub-task
> Components: modules/analysis
> Reporter: Uwe Schindler
> Fix For: 4.9, 5.0
>
> Attachments: LUCENE-5640.patch, LUCENE-5640.patch, LUCENE-5640.patch,
> LUCENE-5640.patch, LUCENE-5640.patch
>
>
> We should remove code duplication in the Token class:
> - copy constructors
> - reinit() shit
> - non-default clone()
> This is too bugy. Most of the methods can be simply removed. In fact, Token
> should just look like a clone of all AttributeImpl it implements.
--
This message was sent by Atlassian JIRA
(v6.2#6252)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]