5 #ifndef JODA_JSONSTORAGE_H
6 #define JODA_JSONSTORAGE_H
15 #include <unordered_map>
45 size_t &insertedDocs,
size_t &insertedConts);
56 const std::atomic_bool &cf, std::atomic_uint &cs);
74 unsigned long size()
const;
109 const std::string &
getName()
const;
129 std::vector<std::string>
stringify(
unsigned long start = 0,
130 unsigned long end = ULONG_MAX);
138 std::vector<std::shared_ptr<RJDocument>>
getRaw(
139 unsigned long start = 0,
unsigned long end = ULONG_MAX);
148 template <
class Handler>
150 unsigned long end = ULONG_MAX) {
152 std::vector<bool> ret;
155 if (start > end)
return ret;
156 auto count = (end - start) + 1;
160 unsigned long skippedSize = 0;
162 while (start >= (*it)->size() + skippedSize) {
163 skippedSize += (*it)->size();
168 while (ret.size() < count) {
169 size_t contStart = start - skippedSize;
170 contStart = std::max(contStart, (
size_t)0);
171 unsigned long contEnd = contStart + count - ret.size() - 1;
173 DCHECK(
false) <<
"If all Container contributed to the raws, this "
174 "should not be possible";
178 if ((*it)->size() != 0) {
179 auto tmp = (*it)->AcceptDocuments(handler, contStart, contEnd);
180 DCHECK_EQ(tmp.size(), contEnd - contStart + 1);
181 std::move(tmp.begin(), tmp.end(), std::back_inserter(ret));
184 DLOG(INFO) <<
"Skipping empty container";
218 const std::vector<std::unique_ptr<JSONContainer>> &
getContainer()
const;
Definition: JSONStorage.h:24
unsigned long docCount
Definition: JSONStorage.h:228
friend QueryPlan
Definition: JSONStorage.h:217
std::string query
Definition: JSONStorage.h:224
void insertDocumentsQueue(JsonContainerQueue::queue_t *queue)
Definition: JSONStorage.cpp:281
std::vector< std::unique_ptr< JSONContainer > > container
Definition: JSONStorage.h:227
const std::string & getRegtmpdir() const
Definition: JSONStorage.cpp:279
const std::string & getQueryString() const
Definition: JSONStorage.cpp:357
void freeAllMemory()
Definition: JSONStorage.cpp:80
size_t estimatedSize() const
Definition: JSONStorage.cpp:56
void writeFile(const std::string &file)
Definition: JSONStorage.cpp:127
std::string getStorageID() const
Definition: JSONStorage.cpp:87
void insertDocuments(moodycamel::ConcurrentQueue< std::unique_ptr< JSONContainer >> &queue, const std::atomic_bool &cf, std::atomic_uint &cs)
Definition: JSONStorage.cpp:13
JSONStorage(std::string query_string)
Definition: JSONStorage.cpp:94
size_t parsedSize() const
Definition: JSONStorage.cpp:64
std::vector< std::shared_ptr< RJDocument > > getRaw(unsigned long start=0, unsigned long end=ULONG_MAX)
Definition: JSONStorage.cpp:234
const std::string & getName() const
Definition: JSONStorage.cpp:125
std::mutex documentMutex
Definition: JSONStorage.h:226
void getDocumentsQueue(JsonContainerRefQueue::queue_t *queue)
Definition: JSONStorage.cpp:325
void addQueryString(const std::string &query_string)
Definition: JSONStorage.cpp:350
void writeFiles(const std::string &file)
Definition: JSONStorage.cpp:135
std::string regtmpdir
Definition: JSONStorage.h:221
const std::vector< std::unique_ptr< JSONContainer > > & getContainer() const
Definition: JSONStorage.cpp:345
unsigned long contSize() const
Definition: JSONStorage.cpp:47
unsigned long getLastUsed() const
Definition: JSONStorage.cpp:335
std::string name
Definition: JSONStorage.h:220
size_t threadCount(size_t containerSize) const
Definition: JSONStorage.cpp:49
void preparePurge()
Definition: JSONStorage.cpp:118
std::vector< bool > AcceptDocuments(Handler &handler, unsigned long start=0, unsigned long end=ULONG_MAX)
Definition: JSONStorage.h:149
virtual ~JSONStorage()
Definition: JSONStorage.cpp:103
unsigned long size() const
Definition: JSONStorage.cpp:45
size_t estimatedCapacity() const
Definition: JSONStorage.cpp:72
std::vector< std::string > stringify(unsigned long start=0, unsigned long end=ULONG_MAX)
Definition: JSONStorage.cpp:181
Definition: QueryPlan.h:25
Definition: concurrentqueue.h:802