[ 
https://issues.apache.org/jira/browse/LUCENE-9314?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17083689#comment-17083689
 ] 

Pierre-Luc Perron edited comment on LUCENE-9314 at 4/14/20, 11:34 PM:
----------------------------------------------------------------------

I agree, and I find the decision hard to make. On one hand, It fits my 
perception that zero document should match nothing, and an array of zero 
document  should not be considered any different than an array of one or more 
documents i.e. not an exception. In a way, I find the problem similar to null 
object design pattern.

On the other hand, it creates a subtle bug if the users take the number of 
documents in another calculation (like statistics) because the library creates 
a document without him knowing.

I consider both alternatives as valid, and I will change it if you show yet 
again the desire for a change.

Thanks again for the feedback.


was (Author: pl.perron):
I agree, and I found the decision hard to make. On one hand, It fits my 
perception that zero document should match nothing, and an array of zero 
document  should not be considered any different than an array of one or more 
documents i.e. not an exception. In a way, I find the problem similar to null 
object design pattern. 

On the other hand, it creates a subtle bug if the users take the number of 
documents in another calculation (like statistics) because the library creates 
a document without him knowing.

I consider both alternatives as valid, and I will change it if you show yet 
again the desire for a change.

Thanks again for the feedback.

> Lucene monitor module uses ByteBuffersDirectory rather than MemoryIndex when 
> matching a single document
> -------------------------------------------------------------------------------------------------------
>
>                 Key: LUCENE-9314
>                 URL: https://issues.apache.org/jira/browse/LUCENE-9314
>             Project: Lucene - Core
>          Issue Type: Improvement
>          Components: modules/other
>    Affects Versions: 8.2, 8.3, 8.4, 8.5
>            Reporter: Pierre-Luc Perron
>            Priority: Minor
>              Labels: easyfix, performance, pull-request-available
>         Attachments: LUCENE-9314.patch, LUCENE-9314.patch, LUCENE-9314.patch
>
>          Time Spent: 10m
>  Remaining Estimate: 0h
>
> Lucene monitor function, [match single 
> document|https://github.com/apache/lucene-solr/blob/e376582e25d02f85b415eb1c0456f3fdc800fc84/lucene/monitor/src/java/org/apache/lucene/monitor/Monitor.java#L276],
>  wraps a single document into a array of documents. Hence, it always calls 
> the function, [match many 
> documents|https://github.com/apache/lucene-solr/blob/e376582e25d02f85b415eb1c0456f3fdc800fc84/lucene/monitor/src/java/org/apache/lucene/monitor/Monitor.java#L256],
>   which builds a 
> [MultiDocumentBatch|https://github.com/apache/lucene-solr/blob/71d335ff688982cef10a648c914623c81ceeeeed/lucene/monitor/src/java/org/apache/lucene/monitor/DocumentBatch.java#L56]
>  rather than a 
> [SingletonDocumentBatch|https://github.com/apache/lucene-solr/blob/71d335ff688982cef10a648c914623c81ceeeeed/lucene/monitor/src/java/org/apache/lucene/monitor/DocumentBatch.java#L46].
>  The former uses ByteBuffersDirectory while later uses MemoryIndex.
> As per documentation, 
> [MemoryIndex|https://lucene.apache.org/core/8_2_0/memory/index.html] is a 
> high-performance single-document main memory Apache Lucene fulltext search 
> index. Hence, Lucene monitor should use it when matching a single document.
> The patch routes [match single 
> document|https://github.com/apache/lucene-solr/blob/e376582e25d02f85b415eb1c0456f3fdc800fc84/lucene/monitor/src/java/org/apache/lucene/monitor/Monitor.java#L276]
>  to a SingletonDocumentBatch.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org
For additional commands, e-mail: issues-h...@lucene.apache.org

Reply via email to