15 m_writeStmt =
nullptr;
19 for(
int i=0;
i<1024;
i++){
36 this->checkConnection();
39 m_writeStmt = m_conn->createStatement();
40 m_writeStmt->setSQL(
"INSERT INTO fe_lut_per_group_dat (lut_conf_id, group_id, " 41 " lut_id, lut_value ) " 42 "VALUES (:lut_conf_id, :group_id, " 43 ":lut_id, :lut_value )" );
44 }
catch (SQLException &
e) {
45 throw(std::runtime_error(
std::string(
"FEConfigLUTGroupDat::prepareWrite(): ")+e.getMessage()));
52 this->checkConnection();
55 int iconfID = iconf->fetchID();
57 cout<<
"iconf="<< iconfID << endl;
59 if (!iconfID) {
throw(std::runtime_error(
"FEConfigLUTGroupDat::writeArrayDB: ICONF not in DB")); }
63 int* iconfid_vec=
new int[nrows];
64 int*
xx=
new int[nrows];
65 int*
yy=
new int[nrows];
66 int*
zz=
new int[nrows];
69 ub2* iconf_len=
new ub2[nrows];
70 ub2* x_len=
new ub2[nrows];
71 ub2* y_len=
new ub2[nrows];
72 ub2* z_len=
new ub2[nrows];
78 iconfid_vec[
count]=iconfID;
79 int x=item->getLUTGroupId();
97 m_writeStmt->setDataBuffer(1, (dvoid*)iconfid_vec, OCCIINT,
sizeof(iconfid_vec[0]),iconf_len);
98 m_writeStmt->setDataBuffer(2, (dvoid*)xx, OCCIINT,
sizeof(xx[0]), x_len );
99 m_writeStmt->setDataBuffer(3, (dvoid*)yy, OCCIINT ,
sizeof(yy[0]), y_len );
100 m_writeStmt->setDataBuffer(4, (dvoid*)zz, OCCIINT ,
sizeof(zz[0]), z_len );
102 m_writeStmt->executeArrayUpdate(nrows);
105 delete [] iconfid_vec;
118 }
catch (SQLException &
e) {
119 throw(std::runtime_error(
std::string(
"FEConfigLUTGroupDat::writeArrayDB(): ")+e.getMessage()));
127 this->checkConnection();
130 iconf->setConnection(m_env, m_conn);
131 int iconfID = iconf->fetchID();
133 throw(std::runtime_error(
"FEConfigLUTGroupDat::fetchData: ICONF not in DB"));
139 m_readStmt->setSQL(
"SELECT d.group_id, d.lut_id, d.lut_value " 140 "FROM fe_lut_per_group_dat d " 141 "WHERE lut_conf_id = :lut_conf_id order by d.group_id, d.lut_id ");
142 m_readStmt->setInt(1, iconfID);
143 ResultSet* rset = m_readStmt->executeQuery();
146 std::pair< EcalLogicID, FEConfigLUTGroupDat >
p;
154 while(rset->next()) {
156 int il=rset->getInt(2);
157 int ival=rset->getInt(3);
174 }
catch (SQLException &
e) {
175 throw(std::runtime_error(
std::string(
"FEConfigLUTGroupDat::fetchData: ")+e.getMessage()));
182 this->checkConnection();
183 this->checkPrepare();
185 int iconfID = iconf->fetchID();
186 if (!iconfID) {
throw(std::runtime_error(
"FEConfigLUTGroupDat::writeArrayDB: ICONF not in DB")); }
189 int nrows=
data->size()*1024;
191 int* iconfid_vec=
new int[nrows];
192 int*
xx=
new int[nrows];
193 int*
yy=
new int[nrows];
194 int*
zz=
new int[nrows];
198 ub2* iconf_len=
new ub2[nrows];
199 ub2* x_len=
new ub2[nrows];
200 ub2* y_len=
new ub2[nrows];
201 ub2* z_len=
new ub2[nrows];
206 typedef map< EcalLogicID, FEConfigLUTGroupDat >::const_iterator CI;
207 for (CI
p =
data->begin();
p !=
data->end(); ++
p) {
210 dataitem = &(
p->second);
214 for (
int i=0;
i<1024;
i++){
215 iconfid_vec[
count]=iconfID;
241 cout <<
"about to insert "<< iconfid_vec[
i]<<
" " <<xx[
i]<<
" "<< yy[
i]<<
" "<< zz[
i]<< endl;
243 cout <<
"about to insert "<< iconfid_vec[
i]<<
" " <<xx[
i]<<
" "<< yy[
i]<<
" "<< zz[
i]<< endl;
245 m_writeStmt->setDataBuffer(1, (dvoid*)iconfid_vec, OCCIINT,
sizeof(iconfid_vec[0]),iconf_len);
246 m_writeStmt->setDataBuffer(2, (dvoid*)xx, OCCIINT,
sizeof(xx[0]), x_len );
247 m_writeStmt->setDataBuffer(3, (dvoid*)yy, OCCIINT ,
sizeof(yy[0]), y_len );
248 m_writeStmt->setDataBuffer(4, (dvoid*)zz, OCCIINT ,
sizeof(zz[0]), z_len );
250 m_writeStmt->executeArrayUpdate(nrows);
253 delete [] iconfid_vec;
266 }
catch (SQLException &
e) {
267 throw(std::runtime_error(
std::string(
"FEConfigLUTGroupDat::writeArrayDB(): ")+e.getMessage()));
int getLUTGroupId() const
void setLUTGroupId(int x)
void writeArrayDB(const std::map< EcalLogicID, FEConfigLUTGroupDat > *data, FEConfigLUTInfo *iconf) noexcept(false)
void prepareWrite() noexcept(false) override
void fetchData(std::map< EcalLogicID, FEConfigLUTGroupDat > *fillMap, FEConfigLUTInfo *iconf) noexcept(false)
~FEConfigLUTGroupDat() override
void setLUTValue(int i, int x)
int getLUTValue(int i) const
void writeDB(const EcalLogicID *ecid, const FEConfigLUTGroupDat *item, FEConfigLUTInfo *iconf) noexcept(false)
char data[epos_bytes_allocation]