The main database code. it creates the global $swDB object and handles all indexes.
It does not handle writing of new records. This is done in inc/record.php. It observes changes and updates indexes based on need.
Note that to look up a record by URL, the indexes are not used. The hashes of the filenames in the current folder are the index for that.
Global object, initiated in api.php. It manages and provides on request the following indexes
- indexedbitmap: a bitma] of the indexed revisions
- currentbitmap: a bitma] of the current revisions
- deletedbitmap: a bitmap of the deleted revisions
- protecedbitmap:: a bitmap of the protected revisions
A valid revision is a revision that is both current and not deleted.
The index files are in the site/indexes folder.
- indexedbitmap.php, currentbitmap.txt, deletedbitmap.txt, protectedbitmap.txt are serialized.
- urls.txt contains a tabbed table with a revision and the md5 hash of the name of the record. The text file as fixed length of 48 bytes per row, so it can be read both as text file and as binary file.
init($force = false) initiates the swDB.
First the bitmaps are read.
If the last revision is 0 or if forced is set (when you request the page Special:Recent Changes, then index are rebuilt.
close() writes down modifications that have been added to the bitmaps.
UpdateIndexes($rev) updates the index for one revision. It sets the bitmaps and writes to the urls.txt file
GetLastRevisionFolderItem() returns the highest revision in the revision folder.
RebuildIndexes() updates indexes each revision at a time. The record lookup by revisions triggers also writing of the record to the current folder. There is a timeout. Normally, one request makes about 5000 revisions.
RebuildBitmaps() can recreate the bitmaps if the urls.txt file is still available.
swGetAllRevisionsFromName($name) gives back a history of all revisions of a page as a list of revision
swGetPath($revision) returns the path from a revision to its file