File: mxBeeBase.html

package info (click to toggle)
egenix-mx-base 2.0.6-1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 3,028 kB
  • ctags: 4,762
  • sloc: ansic: 14,965; python: 11,739; sh: 313; makefile: 117
file content (1171 lines) | stat: -rw-r--r-- 28,073 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
<HEAD>
    <TITLE>mxBeeBase - On-disk B+Tree Based Database Kit</TITLE>
    <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
    <STYLE TYPE="text/css">
      p { text-align: justify; }
      ul.indent { }
      body { }
    </STYLE>
</HEAD>

  <BODY TEXT="#000000" BGCOLOR="#FFFFFF" LINK="#0000EE" VLINK="#551A8B" ALINK="#FF0000">

    <HR NOSHADE WIDTH="100%">
    <H2>mxBeeBase - On-disk B+Tree Based Database Kit</H2>

    <HR SIZE=1 NOSHADE WIDTH="100%">
    <TABLE WIDTH="100%">
      <TR>
	<TD>
	  <SMALL>
	    Interface (
	    <A HREF="#BeeDict">BeeDict</A> :
	    <A HREF="#BeeStorage">BeeStorage</A> :
	    <A HREF="#BeeIndex">BeeIndex</A> )
	    <A HREF="#Examples">Examples</A> :
	    <A HREF="#Structure">Structure</A> :
	    <A HREF="#Support">Support</A> :
            <A HREF="http://www.egenix.com/files/python/eGenix-mx-Extensions.html#Download-mxBASE"><B>Download</B></A> :
	    <A HREF="#Copyright">Copyright &amp; License</A> :
	    <A HREF="#History">History</A> :
	    <A HREF="" TARGET="_top">Home</A>
	</SMALL>
	</TD>
	<TD ALIGN=RIGHT VALIGN=TOP>
	  <SMALL>
	    <FONT COLOR="#FF0000">Version 2.0.2</FONT>
	  </SMALL>
	</TD>
    </TABLE>
    <HR SIZE=1 NOSHADE WIDTH="100%">

    <H3>Introduction</H3>

    <UL CLASS="indent">

      <HR>

	<P>
	  <B>XXX This documentation is unfinished...</B> the software
	  itself has been in use for quite a while, but the
	  documentation still needs to be completed. For now, all I
	  can offer you is to read the code which is well documented.

	<HR>

	<P>
	  mxBeeBase is a high performance construction kit for disk
	  based indexed databases. It offers components which you can
	  plug together to easily build your own custom mid-sized
	  databases (the current size limit is
	  <CODE>sizeof(long)</CODE> which gives you an address range
	  of around 2GB on 32-bit platforms).

	<P>
	  The two basic building blocks in mxBeeBase are
	  <I>storage</I> and <I>index</I>. Storage is implemented as
	  variable record length data storage with integrated data
	  protection features, automatic data recovery and locking for
	  multi process access. Indexes use a high performance
	  optimized B+Tree implementation built on top of <A
	  HREF="http://epaperpress.com/">Thomas
	  Niemann</A>'s Cookbook B+Tree implementation.

	<P>
	  <U>Note:</U> Due to the file locking mechanism currently
	  used in mxBeeBase, the package will only work on systems
	  which support symbolic links, e.g. Windows does not support
	  symbolic links and therefore parts of mxBeeBase don't work
	  on that platform.

    </UL><!--CLASS="indent"-->

    <A NAME="BeeDict">

    <H3>BeeDict Module</H3>

    <UL CLASS="indent">

	<P>
	  The BeeDict module provides two high level on-disk
	  dictionary implementations. The first (<I>BeeDict</I>) can
	  work with arbitrary hashable key objects, while the second
	  (<I>BeeStringDict</I>) uses limited sized strings as basis
	  providing slightly better performance. Both variants need
	  pickleable Python objects as keys and values.

	<P>
	  Data transfer to and from the dictionaries is done in the
	  same way as for in-memory dictionaries, e.g. <CODE>d['key']
	  = 1; print d['key']; del d['key]</CODE>, so usage should be
	  transparent to Python programs using either in-memory or
	  on-disk dictionaries. Not all dictionary methods are
	  understood though.

    <H4>BeeDict Objects</H4>

    <UL CLASS="indent">

	<P>
	  BeeDict objects are on-disk dictionaries which use a
	  hash-to-address index.  Both Keys and values must be
	  pickleable and can have arbitrary size (keys shouldn't be
	  too long though); keys have to be hashable.

	<P>
	  Hash collisions are treated by sequential reads of all
	  records with the same hash value and testing for equality of
	  keys. This can be expensive ! 

	<P>
	  BeeDicts use a BeeStorage.BeeKeyValueStorage instance as
	  storage object and a BeeIndex.BeeIntegerIndex instance as
	  index object.

	<P>
	  BeeDict objects are constructed using:

	<P><DL>

	  <DT><CODE><FONT COLOR="#000099">
		BeeDict(name,min_recordsize=0,readonly=0,recover=0,
		autocommit=0,validate=0)</FONT></CODE></DT>

	  <DD>
	    Create an instance using <CODE>name</CODE> as basename for
	    the data and index files. Two files will be created:
	    name.dat and name.idx.

	    <P>
	      <CODE>min_recordsize</CODE> is passed to the BeeStorage
	      as indicator of the minimum size for data
	      records. <CODE>readonly</CODE> can be set to true to
	      open the files in read-only mode, preventing any disk
	      modifications.

	    <P>
	      To open the dictionary in recovery mode, pass a keyword
	      <CODE>recover=1</CODE>. Then run <CODE>.recover()</CODE>
	      and reopen using the normal settings. The
	      <CODE>AutoRecover()</CODE> wrapper can take care of this
	      action for you automatically.

	    <P>
	      If <CODE>autocommit</CODE> is true the cache control
	      will do an automatic <CODE>.commit()</CODE> whenever the
	      transaction log overflows.
            
	    <P>
	      If <CODE>validate</CODE> is true, the dictionary will
	      run a validation check after having successfully opened
	      storage and index.  <CODE>RecreateIndexError</CODE> or
	      <CODE>RecoverError</CODE> exceptions could be raised in
	      case inconsistencies are found.

	  </DD><P>

	</DL>

    </UL><!--CLASS="indent"-->

    <H5>BeeDict Instance Methods</H5>

    <UL CLASS="indent">
      
	<P>
	  BeeDict objects have the following methods:

	<P><DL>

	  <DT><CODE><FONT COLOR="#000099">
		flush()</FONT></CODE></DT>

	  <DD>
	    Flush buffers to disk.
	  </DD><P>

	  <DT><CODE><FONT COLOR="#000099">
		close()</FONT></CODE></DT>

	  <DD>
	    Flush buffers and close.
	    <P>
	      This does not issue a <CODE>.commit()</CODE>, so the
	      current transaction is rolled back.

	  </DD><P>

	  <DT><CODE><FONT COLOR="#000099">
		commit()</FONT></CODE></DT>

	  <DD>
	    Commits all changes and starts a new transaction.

	  </DD><P>

	  <DT><CODE><FONT COLOR="#000099">
		rollback()</FONT></CODE></DT>

	  <DD>
	    Rolls back the current transaction. All changes are undone.

	  </DD><P>

	  <DT><CODE><FONT COLOR="#000099">
		changed()</FONT></CODE></DT>

	  <DD>
	    Return true in case the current transaction includes changes
            to the database, false otherwise.

	  </DD><P>

	  <DT><CODE><FONT COLOR="#000099">
		has_key()</FONT></CODE></DT>

	  <DD>
	    Check if the dictionary has an item indexed by key.
	    <P>
	      Successfully found items are put in the cache for fast
	      subsequent access.

	  </DD><P>

	  <DT><CODE><FONT COLOR="#000099">
		get(key,default=None)</FONT></CODE></DT>

	  <DD>
	    Get item indexed by key from the dictionary or default if
	    no such item exists.
	    <P>
	      This first tries to read the item from cache and reverts
	      to the disk storage if it is not found.

	  </DD><P>

	  <DT><CODE><FONT COLOR="#000099">
		cursor(key,default=None)</FONT></CODE></DT>

	  <DD>
	    Return a BeeDictCursor instance for the dictionary.
	    <P>
	      In case the key is not found, default is returned
	      instead.
	    <P>
	      Note that cursors operate with the data on disk meaning
	      that any uncommitted changes will not be seen by the
	      cursor.

	  </DD><P>

	  <DT><CODE><FONT COLOR="#000099">
		garbage()</FONT></CODE></DT>

	  <DD>
	    Determine the amount of garbage in bytes that has accumulated
            in the storage file.
	    <P>
	      This amount would be freed if .collect() were run.

	  </DD><P>

	  <DT><CODE><FONT COLOR="#000099">
		collect()</FONT></CODE></DT>

	  <DD>
	    Run the storage garbage collector.
	    <P>
	      Storage collection can only be done for writeable
	      dictionaries and then only if the current transaction
	      does not contain any pending changes.
	    <P>
	      This can take a while depending on the size of the
	      dictionary.

	  </DD><P>

	  <DT><CODE><FONT COLOR="#000099">
		recover()</FONT></CODE></DT>

	  <DD>
	    Recover all valid records and recreate the index.

	  </DD><P>

	  <DT><CODE><FONT COLOR="#000099">
		keys()</FONT></CODE></DT>

	  <DD>
	    Return a list of keys.
	    <P>
	      The method does not load any data into the cache, but
	      does take notice of uncommitted changes.

	  </DD><P>

	  <DT><CODE><FONT COLOR="#000099">
		values()</FONT></CODE></DT>

	  <DD>
	    Return a list of values.
	    <P>
	      The method does not load any data into the cache, but
	      does take notice of uncommitted changes.

	  </DD><P>

	  <DT><CODE><FONT COLOR="#000099">
		items()</FONT></CODE></DT>

	  <DD>
	    Return a list of items.
	    <P>
	      The method does not load any data into the cache, but
	      does take notice of uncommitted changes.

	  </DD><P>

	</DL>

    </UL><!--CLASS="indent"-->

    <H5>BeeDict Instance Attributes</H5>

    <UL CLASS="indent">
      
	<P>
	  BeeDict objects have the following read-only attributes:

	<P><DL>

	  <DT><CODE><FONT COLOR="#000099">
		name</FONT></CODE></DT>

	  <DD>
	    Basenname of the dictionary. The implementation uses two
	    files for the on-disk representation: name.dat and name.idx.
	  </DD><P>

	  <DT><CODE><FONT COLOR="#000099">
		closed</FONT></CODE></DT>

	  <DD>
	    Closed flag.
	  </DD><P>

	  <DT><CODE><FONT COLOR="#000099">
		readonly</FONT></CODE></DT>

	  <DD>
	    Read-only flag.
	  </DD><P>

	  <DT><CODE><FONT COLOR="#000099">
		autocommit</FONT></CODE></DT>

	  <DD>
	    Autocommit flag.
	  </DD><P>

	  <DT><CODE><FONT COLOR="#000099">
		FirstKey</FONT></CODE></DT>

	  <DD>
	    Special key object useable to represent the first key in
	    the (sorted) B+Tree index.
	    
	  </DD><P>

	  <DT><CODE><FONT COLOR="#000099">
		LastKey</FONT></CODE></DT>

	  <DD>
	    Special key object useable to represent the last key in
	    the (sorted) B+Tree index.
	    
	  </DD><P>

	</DL>

    </UL><!--CLASS="indent"-->

    <H4>BeeDictCursor Objects</H4>

    <UL CLASS="indent">

	<P>
	  BeeDickCursor objects are intended to iterate over the
	  database one item at a time without the need to read all
	  keys. You can then read/write to the current cursor position
	  and thus modify the dictionary in place.

	<P>
	  Note that modifying the targetted dictionary while using a
	  cursor can cause the cursor to skip new entries or fail due
	  to deleted items. Especially deleting the key to which the
	  cursor currently points can cause errors to be raised.  In
	  all other cases, the cursor will be repositioned.

	<P>
	  BeeDictCursor objects are constructed using the BeeDict
	  <CODE>.cursor()</CODE> method.

    </UL><!--CLASS="indent"-->

    <H5>BeeDictCursor Instance Methods</H5>

    <UL CLASS="indent">
      
	<P>
	  BeeDictCursor objects have the following methods:

	<P><DL>

	  <DT><CODE><FONT COLOR="#000099">
		position(key,value=None)</FONT></CODE></DT>

	  <DD>
	    Position the index cursor to index[key]. If value is given,
            index[key] == value is assured.
	    <P>
	      key may also be FirstKey or LastKey (in which case value
	      has to be None).

	  </DD><P>

	  <DT><CODE><FONT COLOR="#000099">
		next()</FONT></CODE></DT>

	  <DD>
	    Moves to the next entry in the dictionary.
	    <P>
	      Returns true on success, false if the end-of-data has
	      been reached.

	  </DD><P>

	  <DT><CODE><FONT COLOR="#000099">
		prev()</FONT></CODE></DT>

	  <DD>
	    Moves to the previous entry in the dictionary.
	    <P>
	      Returns true on success, false if the end-of-data has
	      been reached.

	  </DD><P>

	  <DT><CODE><FONT COLOR="#000099">
		read()</FONT></CODE></DT>

	  <DD>
	    Reads the object from the dict to which the cursor
            currently points.

	  </DD><P>

	  <DT><CODE><FONT COLOR="#000099">
		read_key()</FONT></CODE></DT>

	  <DD>
	    Reads the key object from the dict to which the cursor
	    currently points.

	  </DD><P>

	  <DT><CODE><FONT COLOR="#000099">
		write()</FONT></CODE></DT>

	  <DD>
	    Writes the object to the dict under the key to which
            the cursor currently points.
	    <P>
	      The new data is not written to disk until the
	      dictionary's current transaction is committed.

	  </DD><P>

	</DL>

    </UL><!--CLASS="indent"-->

    <H5>BeeDictCursor Instance Attributes</H5>

    <UL CLASS="indent">
      
	<P>
	  BeeDictCursor don't have any useful attributes. Use the instance
	  methods to query the key and value objects.

    </UL><!--CLASS="indent"-->

    <H4>BeeStringDict Objects</H4>

    <UL CLASS="indent">

	<P>
	  BeeStringDict objects are on-disk dictionaries which use a
	  limited size string to address index.  Values must be
	  pickleable and can have arbitrary size.

	<P>
	  Since hash collisions cannot occur this dictionary type may
	  have some performance advantages over the standard BeeDict
	  dictionary.

	<P>
	  BeeStringDict objects are constructed using:

	<P><DL>

	  <DT><CODE><FONT COLOR="#000099">
		BeeStringDict(name,keysize=10,min_recordsize=0,readonly=0,
		recover=0,autocommit=0,validate=0)</FONT></CODE></DT>

	  <DD>
	    Create an instance using <CODE>name</CODE> as basename for
	    the data and index files. Two files will be created:
	    name.dat and name.idx.

	    <P>
	      <CODE>keysize</CODE> gives the maximal size of the
	      strings used as index keys. <CODE>min_recordsize</CODE>
	      is passed to the BeeStorage as indicator of the minimum
	      size for data records. <CODE>readonly</CODE> can be set
	      to true to open the files in read-only mode, preventing
	      any disk modifications.

	    <P>
	      To open the dictionary in recovery mode, pass a keyword
	      <CODE>recover=1</CODE>. Then run <CODE>.recover()</CODE>
	      and reopen using the normal settings. The
	      <CODE>AutoRecover()</CODE> wrapper can take care of this
	      action for you automatically.

	    <P>
	      If <CODE>autocommit</CODE> is true the cache control
	      will do an automatic <CODE>.commit()</CODE> whenever the
	      transaction log overflows.
            
	    <P>
	      If <CODE>validate</CODE> is true, the dictionary will
	      run a validation check after having successfully opened
	      storage and index.  <CODE>RecreateIndexError</CODE> or
	      <CODE>RecoverError</CODE> exceptions could be raised in
	      case inconsistencies are found.

	    <P>
	      Note that the keysize is currently not stored in the
	      dictionary itself -- you'll have to store this
	      information in some other form. This may change in
	      future versions.

	  </DD><P>

	</DL>

    </UL><!--CLASS="indent"-->

    <H5>BeeStringDict Instance Methods</H5>

    <UL CLASS="indent">
      
	<P>
	  BeeStringDict objects have the following methods:

	<P><DL>

	  <DT><CODE><FONT COLOR="#000099">
		commit()</FONT></CODE></DT>

	  <DD>
	    Commits all changes and starts a new transaction.

	  </DD><P>

	  <DT><CODE><FONT COLOR="#000099">
		rollback()</FONT></CODE></DT>

	  <DD>
	    Rolls back the current transaction. All changes are undone.

	  </DD><P>

	  <DT><CODE><FONT COLOR="#000099">
		changed()</FONT></CODE></DT>

	  <DD>
	    Return true in case the current transaction includes changes
            to the database, false otherwise.

	  </DD><P>

	  <DT><CODE><FONT COLOR="#000099">
		has_key()</FONT></CODE></DT>

	  <DD>
	    Check if the dictionary has an item indexed by key.
	    <P>
	      Successfully found items are put in the cache for fast
	      subsequent access.

	  </DD><P>

	  <DT><CODE><FONT COLOR="#000099">
		get(key,default=None)</FONT></CODE></DT>

	  <DD>
	    Get item indexed by key from the dictionary or default if
	    no such item exists.
	    <P>
	      This first tries to read the item from cache and reverts
	      to the disk storage if it is not found.

	  </DD><P>

	  <DT><CODE><FONT COLOR="#000099">
		cursor(key,default=None)</FONT></CODE></DT>

	  <DD>
	    Return a BeeStringDictCursor instance for the dictionary.
	    <P>
	      In case the key is not found, default is returned
	      instead.
	    <P>
	      Note that cursors operate with the data on disk meaning
	      that any uncommitted changes will not be seen by the
	      cursor.

	  </DD><P>

	  <DT><CODE><FONT COLOR="#000099">
		garbage()</FONT></CODE></DT>

	  <DD>
	    Determine the amount of garbage in bytes that has accumulated
            in the storage file.
	    <P>
	      This amount would be freed if .collect() were run.

	  </DD><P>

	  <DT><CODE><FONT COLOR="#000099">
		collect()</FONT></CODE></DT>

	  <DD>
	    Run the storage garbage collector.
	    <P>
	      Storage collection can only be done for writeable
	      dictionaries and then only if the current transaction
	      does not contain any pending changes.
	    <P>
	      This can take a while depending on the size of the
	      dictionary.

	  </DD><P>

	  <DT><CODE><FONT COLOR="#000099">
		recover()</FONT></CODE></DT>

	  <DD>
	    Recover all valid records and recreate the index.

	  </DD><P>

	  <DT><CODE><FONT COLOR="#000099">
		keys()</FONT></CODE></DT>

	  <DD>
	    Return a list of keys.
	    <P>
	      The method will raise an error if there are uncommitted
	      changes pending. Output is sorted ascending according to
	      keys.

	  </DD><P>

	  <DT><CODE><FONT COLOR="#000099">
		values()</FONT></CODE></DT>

	  <DD>
	    Return a list of values.
	    <P>
	      The method will raise an error if there are uncommitted
	      changes pending. Output is sorted ascending according to
	      keys.

	  </DD><P>

	  <DT><CODE><FONT COLOR="#000099">
		items()</FONT></CODE></DT>

	  <DD>
	    Return a list of items.
	    <P>
	      The method will raise an error if there are uncommitted
	      changes pending. Output is sorted ascending according to
	      keys.

	  </DD><P>

	</DL>

    </UL><!--CLASS="indent"-->

    <H5>BeeStringDict Instance Attributes</H5>

    <UL CLASS="indent">
      
	<P>
	  BeeDict objects have the following read-only attributes:

	<P><DL>

	  <DT><CODE><FONT COLOR="#000099">
		name</FONT></CODE></DT>

	  <DD>
	    Basenname of the dictionary. The implementation uses two
	    files for the on-disk representation: name.dat and name.idx.
	  </DD><P>

	  <DT><CODE><FONT COLOR="#000099">
		closed</FONT></CODE></DT>

	  <DD>
	    Closed flag.
	  </DD><P>

	  <DT><CODE><FONT COLOR="#000099">
		readonly</FONT></CODE></DT>

	  <DD>
	    Read-only flag.
	  </DD><P>

	  <DT><CODE><FONT COLOR="#000099">
		autocommit</FONT></CODE></DT>

	  <DD>
	    Autocommit flag.
	  </DD><P>

	  <DT><CODE><FONT COLOR="#000099">
		FirstKey</FONT></CODE></DT>

	  <DD>
	    Special key object useable to represent the first key in
	    the (sorted) B+Tree index.
	    
	  </DD><P>

	  <DT><CODE><FONT COLOR="#000099">
		LastKey</FONT></CODE></DT>

	  <DD>
	    Special key object useable to represent the last key in
	    the (sorted) B+Tree index.
	    
	  </DD><P>

	</DL>

    </UL><!--CLASS="indent"-->

    <H4>BeeStringDictCursor Objects</H4>

    <UL CLASS="indent">

	<P>
	  BeeDickCursor objects are intended to iterate over the
	  database one item at a time without the need to read all
	  keys. You can then read/write to the current cursor position
	  and thus modify the dictionary in place.

	<P>
	  Note that modifying the targetted dictionary while using a
	  cursor can cause the cursor to skip new entries or fail due
	  to deleted items. Especially deleting the key to which the
	  cursor currently points can cause errors to be raised.  In
	  all other cases, the cursor will be repositioned.

	<P>
	  BeeStringDictCursor objects are constructed using the BeeStringDict
	  <CODE>.cursor()</CODE> method.

    </UL><!--CLASS="indent"-->

    <H5>BeeStringDictCursor Instance Methods</H5>

    <UL CLASS="indent">
      
	<P>
	  BeeStringDictCursor objects have the following methods:

	<P><DL>

	  <DT><CODE><FONT COLOR="#000099">
		position(key,value=None)</FONT></CODE></DT>

	  <DD>
	    Position the index cursor to index[key]. If value is given,
            index[key] == value is assured.
	    <P>
	      key may also be FirstKey or LastKey (in which case value
	      has to be None).

	  </DD><P>

	  <DT><CODE><FONT COLOR="#000099">
		next()</FONT></CODE></DT>

	  <DD>
	    Moves to the next entry in the dictionary.
	    <P>
	      Returns true on success, false if the end-of-data has
	      been reached.

	  </DD><P>

	  <DT><CODE><FONT COLOR="#000099">
		prev()</FONT></CODE></DT>

	  <DD>
	    Moves to the previous entry in the dictionary.
	    <P>
	      Returns true on success, false if the end-of-data has
	      been reached.

	  </DD><P>

	  <DT><CODE><FONT COLOR="#000099">
		read()</FONT></CODE></DT>

	  <DD>
	    Reads the object from the dict to which the cursor
            currently points.

	  </DD><P>

	  <DT><CODE><FONT COLOR="#000099">
		read_key()</FONT></CODE></DT>

	  <DD>
	    Reads the key object from the dict to which the cursor
	    currently points.

	  </DD><P>

	  <DT><CODE><FONT COLOR="#000099">
		write()</FONT></CODE></DT>

	  <DD>
	    Writes the object to the dict under the key to which
            the cursor currently points.
	    <P>
	      The new data is not written to disk until the
	      dictionary's current transaction is committed.

	  </DD><P>

	</DL>

    </UL><!--CLASS="indent"-->

    <H5>BeeStringDictCursor Instance Attributes</H5>

    <UL CLASS="indent">
      
	<P>
	  BeeStringDictCursor objects have the following read-only
	  attributes:

	<P><DL>

	  <DT><CODE><FONT COLOR="#000099">
		key</FONT></CODE></DT>

	  <DD>
	    Key string which dereferences to the current cursor position.
	  </DD><P>

	</DL>

    </UL><!--CLASS="indent"-->

    <H4>Functions</H4>

    <UL CLASS="indent">

	<P>
	  These functions are available:

	<P><DL>

	  <DT><CODE><FONT COLOR="#000099">
		AutoRecover(Class,*args,**kws)</FONT></CODE></DT>

	  <DD>
	    Wrapper that can be used around the dictionary
	    constructors to provide automatic recovery whenever needed
	    (if possible).
	    <P>
	      Example: <CODE>diskdict = AutoRecover(BeeDict.BeeDict,
	      'test')</CODE>

	  </DD><P>

	</DL>

    </UL><!--CLASS="indent"-->
    
    <H4>Constants</H4>

    <UL CLASS="indent">

	<P>
	  These constants are available:

	<P><DL>

	  <DT><CODE><FONT COLOR="#000099">
		Error</FONT></CODE></DT>

	  <DD>
	    Baseclass for errors related to this module. It is a
	    subclass of exceptions.StandardError. </DD><P>

	  <DT><CODE><FONT COLOR="#000099">
		RecreateIndexError</FONT></CODE></DT>

	  <DD>
	    This error is raised in case the index for a dictionary
	    was not found and/or needs to be recreated by running
	    recovery. It is a subclass of Error. </DD><P>

	  <DT><CODE><FONT COLOR="#000099">
		RecoverError</FONT></CODE></DT>

	  <DD>
	    This error is raised in case the storage for a dictionary
	    was found to be in an inconsistent state. It is a subclass
	    of Error. </DD><P>

	  <DT><CODE><FONT COLOR="#000099">
		FirstKey</FONT></CODE></DT>

	  <DD>
	    Special index key object representing the key of the first
	    entry in the index (B+Tree's sort their data).

	  </DD><P>

	  <DT><CODE><FONT COLOR="#000099">
		LastKey</FONT></CODE></DT>

	  <DD>
	    Special index key object representing the key of the last
	    entry in the index (B+Tree's sort their data).

	  </DD><P>

	</DL>

    </UL><!--CLASS="indent"-->

    </UL><!--CLASS="indent"-->
    
    <A NAME="BeeStorage"></A>

    <H3>BeeStorage Module</H3>

    <UL CLASS="indent">

	<P>
	  XXX Not yet documented. Please refer to the source code.

    </UL><!--CLASS="indent"-->
    
    <A NAME="BeeIndex"></A>

    <H3>BeeIndex Module</H3>

    <UL CLASS="indent">

	<P>
	  XXX Not yet documented. Please refer to the source code.

    </UL><!--CLASS="indent"-->
    
    <A NAME="Examples"></A>

    <H3>Examples of Use</H3>

    <UL CLASS="indent">

	<P>
	  Here is a very simple one:

	<PRE><FONT COLOR="#000066">from mx import BeeBase

#...XXX not written yet...

</FONT></PRE>

	<P>
	  More examples will eventually appear in the Examples
	  subdirectory of the package.

    </UL><!--CLASS="indent"-->

    <A NAME="Structure">

    <H3>Package Structure</H3>
    
    <UL CLASS="indent">

	<PRE>
[BeeBase]
       Doc/
       [mxBeeBase]
              test.py
       BeeBase.py
       BeeDict.py
       BeeIndex.py
       BeeStorage.py
       showBeeDict.py
 	</PRE>

	<P>
	  Entries enclosed in brackets are packages (i.e. they are
	  directories that include a <TT>__init__.py</TT> file). Ones
	  without brackets are just simple subdirectories that are not
	  accessible via <CODE>import</CODE>.

	<P>
	  The package imports all symbols from the BeeBase sub module
	  which in turn imports the extension module, so you only need
	  to '<CODE>import BeeBase</CODE>' to start working.

	<P>

    </UL><!--CLASS="indent"-->

    <A NAME="Support">

    <H3>Support</H3>

    <UL CLASS="indent">

	<P>
	  eGenix.com is providing commercial support for this
	  package. If you are interested in receiving information
	  about this service please see the <A
	  HREF="http://www.egenix.com/files/python/eGenix-mx-Extensions.html#Support">eGenix.com
	  Support Conditions</A>.

    </UL><!--CLASS="indent"-->

    <A NAME="Copyright">

    <H3>Copyright &amp; License</H3>

    <UL CLASS="indent">

	<P>
	  &copy; 1999-2000, Copyright by Marc-Andr&eacute; Lemburg;
	  All Rights Reserved.  mailto: <A
	  HREF="mailto:mal@lemburg.com">mal@lemburg.com</A>
	<P>
	  &copy; 2000-2001, Copyright by eGenix.com Software GmbH,
	  Langenfeld, Germany; All Rights Reserved.  mailto: <A
	  HREF="mailto:info@egenix.com">info@egenix.com</A>

	<P>
	  This software is covered by the <A
	  HREF="mxLicense.html#Public"><B>eGenix.com Public
	  License Agreement</B></A>. The text of the license is also
	  included as file "LICENSE" in the package's main directory.

	<P>
	  <B> By downloading, copying, installing or otherwise using
	  the software, you agree to be bound by the terms and
	  conditions of the eGenix.com Public License
	  Agreement. </B>

	<P>
	  Parts of this package are based on an ANSI C implementation
    	  of a B+Tree implementation written by Thomas Nieman,
    	  Portland, Oregon.  The files in question are btr.c and btr.h
    	  which were heavily modified for the purpose of inclusion in
    	  this package by the above author.

	<P>
	  The original files were extracted from btr.c -- an ANSI C
    	  implementation included in the source code distribution of

	<PRE>
        SORTING AND SEARCHING ALGORITHMS: A COOKBOOK

	by THOMAS NIEMANN Portland, Oregon 
	home: <A HREF="http://epaperpress.com/">http://epaperpress.com/</A>
	</PRE>
    
	<P>
	  From the cookbook:
	<BLOCKQUOTE>
	  Permission to reproduce this document, in whole or in part,
    	  is given provided the original web site listed below is
    	  referenced, and no additional restrictions apply. Source
    	  code, when part of a software project, may be used freely
    	  without reference to the author.
	</BLOCKQUOTE>
	  

    </UL><!--CLASS="indent"-->

    <A NAME="History">

    <H3>History & Future</H3>

    <UL CLASS="indent">

	<P>Things that still need to be done:

	<P><UL>

	    <LI> Provide more examples.

	    <P><LI> Test the package some more.

	    <P><LI> Write more documentation.

	</UL>

	<P>
	  There were no significant changes between 2.0.0 and 2.0.3.

	<P>
	  Version 2.0.0 was the intial release. 

	<P>

    </UL><!--CLASS="indent"-->

    <HR WIDTH="100%">
    <CENTER><FONT SIZE=-1>
        <P>
          &copy; 1998-2000, Copyright by Marc-Andr&eacute; Lemburg;
          All Rights Reserved.  mailto: <A
          HREF="mailto:mal@lemburg.com">mal@lemburg.com</A>
        <P>
          &copy; 2000-2001, Copyright by eGenix.com Software GmbH; 
          All Rights Reserved.  mailto: <A
          HREF="mailto:info@egenix.com">info@egenix.com</A>
    </FONT></CENTER>
    </FONT></CENTER>

  </BODY>
</HTML>