public abstract class Index extends Object implements Closeable, Flushable
Arbitrary properties can be defined in the index properties files, and in particular, properties are used to record index statistics and the contructor type and values of various index objects.
The Index will apply methods on specially marked interfaces. Currently, the only interface supported is IndexConfigurable. Moreover, structures implementing java.io.Closeable will have their close method called when the Index is closed.
Modifier and Type | Class and Description |
---|---|
protected class |
Index.UpdatingCollectionStatistics
This collection statistics parses the associated index properties for
each call.
|
Modifier and Type | Field and Description |
---|---|
protected boolean |
dirtyProperties
Have the properties of this index changed, suggesting a flush() is
necessary when closing
|
protected static Class<?>[] |
EMPTY_CLASS_ARRAY
empty class array
|
protected static String |
lastLoadError |
protected static org.slf4j.Logger |
logger
The logger used
|
protected static int |
MINIMUM_INDEX_TERRIER_VERSION |
protected Properties |
properties
properties of this index
|
protected static String |
PROPERTIES_SUFFIX |
protected static boolean |
RETRIEVAL_LOADING_PROFILE |
Modifier | Constructor and Description |
---|---|
|
Index()
Empty Index constructor - this should never be used!
Use Index.createIndex() instead
|
protected |
Index(long a,
long b,
long c)
A constructor for child classes that doesnt open the file
|
Modifier and Type | Method and Description |
---|---|
void |
addIndexStructure(String structureName,
Class<?> className,
Class<?>[] paramTypes,
String[] paramValues)
tell the index about a new index structure it provides.
|
void |
addIndexStructure(String structureName,
String className)
add an index structure to this index.
|
void |
addIndexStructure(String structureName,
String className,
String[] paramTypes,
String[] paramValues)
add an index structure to this index.
|
void |
addIndexStructure(String structureName,
String className,
String paramTypes,
String paramValues)
add an index structure to this index.
|
void |
addIndexStructureInputStream(String structureName,
Class<?> className,
Class<?>[] paramTypes,
String[] paramValues)
tell the index about a new input stream index structure it provides.
|
void |
addIndexStructureInputStream(String structureName,
String className)
tell the index about a new input stream index structure it provides.
|
void |
addIndexStructureInputStream(String structureName,
String className,
String[] paramTypes,
String[] paramValues)
tell the index about a new input stream index structure it provides.
|
void |
addIndexStructureInputStream(String structureName,
String className,
String paramTypes,
String paramValues)
tell the index about a new input stream index structure it provides.
|
static boolean |
allExists(String... files)
returns true if all named files exist
|
abstract void |
close()
Closes the data structures of the index.
|
static IndexOnDisk |
createIndex()
Constructs a new Index object.
|
static IndexOnDisk |
createIndex(String path,
String prefix)
Factory method for load an index.
|
static IndexOnDisk |
createNewIndex(String path,
String prefix)
Factory method create a new index.
|
static boolean |
existsIndex(String path,
String prefix)
Returns true if it is likely that an index exists at the specified
location
|
abstract void |
flush()
Write any dirty data structures down to disk
|
abstract CollectionStatistics |
getCollectionStatistics()
Get the collection statistics
|
abstract PostingIndex<?> |
getDirectIndex()
Return the DirectIndex associated with this index
|
abstract DocumentIndex |
getDocumentIndex()
Return the DocumentIndex associated with this index
|
int |
getEnd()
Returns the last docid in this index
|
static boolean |
getIndexLoadingProfileAsRetrieval()
Get RETRIEVAL_LOADING_PROFILE
|
String |
getIndexProperty(String key,
String defaultValue)
get an arbitrary property in the index
|
IndexRef |
getIndexRef() |
abstract Object |
getIndexStructure(String structureName)
Obtains the named index structure, using an already loaded one if
possible.
|
abstract Object |
getIndexStructureInputStream(String structureName)
Return the input stream associated with the specified structure of this
index
|
int |
getIntIndexProperty(String key,
int defaultValue)
get an arbitrary int property from the index
|
abstract PostingIndex<?> |
getInvertedIndex()
Returns the InvertedIndex to use for this index
|
static String |
getLastIndexLoadError()
Returns the last warning given by an index being loaded.
|
abstract Lexicon<String> |
getLexicon()
Return the Lexicon associated with this index
|
abstract MetaIndex |
getMetaIndex()
Get the Meta Index structure
|
Properties |
getProperties()
Get the index properties
|
int |
getStart()
Returns the first docid in this index
|
boolean |
hasIndexStructure(String structureName)
Does this index have an index structure with the specified name?
|
boolean |
hasIndexStructureInputStream(String structureName)
Does this index have an index structure input stream with the specified
name?
|
protected static String |
join(String[] input,
String joinString)
joins a series of strings together with a delimiter
|
static void |
main(String[] args)
main
|
static void |
setIndexLoadingProfileAsRetrieval(boolean yes)
Set RETRIEVAL_LOADING_PROFILE
|
void |
setIndexProperty(String key,
String value)
set an arbitrary property in the index
|
abstract String |
toString()
Returns a String representation of this index
|
protected static final int MINIMUM_INDEX_TERRIER_VERSION
protected static final String PROPERTIES_SUFFIX
protected static boolean RETRIEVAL_LOADING_PROFILE
protected static final org.slf4j.Logger logger
protected static String lastLoadError
protected static final Class<?>[] EMPTY_CLASS_ARRAY
protected final Properties properties
protected boolean dirtyProperties
public Index()
protected Index(long a, long b, long c)
public static boolean allExists(String... files)
public static IndexOnDisk createIndex()
public static IndexOnDisk createIndex(String path, String prefix)
path
- String the path in which the data structures will be created.prefix
- String the prefix of the files to be created.public static IndexOnDisk createNewIndex(String path, String prefix)
path
- String the path in which the data structures will be created.prefix
- String the prefix of the files to be created.public static boolean existsIndex(String path, String prefix)
path
- prefix
- public static boolean getIndexLoadingProfileAsRetrieval()
public static String getLastIndexLoadError()
protected static String join(String[] input, String joinString)
public static void main(String[] args)
args
- public static void setIndexLoadingProfileAsRetrieval(boolean yes)
yes
- public void addIndexStructure(String structureName, Class<?> className, Class<?>[] paramTypes, String[] paramValues)
public void addIndexStructure(String structureName, String className)
structureName
- className
- public void addIndexStructure(String structureName, String className, String paramTypes, String paramValues)
public void addIndexStructure(String structureName, String className, String[] paramTypes, String[] paramValues)
public void addIndexStructureInputStream(String structureName, Class<?> className, Class<?>[] paramTypes, String[] paramValues)
public void addIndexStructureInputStream(String structureName, String className)
public void addIndexStructureInputStream(String structureName, String className, String paramTypes, String paramValues)
public void addIndexStructureInputStream(String structureName, String className, String[] paramTypes, String[] paramValues)
public abstract void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
IOException
public abstract void flush() throws IOException
flush
in interface Flushable
IOException
public abstract CollectionStatistics getCollectionStatistics()
public abstract PostingIndex<?> getDirectIndex()
public abstract DocumentIndex getDocumentIndex()
public String getIndexProperty(String key, String defaultValue)
key
- Key of the property to getdefaultValue
- value of the property to use if property is not setpublic IndexRef getIndexRef()
public abstract Object getIndexStructure(String structureName)
structureName
- name of the required structurepublic abstract Object getIndexStructureInputStream(String structureName)
structureName
- The name of the structure of which you want the inputstream.
Eg "lexicon"public int getIntIndexProperty(String key, int defaultValue)
public abstract PostingIndex<?> getInvertedIndex()
public abstract Lexicon<String> getLexicon()
public abstract MetaIndex getMetaIndex()
public Properties getProperties()
public boolean hasIndexStructure(String structureName)
structureName
- name of the required structurepublic boolean hasIndexStructureInputStream(String structureName)
structureName
- name of the required structurepublic void setIndexProperty(String key, String value)
key
- Key to of the property to setvalue
- Value of the property to setpublic abstract String toString()
public int getStart()
public int getEnd()
Terrier Information Retrieval Platform 5.1. Copyright © 2004-2019, University of Glasgow