LUCENE-5129: CategoryAssociationsContainer should not allow null associations

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1506526 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Shai Erera 2013-07-24 12:42:50 +00:00
parent 7dfaf2e5fb
commit f9bb96db81
3 changed files with 8 additions and 10 deletions

View File

@ -84,6 +84,10 @@ API Changes
searchAfter exceeds the number of documents in the reader.
(Crocket via Shai Erera)
* LUCENE-5129: CategoryAssociationsContainer no longer supports null
association values for categories. If you want to index categories without
associations, you should add them using FacetFields. (Shai Erera)
Optimizations
* LUCENE-5088: Added TermFilter to filter docs by a specific term.

View File

@ -54,13 +54,6 @@ public class AssociationsListBuilder implements CategoryListBuilder {
// build per-association key BytesRef
CategoryAssociation association = associations.getAssociation(cp);
if (association == null) {
// it is ok to set a null association for a category - it's treated as a
// regular category in that case.
++idx;
continue;
}
BytesRef bytes = res.get(association.getCategoryListID());
if (bytes == null) {
bytes = new BytesRef(32);

View File

@ -30,11 +30,12 @@ public class CategoryAssociationsContainer implements Iterable<CategoryPath> {
/**
* Adds the {@link CategoryAssociation} for the given {@link CategoryPath
* category}. Overrides any assocation that was previously set. It is ok to
* pass {@code null}, in which case the category will be treated as a regular
* one (i.e. without association value).
* category}. Overrides any assocation that was previously set.
*/
public void setAssociation(CategoryPath category, CategoryAssociation association) {
if (association == null) {
throw new IllegalArgumentException("cannot set a null association to a category");
}
categoryAssociations.put(category, association);
}