souffle  2.0.2-371-g6315b36
Data Structures | Public Member Functions | Private Attributes
souffle::RecordMap Class Reference

Bidirectional mappping between records and record references. More...

#include <RecordTable.h>

Collaboration diagram for souffle::RecordMap:
Collaboration graph

Data Structures

struct  RecordHash
 hash function for unordered record map More...
 

Public Member Functions

RamDomain pack (const RamDomain *tuple)
 convert record pointer to a record reference More...
 
RamDomain pack (std::vector< RamDomain > vector)
 converts record to a record reference More...
 
 RecordMap (size_t arity)
 
const RamDomainunpack (RamDomain index) const
 convert record reference to a record pointer More...
 

Private Attributes

const size_t arity
 arity of record More...
 
std::vector< std::vector< RamDomain > > indexToRecord
 array of records; index represents record reference More...
 
std::unordered_map< std::vector< RamDomain >, RamDomain, RecordHashrecordToIndex
 map from records to references More...
 

Detailed Description

Bidirectional mappping between records and record references.

Definition at line 40 of file RecordTable.h.

Constructor & Destructor Documentation

◆ RecordMap()

souffle::RecordMap::RecordMap ( size_t  arity)
inlineexplicit

Definition at line 72 of file RecordTable.h.

Member Function Documentation

◆ pack() [1/2]

RamDomain souffle::RecordMap::pack ( const RamDomain tuple)
inline

convert record pointer to a record reference

Definition at line 97 of file RecordTable.h.

99  {
100  const RamDomain* res;
101 #pragma omp critical(record_unpack)
102  res = indexToRecord[index].data();
103  return res;
104  }
105 };
106 
107 class RecordTable {
108 public:
109  RecordTable() = default;
110  virtual ~RecordTable() = default;

References indexToRecord.

◆ pack() [2/2]

RamDomain souffle::RecordMap::pack ( std::vector< RamDomain vector)
inline

converts record to a record reference

Definition at line 76 of file RecordTable.h.

83  {
84  // TODO (b-scholz): data is unnecessarily copied
85  // for a successful lookup. To avoid this, we should
86  // compute a hash of the pointer-array and traverse through
87  // the bucket list of the unordered map finding the record.
88  // Note that in case of non-existence, the record still needs to be
89  // copied for the newly created entry but this will be the less
90  // frequent case.
91  std::vector<RamDomain> tmp(arity);
92  for (size_t i = 0; i < arity; i++) {
93  tmp[i] = tuple[i];
94  }

◆ unpack()

const RamDomain* souffle::RecordMap::unpack ( RamDomain  index) const
inline

convert record reference to a record pointer

Definition at line 113 of file RecordTable.h.

113  {
114  return lookupArity(arity).pack(tuple);
115  }
116  /** @brief convert record reference to a record */
117  const RamDomain* unpack(RamDomain ref, size_t arity) const {
118  std::unordered_map<size_t, RecordMap>::const_iterator iter;

Field Documentation

◆ arity

const size_t souffle::RecordMap::arity
private

arity of record

Definition at line 49 of file RecordTable.h.

◆ indexToRecord

std::vector<std::vector<RamDomain> > souffle::RecordMap::indexToRecord
private

array of records; index represents record reference

Definition at line 69 of file RecordTable.h.

Referenced by pack().

◆ recordToIndex

std::unordered_map<std::vector<RamDomain>, RamDomain, RecordHash> souffle::RecordMap::recordToIndex
private

map from records to references

Definition at line 65 of file RecordTable.h.


The documentation for this class was generated from the following file:
souffle::RamDomain
int32_t RamDomain
Definition: RamTypes.h:56
souffle::RecordMap::unpack
const RamDomain * unpack(RamDomain index) const
convert record reference to a record pointer
Definition: RecordTable.h:113
i
size_t i
Definition: json11.h:663
souffle::RecordMap::indexToRecord
std::vector< std::vector< RamDomain > > indexToRecord
array of records; index represents record reference
Definition: RecordTable.h:69
souffle::RecordMap::arity
const size_t arity
arity of record
Definition: RecordTable.h:49