Overview | File | Class | Tree | Index | Help
| Jala 1.2
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## Class jala.IndexManager

    Object
       |
       +--jala.IndexManager

class jala.IndexManager

This class basically sits on top of a helma.Search.Index instance and provides methods for adding, removing, optimizing and rebuilding the underlying index. All methods except rebuilding are executed asynchronously using an internal queue that contains jobs created for each call of add/remove/optimize. Rebuilding is somehow different as it puts this manager into rebuilding mode where all following calls of add/remove/optimize are queued, but the queue is not flushed until rebuilding has finished. This ensures that objects that have been modified during a rebuilding process are re-indexed properly afterwards.
Defined in IndexManager.js
See:

- helma.Search.createIndex

Nested Class Summary
`<static class>` | `jala.IndexManager.Job`

Field Summary
`<static> <final> Number` | `MAXTRIES` Constant defining the maximum number of tries to add/remove an object to/from the underlying index.
`<static> <final> Number` | `NORMAL` Constant defining normal mode of this index manager.
`<static> <final> Number` | `OPTIMIZE_INTERVAL` Constant defining the number of changes in the underlying index before it should be optimized.
`<static> <final> Number` | `REBUILDING` Constant defining rebuilding mode of this index manager.

Constructor Summary
`jala.IndexManager (<String> name, <helma.File> dir, <String> lang)` Constructs a new IndexManager object.

Method Summary
`void` | `add(<helma.Search.Document> doc, <Boolean> force)` Adds a document object to the underlying index.
`Number` | `getCurrentIndexVersion()` Returns the version number of the underlying index.
`helma.Search.Index` | `getIndex()` Returns the underlying index.
`String` | `getName()` Returns the name of the index manger, which is equal to the name of the underlying index
`java.util.LinkedList` | `getQueue()` Returns the queue this index manager is using.
`Array` | `getSegmentInfos()` Returns an Array containing objects, where each one contains information about an index segment in two properties: "name" is the file name of the segment, and "docCount" contains the number of documents in this segment.
`Number` | `getStatus()` Returns the status of this manager.
`Number` | `getVersion()` Returns the current version of this index manager
`Boolean` | `hasOptimizingJob()` Returns true if the underlying index is currently optimized.
`Boolean` | `hasWorker()` Returns true if a worker has been initialized and it's still alive.
`Boolean` | `isRebuilding()` Returns true if the underlying index is currently rebuilding.
`Boolean` | `needsOptimize()` Returns true if the index should be optimized.
`void` | `optimize(<Boolean> force)` Optimizes the underlying index.
`void` | `remove(<Number> id, <Boolean> force)` Removes all entries with the Id passed as argument from the underlying index.
`void` | `setStatus(<Number> s)` Modifies the status of this manager, which has implications on how index modifying jobs are handled.
`void` | `updateVersion()` Updates the internal version property of this index manager to the current version of the underlying index.

Field Detail

### MAXTRIES

    <static> <final> Number MAXTRIES

Constant defining the maximum number of tries to add/remove an object to/from the underlying index.

See Also:
  Constant Field Values

### NORMAL

    <static> <final> Number NORMAL

Constant defining normal mode of this index manager.

See Also:
  Constant Field Values

### OPTIMIZE_INTERVAL

    <static> <final> Number OPTIMIZE_INTERVAL

Constant defining the number of changes in the underlying index before it should be optimized.

See Also:
  Constant Field Values

### REBUILDING

    <static> <final> Number REBUILDING

Constant defining rebuilding mode of this index manager.

See Also:
  Constant Field Values

Constructor Detail

### jala.IndexManager

    jala.IndexManager(<String> name, <helma.File> dir, <String> lang)

Constructs a new IndexManager object.

Parameters:

`name` - The name of the index, which is the name of the directory the index already resides or will be created in.

`dir` - The base directory where this index's directory is already existing or will be created in.

`lang` - The language of the documents in this index. This leads to the proper Lucene analyzer being used for indexing documents.

See:

- helma.Search.createIndex

Method Detail

### add

    void add(<helma.Search.Document> doc, <Boolean> force)

Adds a document object to the underlying index. This is done by adding a new job to the internal queue and starting a new worker thread to process it (if there isn't already a worker being busy processing the queue). Adding an object to the index also means that all documents with the same Id will be removed before.

Parameters:

`doc` - The document object that should be added to the underlying index.

`force` - (optional) If true the object will be added instantly to the index without any check if the index is locked or not, so use this option with caution. Normally this option should never be set manually.

See:

- helma.Search.Document

### getCurrentIndexVersion

    Number getCurrentIndexVersion()

Returns the version number of the underlying index.

Returns:

The current version number of the underlying index.

### getIndex

    helma.Search.Index getIndex()

Returns the underlying index.

Returns:

The index this queue is working on.

### getName

    String getName()

Returns the name of the index manger, which is equal to the name of the underlying index

Returns:

The name of the index manager

### getQueue

    java.util.LinkedList getQueue()

Returns the queue this index manager is using.

Returns:

The queue.

### getSegmentInfos

    Array getSegmentInfos()

Returns an Array containing objects, where each one contains information about an index segment in two properties: "name" is the file name of the segment, and "docCount" contains the number of documents in this segment.

Returns:

An Array containing segment informations.

### getStatus

    Number getStatus()

Returns the status of this manager.

Returns:

The status of this index manager.

See:

- NORMAL
- REBUILDING

### getVersion

    Number getVersion()

Returns the current version of this index manager

Returns:

The current version of this index manager

### hasOptimizingJob

    Boolean hasOptimizingJob()

Returns true if the underlying index is currently optimized.

Returns:

True in case the index is optimized, false otherwise.

### hasWorker

    Boolean hasWorker()

Returns true if a worker has been initialized and it's still alive.

Returns:

True if a worker is running, false otherwise.

### isRebuilding

    Boolean isRebuilding()

Returns true if the underlying index is currently rebuilding.

Returns:

True in case the index is rebuilding, false otherwise.

### needsOptimize

    Boolean needsOptimize()

Returns true if the index should be optimized. This is done by comparing the version number of this IndexManager with the one of the underlying index. If it exceeds IndexManager.OPTIMIZE_INTERVAL the index needs to be optimized.

Returns:

True in case the underlying should be optimized, false otherwise

### optimize

    void optimize(<Boolean> force)

Optimizes the underlying index. Optimizing is done asynchronously, so this method returns immediately, but the job itself will be processed as soon as possible. Calling this method multiple times doesn not lead to multiple optimization, as the job cannot be added to the queue if there is already one.

Parameters:

`force` - If true the index is optimized immediately, without any check whether the index is locked or not, so use this option with caution.

See:

- ()

### remove

    void remove(<Number> id, <Boolean> force)

Removes all entries with the Id passed as argument from the underlying index. Removing is done by adding a new job to the internal queue, which in turn is processed asynchronously by a worker thread.

Parameters:

`id` - The Id of the document object(s) to remove from the underlying index.

`force` - (optional) If true the removal is done instantly. In this case no checking is done if the index is locked, so use this option with caution as it might lead to index corruption.

### setStatus

    void setStatus(<Number> s)

Modifies the status of this manager, which has implications on how index modifying jobs are handled. If the status is REBUILDING, all jobs are queued until the status is set back to NORMAL.

Parameters:

`s` - The new status of this manager.

See:

- NORMAL
- REBUILDING

### updateVersion

    void updateVersion()

Updates the internal version property of this index manager to the current version of the underlying index.

Overview | File | Class | Tree | Index | Help
| Jala 1.2
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Documentation generated by JSDoc on Tue May 29 10:26:15 2007