2011-10-01 | Paul Boddie | raw annotate files changeset graph | Added support for duplicate keys so that an index will always refer to the first record of any group of records sharing such a key, thus ensuring that use of the index does not cause records to be missed (because some of them occur before the referenced record). |
1 #!/usr/bin/env python 2 3 from simplex import * 4 import sys, time 5 6 filename = sys.argv[1] 7 terms = sys.argv[2:] 8 9 f = open(filename) 10 tf = TextFile(f) 11 try: 12 for term in terms: 13 tf.seek(0) 14 15 t = time.time() 16 line = find_in_file(tf, term) 17 if line: 18 print "Found (at %s seconds)...\n%s" % (time.time() - t, line) 19 finally: 20 f.close() 21 22 # vim: tabstop=4 expandtab shiftwidth=4