JODA  0.13.1 (59b41972)
JSON On-Demand Analysis
Data Structures | Public Member Functions
JSONContainer Class Reference

#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
 
RJMemoryPoolAllocgetAlloc ()
 
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 DocIndexcheckDocuments (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< JSONContainercreateViewFromContainer (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 DocIndexgetAllIDs () 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)
 

Detailed Description

JSONContainers are a collection of JSONDocuments and indices created on them. They are used as interface for all query operations.

Constructor & Destructor Documentation

◆ JSONContainer() [1/3]

JSONContainer::JSONContainer ( )

Creates a default empty JSONContainer with the maximum size configured in the config

Here is the caller graph for this function:

◆ JSONContainer() [2/3]

JSONContainer::JSONContainer ( size_t  maxsize)
explicit

Creates a default empty JSONContainer with the maximum size specified in the parameter

Parameters
maxsizeMaximum size (in Bytes) of the container

◆ JSONContainer() [3/3]

JSONContainer::JSONContainer ( JSONContainer other)
delete

◆ ~JSONContainer()

JSONContainer::~JSONContainer ( )
virtual
Here is the call graph for this function:

Member Function Documentation

◆ AcceptDocuments()

template<class Handler >
std::vector<bool> JSONContainer::AcceptDocuments ( Handler &  handler,
unsigned long  start = 0,
unsigned long  end = ULONG_MAX 
)
inline
Here is the call graph for this function:

◆ checkDocuments()

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.

Parameters
funcThe function to execute on the documents
Returns
A set containing all document ids where the function returned True
Here is the caller graph for this function:

◆ createTempViewDocs()

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 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ createViewFromContainer()

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

Parameters
idsThe documents to project
projA vector containing all projections to be executed on the documents
allocAn allocator used to project the documents
setProjA vector containing all set-projections to be executed on the documents
Returns
A vector containing all projected documents

◆ estimatedSize()

size_t JSONContainer::estimatedSize ( ) const

Returns the estimated size of the container (in Bytes)

Returns
Estimated size of the container (in Bytes)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ finalize()

void JSONContainer::finalize ( )

Finalizes the container. After finalization no further documents can be added. During this step, the indices are computed.

◆ forAll() [1/4]

template<class F >
void JSONContainer::forAll ( F &  f)
inline

Executes a function on all documents and discards their return value

Template Parameters
Fthe function to call
Parameters
funcThe function to execute on all documents.

◆ forAll() [2/4]

template<class F >
void JSONContainer::forAll ( f)
inline

Executes a function on all documents and discards their return value

Template Parameters
Fthe function to call
Parameters
funcThe function to execute on all documents.

◆ forAll() [3/4]

template<class F >
void JSONContainer::forAll ( f,
const DocIndex ids 
)
inline

Executes a function on all documents and discards their return value

Template Parameters
Fthe function to call
Parameters
funcThe function to execute on all documents.
idsThe documents to check
Here is the call graph for this function:

◆ forAll() [4/4]

template<class retType >
void JSONContainer::forAll ( std::function< retType(RapidJsonDocument &)> &  func,
std::vector< retType > &  vec 
)

Executes a function on all documents and stores their return value

Template Parameters
retTypeThe return-type of the function
Parameters
funcThe function to execute on all documents.
vecThe vector used to store all return values in
Here is the caller graph for this function:

◆ forAllRet()

template<class F , class R >
std::vector<R> JSONContainer::forAllRet ( f,
const DocIndex ids 
)
inline

Executes a function on all documents and stores their return value

Template Parameters
Fthe function to call
Parameters
funcThe function to execute on all documents.
idsThe documents to check
vecThe vector of return types to fill
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getAllIDs()

std::unique_ptr< const DocIndex > JSONContainer::getAllIDs ( ) const

Returns a list of all document ids

Returns
Here is the caller graph for this function:

◆ getAlloc()

RJMemoryPoolAlloc * JSONContainer::getAlloc ( )

Returns the allocator used to store all the JSONDocuments

Returns
Pointer to the allocator

◆ getCache()

const std::unique_ptr< QueryCache > & JSONContainer::getCache ( ) const

Returns the QueryCache

Returns
QueryCache
Here is the caller graph for this function:

◆ getLastUsed()

unsigned long JSONContainer::getLastUsed ( ) const

Returns a UNIX timestamp of the last time the JSONContainer was used

Returns

◆ getMaxSize()

size_t JSONContainer::getMaxSize ( ) const

Returns the maximum size (in Bytes) of the container

Returns
Maximum size (in Bytes) of the container

◆ getRaw() [1/3]

std::vector< std::unique_ptr< RJDocument > > JSONContainer::getRaw ( const DocIndex ids)

Returns the raw document representation of the chosen documents

Parameters
idsIDs of desired documents
Returns
Vector of raw documents
Here is the call graph for this function:

◆ getRaw() [2/3]

std::vector< std::unique_ptr< RJDocument > > JSONContainer::getRaw ( const DocIndex ids,
RJMemoryPoolAlloc alloc 
)
Here is the call graph for this function:

◆ getRaw() [3/3]

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

Parameters
startStart index of documents
endEnd index of documents
Returns
Vector of raw documents
Here is the call graph for this function:
Here is the caller graph for this function:

◆ hasMetaSpace()

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

Parameters
sizeThe size of the document(s) to add
Returns
True if there is enough space, False if not
Here is the call graph for this function:

◆ hasSpace()

bool JSONContainer::hasSpace ( size_t  size) const

Checks if the container has enough space to add another document of size "size".

Parameters
sizeThe size of the document(s) to add
Returns
True if there is enough space, False if not
Here is the call graph for this function:

◆ insertDoc() [1/2]

void JSONContainer::insertDoc ( RapidJsonDocument &&  doc,
size_t  baseIndex = 0 
)

Inserts a document into the container using its representation class

Parameters
docThe document to be inserted
baseIndexthe index of the parent document (if exists)

◆ insertDoc() [2/2]

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

Parameters
docThe actual rapidjson document
originThe origin of the document

◆ isBaseContainer()

bool JSONContainer::isBaseContainer ( const JSONContainer cont) const

◆ isReparsable()

bool JSONContainer::isReparsable ( )

Checks if the container is reparsable

Here is the caller graph for this function:

◆ isView()

bool JSONContainer::isView ( ) const
Returns
true if the container is a queue
Here is the caller graph for this function:

◆ materializeAttributes()

void JSONContainer::materializeAttributes ( const std::vector< std::string > &  atts)

Materializes the given attributes if the container is a view

Parameters
atts
Here is the call graph for this function:
Here is the caller graph for this function:

◆ materializeAttributesIfRequired()

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

Parameters
atts
Here is the call graph for this function:
Here is the caller graph for this function:

◆ materializeView()

void JSONContainer::materializeView ( )

Materializes the view completly and turns the container to a normal container.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ metaFinalize()

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.

◆ parsedSize()

size_t JSONContainer::parsedSize ( ) const

Returns the parsed size of the container (in Bytes)

Returns
parsed size of the container (in Bytes)
Here is the call graph for this function:

◆ preparePurge()

void JSONContainer::preparePurge ( )

◆ probContainsAttr()

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

Parameters
attrThe attribute to check for
Returns
True if it is probably contained within the container, False if it definitely is not
Here is the call graph for this function:

◆ projectDocuments()

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

Parameters
idsThe documents to project
projA vector containing all projections to be executed on the documents
allocAn allocator used to project the documents
setProjA vector containing all set-projections to be executed on the documents
Returns
A vector containing all projected documents
Here is the caller graph for this function:

◆ removeDocuments()

void JSONContainer::removeDocuments ( )

Removes the content of all documents. The metadata is kept. This function only executes if the documents are reparsable.

Here is the call graph for this function:

◆ removeViews()

void JSONContainer::removeViews ( )
Here is the caller graph for this function:

◆ reparse()

void JSONContainer::reparse ( )

Reparses the contained documents

Here is the call graph for this function:

◆ reparseSubset() [1/2]

void JSONContainer::reparseSubset ( const DocIndex index)

Reparses the contained documents

Parameters
indexThe document index of all documents to be parsed
Here is the call graph for this function:

◆ reparseSubset() [2/2]

void JSONContainer::reparseSubset ( unsigned long  start = 0,
unsigned long  end = ULONG_MAX 
)

Reparses the contained documents

Parameters
startStart index of documents to reparse
endEnd index of documents to reparse
Here is the call graph for this function:
Here is the caller graph for this function:

◆ setViews()

void JSONContainer::setViews ( )

Creates the internal view objects for all documents (if required)

Here is the call graph for this function:
Here is the caller graph for this function:

◆ size()

unsigned long JSONContainer::size ( ) const

Returns the amount of documents stored in the container

Returns
Amount of documents stored in the container
Here is the caller graph for this function:

◆ stringify()

std::vector< std::string > JSONContainer::stringify ( unsigned long  start = 0,
unsigned long  end = ULONG_MAX 
)

Stringifies the documents in the container

Parameters
startStart index of documents to stringify
endEnd index of documents to stringify
Returns
Vector of string representations of the documents
Here is the call graph for this function:
Here is the caller graph for this function:

◆ useContInScope()

auto JSONContainer::useContInScope ( bool  parse = true)
inline

◆ useViewBasedOnSample()

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 
)
Here is the call graph for this function:

◆ writeFile()

void JSONContainer::writeFile ( const std::string &  file,
bool  append 
)

Writes the documents into a file

Parameters
fileThe file to write the documents to
appendWhether to append or replace the file
Here is the call graph for this function:
Here is the caller graph for this function:

The documentation for this class was generated from the following files: