apache / lucene

Apache Lucene open-source search software
https://lucene.apache.org/
Apache License 2.0
2.73k stars 1.05k forks source link

FacetIndexing/SearchParams house cleaning [LUCENE-4621] #5686

Closed asfimport closed 11 years ago

asfimport commented 11 years ago

FacetIndexingParams lets you configure few things such as OrdinalPolicy, PathPolicy and partitionSize. However, in order to set them you must extend DefaultFacetIndexingParams and override fixedXY(), as the respective getters are final.

I'd like to do the following:


Migrated from LUCENE-4621 by Shai Erera (@shaie), resolved Dec 13 2012 Attachments: LUCENE-4621.patch (versions: 2)

asfimport commented 11 years ago

Shai Erera (@shaie) (migrated from JIRA)

Patch does the following:

The chain of indexing params is now:

FacetIP has a scary equals() and hashCode() implementations. Not sure why do we need them, i.e. do we put them in a map? Anyway, this should not block the commit.

All tests pass, I think it's ready.

asfimport commented 11 years ago

Shai Erera (@shaie) (migrated from JIRA)

FacetSearchParams could also be made immutable, by eliminating addFacetRequest and setClCache. I saw that it might be an issue with the tests, so I'll check if this can be done cleanly. Basically I think it's doable, I'll do it now.

asfimport commented 11 years ago

Shai Erera (@shaie) (migrated from JIRA)

Updated patch makes FacetSearchParams immutable too. Now all FacetRequests must be specified at construction. For convenience I added these ctors:

You can no longer set CategoryListCache, you need to override. But with all the changes happening (cutting over to DV), I suspect that this method will be nuked completely, soon.

FacetSP do not allow empty requests. That caused trouble in PartitionUtils because it exposed methods that take FSP, but only delegate to FIP methods. I nuked the FSP methods, whoever uses partitions should understand that he can call fsp.getFIP(). The problem was that some places just called PartitionUtils w/ an empty FSP, just because you could initialize one.

I think this is ready. Would be glad if someone took a quick look at FSP, FIP and its chain, see if you think it can be improved somehow.

asfimport commented 11 years ago

Sivan Yogev (migrated from JIRA)

Patch looks good. One question - there is a ctor of FIP whose Javadoc states: "You should use this constructor only if you intend to override any of the getters". Shouldn't it be protected?

asfimport commented 11 years ago

Shai Erera (@shaie) (migrated from JIRA)

Thanks for the review !

That comment is meant more to direct user's attention to the constant. If I'd make it protected, then you couldn't do:

FacetIndexingParams fip = new FacetIndexParams() {
  `@Override`
  public int getPartitionSize() { return size; }
}

This patter is easy and used in tests, as well as I used it in some code that I wrote. It doesn't force you to actually declare a class.

asfimport commented 11 years ago

Sivan Yogev (migrated from JIRA)

OK, ready to commit from my side.

asfimport commented 11 years ago

Michael McCandless (@mikemccand) (migrated from JIRA)

This patch looks like a great cleanup!

asfimport commented 11 years ago

Commit Tag Bot (migrated from JIRA)

[trunk commit] Shai Erera http://svn.apache.org/viewvc?view=revision&revision=1421256

LUCENE-4621: FacetIndexing/SearchParams house cleaning

asfimport commented 11 years ago

Commit Tag Bot (migrated from JIRA)

[branch_4x commit] Shai Erera http://svn.apache.org/viewvc?view=revision&revision=1421262

LUCENE-4621: FacetIndexing/SearchParams house cleaning

asfimport commented 11 years ago

Shai Erera (@shaie) (migrated from JIRA)

Committed to trunk and 4x.