public class KeyIndex
extends java.lang.Object
The index can support a mixture of atomic keys of different types; there is no error caused by comparing values of different types. This relies on the fact that XPathComparable values are identical for comparable values (e.g. integers and doubles), and distinct otherwise.
With the XSLT xsl:key construct, untypedAtomic values are treated as strings. However, this structure is also used to support internally-generated keys with general comparison semantics, where untyped values are converted to the type of the other operand. To enable this to work, we maintain a list of all untypedAtomic keys present in the index; and if a search is made for some type like xs:date, we then go through this list converting each untypedAtomic value to a date and indexing it as such. In principle this can happen for an arbitrary number of data types, though it is unlikely in practice because not many types have overlapping lexical spaces.
Modifier and Type | Class and Description |
---|---|
static class |
KeyIndex.Status |
Constructor and Description |
---|
KeyIndex(boolean isRangeKey) |
Modifier and Type | Method and Description |
---|---|
void |
buildIndex(KeyDefinitionSet keySet,
TreeInfo doc,
XPathContext context)
Build the index for a particular document for a named key
|
java.util.List<NodeInfo> |
get(AtomicValue soughtValue)
Get the nodes with a given key value
|
java.util.List<NodeInfo> |
getComposite(SequenceIterator<?> soughtValue)
Get the nodes with a given composite key value
|
KeyIndex.Status |
getStatus()
Ask if the index is under construction
|
java.util.Map<AtomicMatchKey,java.util.List<NodeInfo>> |
getUnderlyingMap()
Get the underlying map
|
boolean |
isCreatedInThisThread()
Ask if the index was created in the current thread
|
boolean |
isEmpty()
Ask whether the index is empty
|
void |
reindexUntypedValues(BuiltInAtomicType type)
Re-index untyped atomic values after conversion to a specific type.
|
void |
setStatus(KeyIndex.Status status)
Say whether the index is under construction
|
public java.util.Map<AtomicMatchKey,java.util.List<NodeInfo>> getUnderlyingMap()
public boolean isCreatedInThisThread()
public KeyIndex.Status getStatus()
public void setStatus(KeyIndex.Status status)
status
- public void buildIndex(KeyDefinitionSet keySet, TreeInfo doc, XPathContext context) throws XPathException
keySet
- The set of key definitions with this namedoc
- The source document in questioncontext
- The dynamic contextXPathException
- if a dynamic error is encounteredpublic void reindexUntypedValues(BuiltInAtomicType type) throws XPathException
type
- the type to which untyped atomic values should be convertedXPathException
- if conversion of any untyped atomic value to the requested key type failspublic boolean isEmpty()
public java.util.List<NodeInfo> get(AtomicValue soughtValue) throws XPathException
soughtValue
- The required key valueXPathException
- if a dynamic error is encounteredpublic java.util.List<NodeInfo> getComposite(SequenceIterator<?> soughtValue) throws XPathException
soughtValue
- The required composite key valueXPathException
- if a dynamic error is encounteredCopyright (c) 2004-2020 Saxonica Limited. All rights reserved.