6 #include "larevt/CalibrationDBI/IOVData/IOVDataConstants.h" 7 #include "larevt/CalibrationDBI/IOVData/TimeStampDecoder.h" 12 #include <sys/types.h> 26 fCachedStart(0,0), fCachedEnd(0,0) {
55 int str_size = getStringValue(tup, col, buf,
kBUFFER_SIZE, &err);
57 if (std::string(buf, str_size)==
"True") {
60 else if (std::string(buf, str_size)==
"False") {
63 else std::cout<<
"(DBFolder) ERROR: Can't identify data: "<<std::string(buf, str_size)<<
" as boolean!"<<std::endl;
77 int str_size = getStringValue(tup, col, buf,
kBUFFER_SIZE, &err);
78 if (std::string(buf, str_size)==
"True") {
81 else if (std::string(buf, str_size)==
"False") {
85 data = getLongValue(tup, col, &err);
96 data = getDoubleValue(tup, col, &err);
107 int str_size = getStringValue(tup, col, buf,
kBUFFER_SIZE, &err);
108 data = std::string(buf, str_size);
131 if ( *sptr ==
'[') sptr +=1;
139 unsigned int array_size=0;
141 val = strtod(sptr, &eptr);
142 if (sptr==eptr)
break;
143 if (*sptr==
'\0')
break;
145 buf[array_size++] = val;
147 if ( *eptr ==
']')
break;
151 data.insert(data.begin(), buf, buf + array_size);
163 for (
int row = 0; row !=
fNRows; ++row) {
165 channels.push_back( (DBChannelID_t)getLongValue(tup,0,&err) );
179 if ( channel == (DBChannelID_t)getLongValue(tup,0,&err) ) {
182 else releaseTuple(tup);
190 int l = 0, h =
fNRows - 1;
195 val = getLongValue(tup, 0, &err);
198 if (val == channel )
break;
200 if (val > channel) h = row - 1;
208 if ( channel != (DBChannelID_t)getLongValue(tup, 0, &err) ) {
210 std::string msg =
"Channel " +
std::to_string(channel) +
" is not found in database!";
222 for (
size_t c=1; c <
fColumns.size(); ++c ) {
226 std::string msg =
"Column named " + name +
" is not found in the database!";
235 IOVTimeStamp ts = TimeStampDecoder::DecodeTimeStamp(raw_time);
238 if (this->
IsValid(ts))
return false;
246 std::stringstream fullurl;
248 <<
"&t=" << ts.DBStamp();
249 if (
fTag.length() > 0) fullurl <<
"&tag=" <<
fTag;
262 std::string msg =
"HTTP error from " + fullurl.str()+
": status: " +
std::to_string(status) +
": " + std::string(getHTTPmessage(
fCachedDataset));
270 std::stringstream msg;
271 msg <<
"Time " << ts.DBStamp() <<
": Data not found in database.";
281 fCachedStart = IOVTimeStamp::GetFromString(std::string(buf));
286 if ( 0 == strcmp(buf,
"-") ) {
290 fCachedEnd = IOVTimeStamp::GetFromString(std::string(buf));
297 for (
int c=0; c < getNfields(tup); ++c) {
306 for (
int c=0; c < getNfields(tup); ++c) {
const unsigned int kNUMBER_HEADER_ROWS
int GetNamedChannelData(DBChannelID_t channel, const std::string &name, bool &data)
bool UpdateData(DBTimeStamp_t raw_time)
size_t GetTupleColumn(DBChannelID_t channel, const std::string &name, Tuple &tup)
IOVTimeStamp fCachedStart
DBFolder(const std::string &name, const std::string &url, const std::string &tag="")
int GetChannelList(std::vector< DBChannelID_t > &channels) const
DBChannelID_t fCachedChannel
bool IsValid(const IOVTimeStamp &time) const
std::vector< std::string > fTypes
const unsigned int kBUFFER_SIZE
Filters for channels, events, etc.
std::vector< std::string > fColumns
std::string to_string(Flag_t< Storage > const flag)
Convert a flag into a stream (shows its index).
Collection of exception classes for WebDBI.