Class MultiRangeItem<Type extends Number>
- All Implemented Interfaces:
TaggableItem,Cloneable
This is a stricter version of an OrItem containing multiple RangeItems, where all
ranges must be specified against the same field, or pair of fields, and where all the left boundaries,
and all the right boundaries, share whether they are MultiRangeItem.Limit.INCLUSIVE or MultiRangeItem.Limit.EXCLUSIVE.
Furthermore, all overlapping ranges are joined, such that the set of ranges this represents is
guaranteed to be non-overlapping, and thus, sorted order of start and end boundaries is the same,
which allows efficient filtering of document points or ranges by whether they are included in any of
the ranges contained in this term. Note that touching ranges, like [3, 5) and [5, 7), will be joined
unless this item is declared to have exclusive boundaries at both ends, or if one of the items is contained
within the other, e.g., (3, 5) and (5, 5) (see below for explanation of weirdness).
In the absence of a range type in the schema definition, all ranges (and points) contained in documents are taken to be inclusive at both ends. However, intersection of range starts from documents and range ends from the query is inclusive, i.e., matching on equality, iff. both boundaries are inclusive, and likewise for intersection between range starts from query and range ends from documents. It is therefore possible to achieve any matching by choosing inclusiveness for the query ranges appropriately. For the case where document ranges are to be treated as exclusive, and the query has single points, this becomes weird, since the ranges [1, 1), (1, 1] and (1, 1) are all logically empty, but this still works :)
Unless ranges are added in ascending start order, the implementation lazily sorts and merges ranges,
when a representation of the item is required. This is typically when the query is serialized and sent
to the backend, or when trace information is written, or Item.toString() is called on the item.
Adding ranges in ascending order is much faster than not; ascending order here has the rather lax
requirement that each added interval is not completely before the current last interval.
- Author:
- jonmv
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumstatic classMultiRangeItem.NumberType<Type extends Number>Type of numbers stored used to describe the ranges stored in aMultiRangeItem.Nested classes/interfaces inherited from class com.yahoo.prelude.query.Item
Item.ItemCreator, Item.ItemType -
Field Summary
Fields inherited from class com.yahoo.prelude.query.Item
connectedBacklink, connectedItem, connectivity, DEFAULT_WEIGHT, documentFrequency, explicitSignificance, significance, uniqueID -
Method Summary
Modifier and TypeMethodDescriptionAdds the given point to this item.Adds the given range to this item.protected voidappendBodyString(StringBuilder buffer) Override to append the item body in the canonical query language of this item.clone()Returns a deep copy of this itemvoidfinal intencode(ByteBuffer buffer) booleanReturns whether this item is of the same class and contains the same state as the given item.final Item.ItemTypeReturn the enumerated type of this item.final StringgetName()Returns the name of this itemfinal intinthashCode()static <Type extends Number>
MultiRangeItem<Type>overPoints(MultiRangeItem.NumberType<Type> type, String index, MultiRangeItem.Limit startInclusive, MultiRangeItem.Limit endInclusive) A multi range item to contain the points defined by the single given index name.static <Type extends Number>
MultiRangeItem<Type>overRanges(MultiRangeItem.NumberType<Type> type, String startIndex, MultiRangeItem.Limit startInclusive, String endIndex, MultiRangeItem.Limit endInclusive) A multi range item to intersect with the ranges defined by the two given index names.voidsetIndexName(String index) Sets the index name of this itemMethods inherited from class com.yahoo.prelude.query.SimpleTaggableItem
getConnectedItem, getConnectivity, getDocumentFrequency, getSignificance, getUniqueID, hasExplicitSignificance, hasUniqueID, setConnectivity, setDocumentFrequency, setExplicitSignificance, setSignificance, setUniqueIDMethods inherited from class com.yahoo.prelude.query.Item
addAnnotation, appendHeadingString, encodeThis, getAnnotation, getBytes, getCode, getCreator, getLabel, getLanguage, getParent, getWeight, hasAnnotation, hasConnectivityBackLink, hasPrefixMatchSemantics, isFilter, isFromSpecialToken, isProtected, isRanked, isRoot, putBytes, putString, setCreator, setFilter, setFromSpecialToken, setHasUniqueID, setLabel, setLanguage, setParent, setPositionData, setProtected, setRanked, setWeight, shouldParenthesize, toString, usePositionData
-
Method Details
-
overRanges
public static <Type extends Number> MultiRangeItem<Type> overRanges(MultiRangeItem.NumberType<Type> type, String startIndex, MultiRangeItem.Limit startInclusive, String endIndex, MultiRangeItem.Limit endInclusive) A multi range item to intersect with the ranges defined by the two given index names. -
overPoints
public static <Type extends Number> MultiRangeItem<Type> overPoints(MultiRangeItem.NumberType<Type> type, String index, MultiRangeItem.Limit startInclusive, MultiRangeItem.Limit endInclusive) A multi range item to contain the points defined by the single given index name. -
addPoint
Adds the given point to this item. More efficient when each added point is not completely before the current last one. -
addRange
Adds the given range to this item. More efficient when each added range is not completely before the current last one. -
setIndexName
Description copied from class:ItemSets the index name of this item- Specified by:
setIndexNamein classItem
-
appendBodyString
Description copied from class:ItemOverride to append the item body in the canonical query language of this item. An item is usually represented by the string([itemName] [body])
The body must be appended by this method.- Specified by:
appendBodyStringin classItem
-
disclose
-
clone
Description copied from class:ItemReturns a deep copy of this item -
equals
Description copied from class:ItemReturns whether this item is of the same class and contains the same state as the given item. -
hashCode
public int hashCode() -
getItemType
Description copied from class:ItemReturn the enumerated type of this item.- Specified by:
getItemTypein classItem
-
getName
Description copied from class:ItemReturns the name of this item -
encode
-
getTermCount
public final int getTermCount()- Specified by:
getTermCountin classItem
-