1 /* Copyright (C) 2014 InfiniDB, Inc.
2 
3    This program is free software; you can redistribute it and/or
4    modify it under the terms of the GNU General Public License
5    as published by the Free Software Foundation; version 2 of
6    the License.
7 
8    This program is distributed in the hope that it will be useful,
9    but WITHOUT ANY WARRANTY; without even the implied warranty of
10    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11    GNU General Public License for more details.
12 
13    You should have received a copy of the GNU General Public License
14    along with this program; if not, write to the Free Software
15    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
16    MA 02110-1301, USA. */
17 
18 /***************************************************************************
19  *
20  *   $Id: filerequest.cpp 2055 2013-02-08 19:09:09Z pleblanc $
21  *
22  *   jrodriguez@calpont.com   *
23  *                                                                         *
24  ***************************************************************************/
25 #include <iostream>
26 using namespace std;
27 
28 #include "filerequest.h"
29 
30 namespace dbbc
31 {
32 
fileRequest()33 fileRequest::fileRequest() :
34     data(0), fLBID(-1), fVer(-1), fFlg(false), fTxn(-1), fRqstType(LBIDREQUEST), fCompType(0),
35     cache(true), wasVersioned(false)
36 {
37     init(); //resets fFRPredicate, fLength, fblksRead, fblksLoaded, fRqstStatus
38 }
39 
fileRequest(BRM::LBID_t lbid,const BRM::QueryContext & ver,bool flg,BRM::VER_t txn,int compType,uint8_t * ptr,bool cacheIt)40 fileRequest::fileRequest(BRM::LBID_t lbid, const BRM::QueryContext& ver, bool flg, BRM::VER_t txn, int compType,
41                          uint8_t* ptr, bool cacheIt) :
42     data(ptr), fLBID(lbid), fVer(ver), fFlg(flg), fTxn(txn), fRqstType(LBIDREQUEST), fCompType(compType),
43     cache(cacheIt), wasVersioned(false)
44 {
45     init(); //resets fFRPredicate, fLength, fblksRead, fblksLoaded, fRqstStatus
46     fLength = 1;
47 }
48 
fileRequest(const BRM::InlineLBIDRange & range,const BRM::QueryContext & ver,BRM::VER_t txn,int compType)49 fileRequest::fileRequest(const BRM::InlineLBIDRange& range, const BRM::QueryContext& ver, BRM::VER_t txn, int compType) :
50     data(0), fLBID(range.start), fVer(ver), fFlg(false), fTxn(txn), fLength(range.size),
51     fRqstType(RANGEREQUEST), fCompType(compType), cache(true), wasVersioned(false)
52 {
53     init(); //resets fFRPredicate, fLength, fblksRead, fblksLoaded, fRqstStatus
54     fLength = range.size;
55 }
56 
fileRequest(const fileRequest & blk)57 fileRequest::fileRequest(const fileRequest& blk)
58 {
59     fLBID = blk.fLBID;
60     fVer = blk.fVer;
61     fTxn = blk.fTxn;
62     fFlg = blk.fFlg;
63     fRqstType = blk.fRqstType;
64     fRqstStatusString = blk.fRqstStatusString;
65     data = blk.data;
66     fCompType = blk.fCompType;
67     cache = blk.cache;
68     wasVersioned = blk.wasVersioned;
69     init(); //resets fFRPredicate, fLength, fblksRead, fblksLoaded, fRqstStatus
70 }
71 
init()72 void fileRequest::init()
73 {
74     fFRPredicate = INIT;
75     fLength = 0;
76     fblksRead = 0;
77     fblksLoaded = 0;
78     fRqstStatus = SUCCESSFUL;
79 }
80 
operator <<(ostream & os,const fileRequest & rhs)81 ostream& operator<<(ostream& os, const fileRequest& rhs)
82 {
83     os
84             << "LBID: " << rhs.fLBID
85             << " ver: " << rhs.fVer
86             << " Txn: " << rhs.fTxn
87             << " len: " << rhs.fLength
88             << " read: " << rhs.fblksRead
89             << " load: " << rhs.fblksLoaded
90             << " ct: " << rhs.fCompType
91             ;
92     return os;
93 }
94 
95 }
96 
97