Package amplee :: Package indexer :: Class Indexer
[hide private]
[frames] | no frames]

Class Indexer

source code

object --+
         |
        Indexer

Instance Methods [hide private]
 
__init__(self, batch=5)
This class is the manager of your index handlers.
source code
 
register(self, index)
Registers a new index handler.
source code
 
unregister(self, index)
Removes an index handler
source code
 
retrieve(self, name)
Returns the index handler per its name
source code
 
shutdown(self)
Shutdown all the associated index container
source code
 
start_daemon(self, interval=60.0)
Convenient way to start a daemon timer that will process the queue of indexable members.
source code
 
stop_daemon(self)
Stops the daemon timer
source code
 
process(self, member)
Indexes the provided member
source code
 
apply_all(self)
Unqueue up to self.batch number of members from the global queue and apply all the index handlers.
source code
dict
to_dict(self, result)
Returns the given set as a dictionnary of the form:
source code

Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __str__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, batch=5)
(Constructor)

source code 

This class is the manager of your index handlers. You register your index handlers and then you start the indexer daemon which will run at regular interval, polling from the global queue members to index.

If you have your own even mechanism you don't need to start the daemon and can simply call `apply_all` to perform the same job at will.
Parameters:
  • batch (int) - indicates how many members to dequeue during one iteration of indexing.
Overrides: object.__init__

unregister(self, index)

source code 
Removes an index handler
Parameters:
  • index (BaseIndex) - instance of the index to remove.

retrieve(self, name)

source code 
Returns the index handler per its name
Parameters:
  • name (string) - name of the index handler

start_daemon(self, interval=60.0)

source code 

Convenient way to start a daemon timer that will process the queue of indexable members.

Note that if you try to start it before it was stopped an error will be raised.
Parameters:
  • interval (float) - frequency at which the indexer is applied.

process(self, member)

source code 
Indexes the provided member
Parameters:

apply_all(self)

source code 

Unqueue up to self.batch number of members from the global queue and apply all the index handlers.

A handler only needs to be a class that implements a method named update() and taking the member as its unique parameter.

to_dict(self, result)

source code 

Returns the given set as a dictionnary of the form:

{collection_name: [member_ids]}
Parameters:
  • result (set) - as returned by one of the indexer
Returns: dict
representation as a dictionary of the set of results provided