BOSS 7.0.8
BESIII Offline Software System
Loading...
Searching...
No Matches
rdbModel::Row Class Reference

#include <Column.h>

Public Member Functions

 Row ()
 
 Row (std::vector< FieldVal > &fields)
 
 ~Row ()
 
void rowSort ()
 
void addField (const FieldVal &f)
 
void clear ()
 
FieldValfind (std::string colname)
 
void regroup (std::vector< std::string > &colNames, std::vector< std::string > &colVals, std::vector< std::string > &nullCols) const
 Reorder information suitable for Connection::insert.
 

Detailed Description

 @class Row

A collection of column names and values.

Definition at line 150 of file Column.h.

Constructor & Destructor Documentation

◆ Row() [1/2]

rdbModel::Row::Row ( )
inline

Definition at line 152 of file Column.h.

152: m_sorted(false) {m_fields.clear();}

◆ Row() [2/2]

rdbModel::Row::Row ( std::vector< FieldVal > &  fields)
inline

Definition at line 153 of file Column.h.

153: m_fields(fields), m_sorted(false) {}

◆ ~Row()

rdbModel::Row::~Row ( )
inline

Definition at line 155 of file Column.h.

155{ m_fields.clear(); }

Member Function Documentation

◆ addField()

void rdbModel::Row::addField ( const FieldVal f)
inline

Definition at line 157 of file Column.h.

157{m_fields.push_back(f); m_sorted = false;}
TFile f("ana_bhabha660a_dqa_mcPat_zy_old.root")

Referenced by rdbModel::Table::supersedeRow().

◆ clear()

void rdbModel::Row::clear ( )
inline

Definition at line 158 of file Column.h.

158{m_fields.clear();}

◆ find()

FieldVal * rdbModel::Row::find ( std::string  colname)

Definition at line 73 of file Column.cxx.

73 {
74 unsigned nField = m_fields.size();
75 unsigned minI = 0;
76 unsigned maxI = nField;
77
78 unsigned guess = maxI/2;
79 unsigned oldGuess = nField;
80
81 int cmp = colname.compare(m_fields[guess].m_colname);
82
83 while (cmp != 0) {
84 if (guess == oldGuess) return 0; // not found
85
86 if (cmp < 0 ) { // thing we tried is > colName, so decrease maxI
87 maxI = guess;
88 } else { // thing we tried is > colName, so increase minI
89 minI = guess;
90 }
91 oldGuess = guess;
92 guess = (minI + maxI)/2;
93 cmp = colname.compare(m_fields[guess].m_colname);
94 }
95 return &m_fields[guess];
96 }

Referenced by rdbModel::Table::insertLatest(), rdbModel::Table::insertRow(), rdbModel::Assertion::Operator::Operator(), rdbModel::Table::supersedeRow(), and rdbModel::Assertion::Operator::verify().

◆ regroup()

void rdbModel::Row::regroup ( std::vector< std::string > &  colNames,
std::vector< std::string > &  colVals,
std::vector< std::string > &  nullCols 
) const

Reorder information suitable for Connection::insert.

Definition at line 98 of file Column.cxx.

100 {
101 unsigned nFields = m_fields.size();
102 colNames.reserve(nFields);
103 colVals.reserve(nFields);
104
105 for (unsigned i = 0; i < nFields; i++) {
106 if (m_fields[i].m_null) {
107 nullCols.push_back(m_fields[i].m_colname);
108 }
109 else {
110 colNames.push_back(m_fields[i].m_colname);
111 colVals.push_back(m_fields[i].m_val);
112 }
113 }
114 }

Referenced by rdbModel::Table::insertLatest(), rdbModel::Table::insertRow(), and rdbModel::Table::updateRows().

◆ rowSort()

void rdbModel::Row::rowSort ( )

Definition at line 65 of file Column.cxx.

65 {
66 if (m_sorted) return;
67
68 FieldValCompare cmp;
69 std::sort(m_fields.begin(), m_fields.end(), cmp);
70 m_sorted = true;
71 }

Referenced by rdbModel::Assertion::Assertion(), rdbModel::Table::insertLatest(), rdbModel::Table::insertRow(), rdbModel::Table::supersedeRow(), rdbModel::Table::updateRows(), and rdbModel::Assertion::verify().


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