BadgerDB
|
00001 00009 #pragma once 00010 00011 #include <string> 00012 #include "types.h" 00013 #include "page.h" 00014 #include "buffer.h" 00015 #include "file_iterator.h" 00016 #include "page_iterator.h" 00017 00018 namespace badgerdb { 00019 00020 class FileScan 00021 { 00022 public: 00023 00027 FileScan(const std::string &name, BufMgr *bufMgr); 00028 00032 ~FileScan(); 00033 00037 void insertRecord(const std::string &rec, RecordId &outRid); 00038 00042 void deleteRecord(RecordId rid); 00043 00047 void startScan(int offset, int length, Datatype type, std::string filter, Operator op); 00048 00052 void endScan(); 00053 00057 void scanNext(RecordId& outRid); 00058 00062 std::string getRecord(); 00063 00067 std::string getRandomRecord(RecordId rid); 00068 00072 void gotoMark(RecordId rid); 00073 00077 bool matchRec(const std::string &rec); 00078 00082 void flushFile(); 00083 00087 void markDirty(); 00088 00089 protected: 00090 BufMgr *bufMgr; 00091 00092 private: 00093 PageFile *file; 00094 Page* curPage; // data page currently pinned in buffer pool 00095 FileIterator filePageIter; // page number of pinned page 00096 PageIterator pageRecordIter; // rid of last record returned 00097 bool curDirtyFlag; // true if page has been updated 00098 int offset; // byte offset of filter attribute 00099 int length; // length of filter attribute 00100 Datatype type; // datatype of filter attribute 00101 std::string filter; // comparison value of filter 00102 Operator op; // comparison operator of filter 00103 }; 00104 00105 }