Moved non-public headers out of include/ directory.
5 * Created by Jens Alfke on 8/27/09.
6 * Copyright 2009 Jens Alfke. All rights reserved.
7 * BSD-Licensed: See the file "LICENSE.txt" for details.
10 #ifndef _MOOSEYARD_INDEX_
11 #define _MOOSEYARD_INDEX_
13 #include "Dictionary.h"
19 /** An in-file hash table. This structure is stored directly in the file, memory-mapped.
20 Index is normally only used internally by VersionDictionary. */
21 class Index :public Chunk {
26 static const Index* indexMappedAt (const void*);
27 static Index* create (int capacity);
29 int count() const {return _count;}
31 Blob get (File *file, Key) const;
32 bool put (File *file, Key, FilePosition valuePosition, FilePosition maxPosition);
33 bool remove (File *file, Key, FilePosition maxPosition);
36 void copyFrom (File *file, const Index *index);
40 void validate() const throw(File::Error);
41 void validateEntries (const File *file) const throw(File::Error);
42 static const uint16_t kChunkType = 2;
45 Index (uint32_t tableSize);
46 const Entry* table (int index) const;
47 Entry* table (int index);
48 const KeyValueChunk* _find (File *file, Key) const;
49 bool _put (File *file, Key, FilePosition, FilePosition maxPosition);
51 // This is mapped to data in the file! Don't mess with it!
52 LittleEndian<uint32_t> _magicNumber;
53 LittleEndian<uint32_t> _count;
54 LittleEndian<uint32_t> _tableSize;
55 char _table[0]; // Actually Entry[]
60 class Index::Iterator :public Dictionary::Iterator {
62 Iterator (File*, const Index*);
63 virtual Key key() const;
64 virtual Blob value() const;
66 virtual bool hasValue() const;
68 FilePosition valuePosition();
71 const Index::Entry *_current, *_end;
76 #endif //_MOOSEYARD_INDEX_