JODA
0.13.1 (59b41972)
JSON On-Demand Analysis
|
#include <JSONContainer.h>
Data Structures | |
class | ScopedRef |
Public Member Functions | |
JSONContainer () | |
JSONContainer (size_t maxsize) | |
JSONContainer (JSONContainer &other)=delete | |
virtual | ~JSONContainer () |
void | preparePurge () |
bool | hasSpace (size_t size) const |
bool | hasMetaSpace (size_t size) |
unsigned long | size () const |
size_t | getMaxSize () const |
bool | probContainsAttr (const std::string &attr) const |
RJMemoryPoolAlloc * | getAlloc () |
void | insertDoc (std::unique_ptr< RJDocument > &&doc, std::unique_ptr< IOrigin > &&origin, size_t baseIndex=0) |
void | insertDoc (RapidJsonDocument &&doc, size_t baseIndex=0) |
std::unique_ptr< const DocIndex > | checkDocuments (std::function< bool(RapidJsonDocument &, size_t)> &func) |
template<class retType > | |
void | forAll (std::function< retType(RapidJsonDocument &)> &func, std::vector< retType > &vec) |
template<class F > | |
void | forAll (F &f) |
template<class F > | |
void | forAll (F f) |
template<class F > | |
void | forAll (F f, const DocIndex &ids) |
template<class F , class R > | |
std::vector< R > | forAllRet (F f, const DocIndex &ids) |
std::vector< std::unique_ptr< RJDocument > > | projectDocuments (const DocIndex &ids, const std::vector< std::unique_ptr< joda::query::IProjector >> &proj, RJMemoryPoolAlloc &alloc, const std::vector< std::unique_ptr< joda::query::ISetProjector >> &setProj) |
std::unique_ptr< JSONContainer > | createViewFromContainer (const DocIndex &ids, const std::vector< std::unique_ptr< joda::query::IProjector >> &proj, const std::vector< std::unique_ptr< joda::query::ISetProjector >> &setProj) |
DocumentCostHandler | createTempViewDocs (const DocIndex &ids, const std::vector< std::unique_ptr< joda::query::IProjector >> &proj, const std::vector< std::unique_ptr< joda::query::ISetProjector >> &setProj) |
bool | useViewBasedOnSample (const DocIndex &ids, const std::vector< std::unique_ptr< joda::query::IProjector >> &proj, const std::vector< std::unique_ptr< joda::query::ISetProjector >> &setProj) |
void | finalize () |
void | metaFinalize () |
void | removeDocuments () |
void | reparse () |
void | setViews () |
void | removeViews () |
void | reparseSubset (unsigned long start=0, unsigned long end=ULONG_MAX) |
void | reparseSubset (const DocIndex &index) |
bool | isReparsable () |
size_t | estimatedSize () const |
size_t | parsedSize () const |
std::vector< std::string > | stringify (unsigned long start=0, unsigned long end=ULONG_MAX) |
std::vector< std::unique_ptr< RJDocument > > | getRaw (unsigned long start=0, unsigned long end=ULONG_MAX) |
std::vector< std::unique_ptr< RJDocument > > | getRaw (const DocIndex &ids) |
std::vector< std::unique_ptr< RJDocument > > | getRaw (const DocIndex &ids, RJMemoryPoolAlloc &alloc) |
template<class Handler > | |
std::vector< bool > | AcceptDocuments (Handler &handler, unsigned long start=0, unsigned long end=ULONG_MAX) |
void | writeFile (const std::string &file, bool append) |
const std::unique_ptr< QueryCache > & | getCache () const |
std::unique_ptr< const DocIndex > | getAllIDs () const |
void | materializeAttributes (const std::vector< std::string > &atts) |
void | materializeAttributesIfRequired (const std::vector< std::string > &atts) |
void | materializeView () |
bool | isView () const |
unsigned long | getLastUsed () const |
bool | isBaseContainer (const JSONContainer *cont) const |
auto | useContInScope (bool parse=true) |
JSONContainers are a collection of JSONDocuments and indices created on them. They are used as interface for all query operations.
JSONContainer::JSONContainer | ( | ) |
Creates a default empty JSONContainer with the maximum size configured in the config
|
explicit |
Creates a default empty JSONContainer with the maximum size specified in the parameter
maxsize | Maximum size (in Bytes) of the container |
|
delete |
|
virtual |
|
inline |
std::unique_ptr< const DocIndex > JSONContainer::checkDocuments | ( | std::function< bool(RapidJsonDocument &, size_t)> & | func | ) |
Executes "func" on all documents. If it returns True, the document id is added to a set and returned.
func | The function to execute on the documents |
DocumentCostHandler JSONContainer::createTempViewDocs | ( | const DocIndex & | ids, |
const std::vector< std::unique_ptr< joda::query::IProjector >> & | proj, | ||
const std::vector< std::unique_ptr< joda::query::ISetProjector >> & | setProj | ||
) |
std::unique_ptr< JSONContainer > JSONContainer::createViewFromContainer | ( | const DocIndex & | ids, |
const std::vector< std::unique_ptr< joda::query::IProjector >> & | proj, | ||
const std::vector< std::unique_ptr< joda::query::ISetProjector >> & | setProj | ||
) |
Creates a view from the current container
ids | The documents to project |
proj | A vector containing all projections to be executed on the documents |
alloc | An allocator used to project the documents |
setProj | A vector containing all set-projections to be executed on the documents |
size_t JSONContainer::estimatedSize | ( | ) | const |
Returns the estimated size of the container (in Bytes)
void JSONContainer::finalize | ( | ) |
Finalizes the container. After finalization no further documents can be added. During this step, the indices are computed.
|
inline |
Executes a function on all documents and discards their return value
F | the function to call |
func | The function to execute on all documents. |
|
inline |
Executes a function on all documents and discards their return value
F | the function to call |
func | The function to execute on all documents. |
|
inline |
Executes a function on all documents and discards their return value
F | the function to call |
func | The function to execute on all documents. |
ids | The documents to check |
void JSONContainer::forAll | ( | std::function< retType(RapidJsonDocument &)> & | func, |
std::vector< retType > & | vec | ||
) |
Executes a function on all documents and stores their return value
retType | The return-type of the function |
func | The function to execute on all documents. |
vec | The vector used to store all return values in |
|
inline |
Executes a function on all documents and stores their return value
F | the function to call |
func | The function to execute on all documents. |
ids | The documents to check |
vec | The vector of return types to fill |
std::unique_ptr< const DocIndex > JSONContainer::getAllIDs | ( | ) | const |
Returns a list of all document ids
RJMemoryPoolAlloc * JSONContainer::getAlloc | ( | ) |
Returns the allocator used to store all the JSONDocuments
const std::unique_ptr< QueryCache > & JSONContainer::getCache | ( | ) | const |
unsigned long JSONContainer::getLastUsed | ( | ) | const |
Returns a UNIX timestamp of the last time the JSONContainer was used
size_t JSONContainer::getMaxSize | ( | ) | const |
Returns the maximum size (in Bytes) of the container
std::vector< std::unique_ptr< RJDocument > > JSONContainer::getRaw | ( | const DocIndex & | ids | ) |
Returns the raw document representation of the chosen documents
ids | IDs of desired documents |
std::vector< std::unique_ptr< RJDocument > > JSONContainer::getRaw | ( | const DocIndex & | ids, |
RJMemoryPoolAlloc & | alloc | ||
) |
std::vector< std::unique_ptr< RJDocument > > JSONContainer::getRaw | ( | unsigned long | start = 0 , |
unsigned long | end = ULONG_MAX |
||
) |
Returns the raw document representation of the chosen documents
start | Start index of documents |
end | End index of documents |
bool JSONContainer::hasMetaSpace | ( | size_t | size | ) |
Checks if the container has enough space to add another document of size "size". If it returns True, "size" is automatically added to an internal counter, to keep track of used metadata space
size | The size of the document(s) to add |
bool JSONContainer::hasSpace | ( | size_t | size | ) | const |
Checks if the container has enough space to add another document of size "size".
size | The size of the document(s) to add |
void JSONContainer::insertDoc | ( | RapidJsonDocument && | doc, |
size_t | baseIndex = 0 |
||
) |
Inserts a document into the container using its representation class
doc | The document to be inserted |
baseIndex | the index of the parent document (if exists) |
void JSONContainer::insertDoc | ( | std::unique_ptr< RJDocument > && | doc, |
std::unique_ptr< IOrigin > && | origin, | ||
size_t | baseIndex = 0 |
||
) |
Inserts a document into the container using its raw components
doc | The actual rapidjson document |
origin | The origin of the document |
bool JSONContainer::isBaseContainer | ( | const JSONContainer * | cont | ) | const |
bool JSONContainer::isReparsable | ( | ) |
Checks if the container is reparsable
bool JSONContainer::isView | ( | ) | const |
void JSONContainer::materializeAttributes | ( | const std::vector< std::string > & | atts | ) |
Materializes the given attributes if the container is a view
atts |
void JSONContainer::materializeAttributesIfRequired | ( | const std::vector< std::string > & | atts | ) |
Materializes the given attributes if the container is a view and the attributes cannot be returned without materialization
atts |
void JSONContainer::materializeView | ( | ) |
Materializes the view completly and turns the container to a normal container.
void JSONContainer::metaFinalize | ( | ) |
Finalizes the container with only the stored metadata. After finalization no further documents can be added. During this step, the indices are computed.
size_t JSONContainer::parsedSize | ( | ) | const |
Returns the parsed size of the container (in Bytes)
void JSONContainer::preparePurge | ( | ) |
bool JSONContainer::probContainsAttr | ( | const std::string & | attr | ) | const |
Uses an internal bloom filter to check if a given attribute is probably contained within the document-set in the container
attr | The attribute to check for |
std::vector< std::unique_ptr< RJDocument > > JSONContainer::projectDocuments | ( | const DocIndex & | ids, |
const std::vector< std::unique_ptr< joda::query::IProjector >> & | proj, | ||
RJMemoryPoolAlloc & | alloc, | ||
const std::vector< std::unique_ptr< joda::query::ISetProjector >> & | setProj | ||
) |
Projects all chosen documents into a new format
ids | The documents to project |
proj | A vector containing all projections to be executed on the documents |
alloc | An allocator used to project the documents |
setProj | A vector containing all set-projections to be executed on the documents |
void JSONContainer::removeDocuments | ( | ) |
Removes the content of all documents. The metadata is kept. This function only executes if the documents are reparsable.
void JSONContainer::removeViews | ( | ) |
void JSONContainer::reparse | ( | ) |
Reparses the contained documents
void JSONContainer::reparseSubset | ( | const DocIndex & | index | ) |
Reparses the contained documents
index | The document index of all documents to be parsed |
void JSONContainer::reparseSubset | ( | unsigned long | start = 0 , |
unsigned long | end = ULONG_MAX |
||
) |
Reparses the contained documents
start | Start index of documents to reparse |
end | End index of documents to reparse |
void JSONContainer::setViews | ( | ) |
Creates the internal view objects for all documents (if required)
unsigned long JSONContainer::size | ( | ) | const |
Returns the amount of documents stored in the container
std::vector< std::string > JSONContainer::stringify | ( | unsigned long | start = 0 , |
unsigned long | end = ULONG_MAX |
||
) |
Stringifies the documents in the container
start | Start index of documents to stringify |
end | End index of documents to stringify |
|
inline |
bool JSONContainer::useViewBasedOnSample | ( | const DocIndex & | ids, |
const std::vector< std::unique_ptr< joda::query::IProjector >> & | proj, | ||
const std::vector< std::unique_ptr< joda::query::ISetProjector >> & | setProj | ||
) |
void JSONContainer::writeFile | ( | const std::string & | file, |
bool | append | ||
) |
Writes the documents into a file
file | The file to write the documents to |
append | Whether to append or replace the file |