[ 
https://issues.apache.org/jira/browse/LUCENENET-181?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12700667#action_12700667
 ] 

eyal post commented on LUCENENET-181:
-------------------------------------

There are 2 ways to discuss this: 
1. Without understanding how TermInfosReader is using the  LocalDataStoreSlot,  
I can still say it is working fine because it is working exactly the same as 
the java version does. The java equivalent (ThreadLocal) is also created 
everytime a TermInfosReader reader is created so there's no problem here. 
2. If (1) doesn't satisfy you, then we should understand how TermInfosReader is 
using the  LocalDataStoreSlot. In this case, I beleive that the 
LocalDataStoreSlot is what makes the TermInfosReader ThreadSafe because even if 
multiple threads use the same instance of TermInfosReader they will still get 
different SegmentTermEnum instances and they won't interefe with each other. 

If you'll make "enumerators" static in this case then *all* TermInfosReader 
will share the same instance which is definitly not what we want and is 
defintly not how the java version behaves (remember - The "enumerators" 
variable is also non-static in the java version).


> Port of ThreadLocal is wrong?
> -----------------------------
>
>                 Key: LUCENENET-181
>                 URL: https://issues.apache.org/jira/browse/LUCENENET-181
>             Project: Lucene.Net
>          Issue Type: Improvement
>            Reporter: Digy
>            Priority: Minor
>         Attachments: TestCase.cs
>
>
> AFAIK, "ThreadLocal" in Java is there to hold objects which are intented to 
> be used  thread-wide. So, its port-equivalent "LocalDataStoreSlot" should 
> contain objects related with the executing thread. But, since they are not 
> declared as "static" in Analyzer.cs, FieldsReader.cs, SegmentReader.cs and 
> TermInfosReader.cs, they are created with every class contruction, changing 
> the behaviour of "ThreadLocal" and possibly resulting in performance 
> degradation.
> I will attach a test case for this issue.
> If I am wrong, then there is no problem. But If I am right we are in trouble; 
>  Since adding "static" to variables declared as LocalDataStoreSlot results in 
> failing of almost all test cases.
> DIGY

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to