SwatDB
Loading...
Searching...
No Matches
Public Member Functions | Private Member Functions | Private Attributes | List of all members
RelOpsManager Class Reference

#include <relopsmgr.h>

Collaboration diagram for RelOpsManager:
Collaboration graph
[legend]

Public Member Functions

 RelOpsManager (FileManager *file_mgr, BufferManager *buf_mgr, Catalog *catalog, const char *result_path)
 Creates SwatDB Relops layer, the interface to the relational operations functionality of the DB.
 
HeapFileproject (FileId rel_id, std::vector< FieldId > fields)
 Runs the Project operation.
 
HeapFileselect (SelectType stype, FileId rel_id, std::vector< FieldId > fields, std::vector< Comp > comps, std::vector< void * > values, FileId index_id=INVALID_FILE_ID)
 Runs the Select operation using the type of select given by the argument stype.
 
HeapFilejoin (JoinType jtype, FileId o_fid, FileId i_fid, std::vector< FieldId > outer_field_ids, std::vector< FieldId > inner_field_ids, std::uint32_t block_size=0)
 Runs the Join operation using the type of join given by the argument jtype. This overloaded function only runs TupleNLJ and BlockNLJ, the others are implemented in the other overloaded versions.
 
HeapFilejoin (JoinType jtype, FileId o_fid, FileId i_fid, std::uint32_t num_buckets, std::vector< FieldId > outer_field_ids, std::vector< FieldId > inner_field_ids, std::uint32_t num_threads=0)
 Runs the Join operation using the type of join given by the argument jtype. This overloaded function only runs HashJoin and ParallelHashJoin, the others are implemented in the other overloaded versions.
 
bool checkFilesEqual (FileId file1_id, FileId file2_id)
 Checks if two files have identical contents (every record in file1 also exists in file2 with the exact same value). This is done by running a join on all columns and returning true if the resulting file has the same number of records as the original files. Note: this will only work if neither files have any duplicates.
 

Private Member Functions

FileId _createJoinRes (FileId outer_fid, FileId inner_fid, std::vector< FieldId > o_fields, std::vector< FieldId > i_fields)
 
FileId _createProjectRes (Schema *rel_schema, std::vector< FieldId > fields)
 
FileId _createResultFile (Schema *schema)
 

Private Attributes

FileManagerfile_mgr
 
BufferManagerbuf_mgr
 
Catalogcatalog
 
int result_num
 

Detailed Description

SwatDB RelOpsManager Class. The interface to relational operators layer of the system: manages relational operators.

Constructor & Destructor Documentation

◆ RelOpsManager()

RelOpsManager::RelOpsManager ( FileManager file_mgr,
BufferManager buf_mgr,
Catalog catalog,
const char *  result_path 
)

Creates SwatDB Relops layer, the interface to the relational operations functionality of the DB.

Precondition
Input parameter objects (file_mgr, buf_mgr, catalog) are initialized and valid.
Parameters
file_mgrPointer to the SwatDB FileManager.
buf_mgrPointer to the SwatDB BufferManager.
catalogPointer to the SwatDB Catalog.
result_pathif not NULL, sets the file path for operator results

Member Function Documentation

◆ _createJoinRes()

FileId RelOpsManager::_createJoinRes ( FileId  outer_fid,
FileId  inner_fid,
std::vector< FieldId o_fields,
std::vector< FieldId i_fields 
)
private

Creates a result file with the schema of the joined relations

◆ _createProjectRes()

FileId RelOpsManager::_createProjectRes ( Schema rel_schema,
std::vector< FieldId fields 
)
private

Creates a result file with the schema of rel_schema, but only the fields in the fields parameter. Used for the project operation.

◆ _createResultFile()

FileId RelOpsManager::_createResultFile ( Schema schema)
private

Creates a result file with the schema given using result_num, then increments result_num

◆ checkFilesEqual()

bool RelOpsManager::checkFilesEqual ( FileId  file1_id,
FileId  file2_id 
)

Checks if two files have identical contents (every record in file1 also exists in file2 with the exact same value). This is done by running a join on all columns and returning true if the resulting file has the same number of records as the original files. Note: this will only work if neither files have any duplicates.

Precondition
Files have the same schema and no duplicate records.
Parameters
file1_id.FileId of first file to be compared.
file2_id.FileId of second file to be compared.
Exceptions
InvalidSchemaHeapFileif schemas do not match.
Returns
True if files are identical, False otherwise.

◆ join() [1/2]

HeapFile * RelOpsManager::join ( JoinType  jtype,
FileId  o_fid,
FileId  i_fid,
std::uint32_t  num_buckets,
std::vector< FieldId outer_field_ids,
std::vector< FieldId inner_field_ids,
std::uint32_t  num_threads = 0 
)

Runs the Join operation using the type of join given by the argument jtype. This overloaded function only runs HashJoin and ParallelHashJoin, the others are implemented in the other overloaded versions.

Precondition
Input parameters o_fid and i_fid are valid relation ids and fields and values align.
Parameters
jtype.JoinType indicating type of join (tuplenlj, blocknlj, etc)
o_fid.FileId of the outer relation of the join.
i_fid.FileId of the inner relation of the join.
outer_field_ids.Vector of field ids for the outer relation.
inner_field_ids.Vector of field ids for the inner relation.
num_buckets.Number of buckets used for hash joins..
num_threads.Number of threads for parallel hash join.

◆ join() [2/2]

HeapFile * RelOpsManager::join ( JoinType  jtype,
FileId  o_fid,
FileId  i_fid,
std::vector< FieldId outer_field_ids,
std::vector< FieldId inner_field_ids,
std::uint32_t  block_size = 0 
)

Runs the Join operation using the type of join given by the argument jtype. This overloaded function only runs TupleNLJ and BlockNLJ, the others are implemented in the other overloaded versions.

Precondition
Input parameters o_fid and i_fid are valid relation ids and fields and values align.
Parameters
jtype.JoinType indicating type of join (tuplenlj, blocknlj, etc)
o_fid.FileId of the outer relation of the join.
i_fid.FileId of the inner relation of the join.
outer_field_ids.Vector of field ids for the outer relation.
inner_field_ids.Vector of field ids for the inner relation.
block_size.Uint32 indicating block size if block nlj is run. This parameter is also used as the inner_index_id if the jtype is indexNLJ.

◆ project()

HeapFile * RelOpsManager::project ( FileId  rel_id,
std::vector< FieldId fields 
)

Runs the Project operation.

Precondition
Input parameters rel_id is a valid relation id to be projected on
Parameters
rel_id.FileId corresponding to relation fileid being projected on
fields.Vector of fieldids corresponding to fields being projected on`
Returns
HeapFile * of the result file with results of the project.

◆ select()

HeapFile * RelOpsManager::select ( SelectType  stype,
FileId  rel_id,
std::vector< FieldId fields,
std::vector< Comp >  comps,
std::vector< void * >  values,
FileId  index_id = INVALID_FILE_ID 
)

Runs the Select operation using the type of select given by the argument stype.

Precondition
Input parameters rel_id is a valid relation id to be selected on, and fields and values have the same types.
Parameters
stype.SelectType indicating type of select (filescan, index)
rel_id.FileId corresponding to relation fileid being selected on
fields.Vector of fieldids corresponding to fields being selected on
comps.Vector of Comp corresponding to comparators for selection
values.Vector of void * corresponding to values for selection
index_id.FileId with default value INVALID_FILE_ID corresponding to index file id if indexscan is being used.
Returns
HeapFile * of the result file with results of the select.

Member Data Documentation

◆ result_num

int RelOpsManager::result_num
private

Stores the current result number


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