[Xapian-discuss] Behavior of WritableDatabase against an "add_database"

Rafael SDM Sierra sdm at underlinux.com.br
Mon Nov 6 20:37:45 GMT 2006


Re-reading your mail for the 3th time, I finally understand something...oO"

On 11/4/06, James Aylett <james-xapian at tartarus.org> wrote:
>
> On Fri, Nov 03, 2006 at 10:33:34PM -0200, Rafael SDM Sierra wrote:
>
> > But, still the suggest of implement some load balance feature in
> > some future version (2.0 maybe...oO)
>
> I don't think you can load balance like this because of locking (I'm
> not even convinced you *can* load balance on write, but I'm probably
> wrong). However you can cluster like this, which may be what you mean.


Yes, is it that I mean say (clustering)

----------------------------------------------------------------------
> db = xapian.WritableDatabase(discriminant_functor)
> db.add_database(xapian.remote_open_writable('192.168.0.1',6666))
> db.add_database(xapian.remote_open_writable('192.168.0.2',6666))
> ----------------------------------------------------------------------


[cut]

----------------------------------------------------------------------
> def add_document(doc, dbs): # dbs is a list
>     discrim = doc.get_field('path')[:4]
>     d_to_db = { '/usr': 1, '/var': 2, '/hom/': 3 }
>     db_idx = d_to_db.get(discrim, 0)
>     dbs[db_idx].add_document(doc)
> ----------------------------------------------------------------------
>

Reading these 2 codes, I think (just replying and thinking, no tests) in
some thing like this:

[code]
class WritableDatabase(xapian.WritableDatabase):
    def add_database(*args, **kwargs):
        # Store the database in a list/set/dict/anything

    def add_document(doc):
        # Using the round-robin method chose an database and store the
document there

    def replace_document(docid,doc): #I don't remember the correct sort of
parameters (just an brainstorm)
        for database in list_of_databases:
            # search for the correct database (the docid does not matter,
            # becouse have lots of equals docid in diferents databases)
       # if it was founded, replace the document

    def remove_document(doc): # Now we need the document, not the docid
       # search for the database and delete the document

[/code]

Well....is something like this....
-- 
SDM Underlinux
Garimpar.com
--
PEP-8
Só existem 3 tipos de pessoas no mundo, as que sabem contar, e as que não
sabem.
CPFL - Compania Piratininga de FALTA de Luz (6 vezes em 5 dias!!)


More information about the Xapian-discuss mailing list