[
https://issues.apache.org/jira/browse/LUCENE-2779?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12965205#action_12965205
]
Shai Erera commented on LUCENE-2779:
------------------------------------
bq. toArray() with no parameters failed on CHM?
I don't use toArray(). I use toArray(new String[0]) because I don't want to
cast the returned array to String[]. According to the javadocs:
_Returns an array containing all of the elements in this collection; the
runtime type of the returned array is that of the specified array. If the
collection fits in the specified array, it is returned therein. Otherwise, a
new array is allocated with the runtime type of the specified array and the
size of this collection._
This method guarantees the right array size will be allocated.
> Use ConcurrentHashMap in RAMDirectory
> -------------------------------------
>
> Key: LUCENE-2779
> URL: https://issues.apache.org/jira/browse/LUCENE-2779
> Project: Lucene - Java
> Issue Type: Improvement
> Components: Store
> Reporter: Shai Erera
> Assignee: Shai Erera
> Priority: Minor
> Fix For: 3.1, 4.0
>
> Attachments: LUCENE-2779-backwardsfix.patch, LUCENE-2779.patch,
> LUCENE-2779.patch, LUCENE-2779.patch, TestCHM.java
>
>
> RAMDirectory synchronizes on its instance in many places to protect access to
> map of RAMFiles, in addition to updating the sizeInBytes member. In many
> places the sync is done for 'read' purposes, while only in few places we need
> 'write' access. This looks like a perfect use case for ConcurrentHashMap
> Also, syncing around sizeInBytes is unnecessary IMO, since it's an AtomicLong
> ...
> I'll post a patch shortly.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]