00001 #ifndef LUX_INDEX_DOCSTORAGEARRAY_H
00002 #define LUX_INDEX_DOCSTORAGEARRAY_H
00003
00004 #include "lux/lux.h"
00005 #include "lux/scoped_ptr.h"
00006 #include "lux/storage/storage_engine.h"
00007 #include "lux/document/document_serializer.h"
00008 #include <string>
00009 #include <map>
00010
00011 #define COMPRESSED 0x10
00012 #define NONCOMPRESSED 0x00
00013
00014 #define DOC_HDR_SIZE sizeof(char) + sizeof(uint32_t)
00015
00016
00017 namespace Lux {
00018
00019 class Document;
00020 namespace Config { class Document; }
00021
00022 typedef std::map< std::string, std::string > StrMap;
00023 typedef StrMap::iterator SMIterator;
00024
00025 class DocStorageArray {
00026 public:
00027 DocStorageArray(Config::Document &doc_config);
00028 ~DocStorageArray() {}
00029 bool open(std::string storage_dir, db_flags_t open_params);
00030 bool close(void);
00031 bool add(const Document *doc);
00032 bool add(const Document &doc);
00033 Document get(doc_id_t internal_id);
00034 std::string get_raw(doc_id_t internal_id);
00035
00036 private:
00037 scoped_ptr<LuxArrayStorage> doc_storage_;
00038 StrMap disp_field_map_;
00039 DocumentSerializer doc_serializer_;
00040
00041 #ifdef USE_ZLIB
00042 bool _compress(std::string &src, LuxDataUnit &dest);
00043 bool _uncompress(LuxDataUnit &src, std::string &dest);
00044 #endif
00045 };
00046 }
00047
00048 #endif