Ticket #317: xaptest.py
File xaptest.py, 524 bytes (added by , 16 years ago) |
---|
Line | |
---|---|
1 | #!/usr/bin/env python |
2 | |
3 | import os |
4 | import sys |
5 | import xapian |
6 | |
7 | dbpath = 'testdb' |
8 | |
9 | db = xapian.WritableDatabase(dbpath, xapian.DB_CREATE_OR_OPEN) |
10 | errcount = 0 |
11 | |
12 | for a in xrange(0, 100000): |
13 | doc = xapian.Document() |
14 | for b in xrange(1000): |
15 | doc.add_posting(str((a * b) % 1000), b) |
16 | try: |
17 | db.add_document(doc) |
18 | if a % 10 == 0: |
19 | print a |
20 | if a % 1000 == 0: |
21 | db.flush() |
22 | except Exception, e: |
23 | print e |
24 | errcount += 1 |
25 | if errcount >= 2: |
26 | raise |