ModErn Text Analysis
META Enumerates Textual Applications
Public Types | Public Member Functions | Private Attributes | List of all members
meta::index::postings_data< PrimaryKey, SecondaryKey, FeatureValue > Class Template Reference

A class to represent the per-PrimaryKey data in an index's postings file. More...

#include <postings_data.h>

Public Types

using primary_key_type = PrimaryKey
 
using secondary_key_type = SecondaryKey
 
using pair_t = std::pair< SecondaryKey, FeatureValue >
 
using count_t = std::vector< pair_t >
 

Public Member Functions

 postings_data ()=default
 PrimaryKeys may only be integral types or strings; SecondaryKeys may only be integral types. More...
 
 postings_data (PrimaryKey p_id)
 Creates an empty postings_data for a given PrimaryKey. More...
 
 postings_data (const postings_data &)=default
 Postings data is copy constructable.
 
 postings_data (postings_data &&)=default
 Postings data is move constructable.
 
postings_dataoperator= (const postings_data &)=default
 Postings data is copy assignable.
 
postings_dataoperator= (postings_data &&)=default
 Postings data is move assignable.
 
template<class Container >
void merge_with (Container &&cont)
 
void increase_count (SecondaryKey s_id, FeatureValue amount)
 
FeatureValue count (SecondaryKey s_id) const
 
const count_t & counts () const
 
void set_counts (const count_t &counts)
 
void set_counts (count_t &&counts)
 
template<class InputIterator >
void set_counts (InputIterator begin, InputIterator end)
 
bool operator< (const postings_data &other) const
 
uint64_t write_packed (std::ostream &out) const
 Writes this postings data to an output stream in a packed binary format. More...
 
uint64_t write_packed_counts (std::ostream &out) const
 Writes this postings data's counts to an output stream in a packed binary format. More...
 
template<class InputStream >
uint64_t read_packed (InputStream &in)
 Reads a postings data object from an input stream in a packed binary format. More...
 
const PrimaryKey & primary_key () const
 
void set_primary_key (PrimaryKey new_key)
 
uint64_t inverse_frequency () const
 
uint64_t bytes_used () const
 

Private Attributes

PrimaryKey p_id_
 Primary id this postings_data represents.
 
util::sparse_vector< SecondaryKey, FeatureValue > counts_
 The (secondary_key_type, count) pairs.
 

Detailed Description

template<class PrimaryKey, class SecondaryKey, class FeatureValue = uint64_t>
class meta::index::postings_data< PrimaryKey, SecondaryKey, FeatureValue >

A class to represent the per-PrimaryKey data in an index's postings file.

For a given PrimaryKey, a mapping of SecondaryKey -> count information is stored.

For example, for an inverted index, PrimaryKey = term_id, SecondaryKey = doc_id. For a forward_index, PrimaryKey = doc_id, SecondaryKey = term_id.

Constructor & Destructor Documentation

§ postings_data() [1/2]

template<class PrimaryKey , class SecondaryKey , class FeatureValue = uint64_t>
meta::index::postings_data< PrimaryKey, SecondaryKey, FeatureValue >::postings_data ( )
default

PrimaryKeys may only be integral types or strings; SecondaryKeys may only be integral types.

postings_data is default-constructable.

§ postings_data() [2/2]

template<class PrimaryKey , class SecondaryKey , class FeatureValue >
meta::index::postings_data< PrimaryKey, SecondaryKey, FeatureValue >::postings_data ( PrimaryKey  p_id)

Creates an empty postings_data for a given PrimaryKey.

Parameters
p_idThe PrimaryKey to be associated with this postings_data

Member Function Documentation

§ merge_with()

template<class PrimaryKey , class SecondaryKey , class FeatureValue >
template<class Container >
void meta::index::postings_data< PrimaryKey, SecondaryKey, FeatureValue >::merge_with ( Container &&  cont)
Parameters
contThe other container (of SecondaryKey, count pairs) to merge Adds the parameter's data to this object's data

§ increase_count()

template<class PrimaryKey , class SecondaryKey , class FeatureValue >
void meta::index::postings_data< PrimaryKey, SecondaryKey, FeatureValue >::increase_count ( SecondaryKey  s_id,
FeatureValue  amount 
)
Parameters
s_idThe SecondaryKey's id to add counts for
amountThe number of times to increase the count for a given SecondaryKey

§ count()

template<class PrimaryKey , class SecondaryKey , class FeatureValue >
FeatureValue meta::index::postings_data< PrimaryKey, SecondaryKey, FeatureValue >::count ( SecondaryKey  s_id) const
Parameters
s_idThe SecondaryKey id to query
Returns
the number of times SecondaryKey occurred in this postings_data

§ counts()

template<class PrimaryKey , class SecondaryKey , class FeatureValue >
auto meta::index::postings_data< PrimaryKey, SecondaryKey, FeatureValue >::counts ( ) const
Returns
the per-SecondaryKey frequency information for this PrimaryKey

§ set_counts() [1/3]

template<class PrimaryKey , class SecondaryKey , class FeatureValue >
void meta::index::postings_data< PrimaryKey, SecondaryKey, FeatureValue >::set_counts ( const count_t &  counts)
Parameters
countsA map of counts to assign into this postings_data

§ set_counts() [2/3]

template<class PrimaryKey , class SecondaryKey , class FeatureValue >
void meta::index::postings_data< PrimaryKey, SecondaryKey, FeatureValue >::set_counts ( count_t &&  counts)
Parameters
countsA vector of counts to assign into this postings_data

§ set_counts() [3/3]

template<class PrimaryKey , class SecondaryKey , class FeatureValue >
template<class InputIterator >
void meta::index::postings_data< PrimaryKey, SecondaryKey, FeatureValue >::set_counts ( InputIterator  begin,
InputIterator  end 
)
Parameters
beginThe beginning of the counts to assign into this postings_data
endThe end of the counts to assign into this postings_data

§ operator<()

template<class PrimaryKey , class SecondaryKey , class FeatureValue >
bool meta::index::postings_data< PrimaryKey, SecondaryKey, FeatureValue >::operator< ( const postings_data< PrimaryKey, SecondaryKey, FeatureValue > &  other) const
Parameters
otherThe postings_data to compare with
Returns
whether this postings_data is less than (has a smaller PrimaryKey than) the parameter

§ write_packed()

template<class PrimaryKey , class SecondaryKey , class FeatureValue >
uint64_t meta::index::postings_data< PrimaryKey, SecondaryKey, FeatureValue >::write_packed ( std::ostream &  out) const

Writes this postings data to an output stream in a packed binary format.

Parameters
outThe stream to write to
Returns
the number of bytes used to write out this postings data

§ write_packed_counts()

template<class PrimaryKey , class SecondaryKey , class FeatureValue >
uint64_t meta::index::postings_data< PrimaryKey, SecondaryKey, FeatureValue >::write_packed_counts ( std::ostream &  out) const

Writes this postings data's counts to an output stream in a packed binary format.

Parameters
outThe stream to write to
Returns
the number of bytes used to write out this postings data's counts

§ read_packed()

template<class PrimaryKey , class SecondaryKey , class FeatureValue >
template<class InputStream >
uint64_t meta::index::postings_data< PrimaryKey, SecondaryKey, FeatureValue >::read_packed ( InputStream &  in)

Reads a postings data object from an input stream in a packed binary format.

Parameters
inThe stream to read from
Returns
the number of bytes read in consuming this postings data

§ primary_key()

template<class PrimaryKey , class SecondaryKey , class FeatureValue >
const PrimaryKey & meta::index::postings_data< PrimaryKey, SecondaryKey, FeatureValue >::primary_key ( ) const
Returns
the term_id for this postings_data

§ set_primary_key()

template<class PrimaryKey , class SecondaryKey , class FeatureValue >
void meta::index::postings_data< PrimaryKey, SecondaryKey, FeatureValue >::set_primary_key ( PrimaryKey  new_key)
Parameters
new_key

§ inverse_frequency()

template<class PrimaryKey , class SecondaryKey , class FeatureValue = uint64_t>
uint64_t meta::index::postings_data< PrimaryKey, SecondaryKey, FeatureValue >::inverse_frequency ( ) const
Returns
the number of SecondaryKeys that this PrimaryKey occurs with

§ bytes_used()

template<class PrimaryKey , class SecondaryKey , class FeatureValue >
uint64_t meta::index::postings_data< PrimaryKey, SecondaryKey, FeatureValue >::bytes_used ( ) const
Returns
the number of bytes used for this postings_data

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