diff -r 31a43d94cc26 -r 6cbad782d16a include/Index.h --- a/include/Index.h Sun Sep 20 15:14:12 2009 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,76 +0,0 @@ -/* - * Index.h - * Ottoman - * - * Created by Jens Alfke on 8/27/09. - * Copyright 2009 Jens Alfke. All rights reserved. - * BSD-Licensed: See the file "LICENSE.txt" for details. - */ - -#ifndef _MOOSEYARD_INDEX_ -#define _MOOSEYARD_INDEX_ -#include "Chunk.h" -#include "Dictionary.h" - -namespace Mooseyard { - - class KeyValueChunk; - - /** An in-file hash table. This structure is stored directly in the file, memory-mapped. - Index is normally only used internally by VersionDictionary. */ - class Index :public Chunk { - public: - - class Entry; - - static const Index* indexMappedAt (const void*); - static Index* create (int capacity); - - int count() const {return _count;} - - Blob get (File *file, Key) const; - bool put (File *file, Key, FilePosition valuePosition, FilePosition maxPosition); - bool remove (File *file, Key, FilePosition maxPosition); - void removeAll(); - - void copyFrom (File *file, const Index *index); - - class Iterator; - - void validate() const throw(File::Error); - void validateEntries (const File *file) const throw(File::Error); - static const uint16_t kChunkType = 2; - - private: - Index (uint32_t tableSize); - const Entry* table (int index) const; - Entry* table (int index); - const KeyValueChunk* _find (File *file, Key) const; - bool _put (File *file, Key, FilePosition, FilePosition maxPosition); - - // This is mapped to data in the file! Don't mess with it! - LittleEndian _magicNumber; - LittleEndian _count; - LittleEndian _tableSize; - char _table[0]; // Actually Entry[] - }; - - - - class Index::Iterator :public Dictionary::Iterator { - public: - Iterator (File*, const Index*); - virtual Key key() const; - virtual Blob value() const; - virtual bool next(); - virtual bool hasValue() const; - - FilePosition valuePosition(); - private: - File* const _file; - const Index::Entry *_current, *_end; - }; - -} - -#endif //_MOOSEYARD_INDEX_