14 fObjDB->select_data(
"objTable",
"unique_id",
Form(
"name = \"%s\"", name.Data()));
16 while (fObjDB->get_next_result())
17 uuid = get_objTable()[
"unique_id"].get_data<
KVString>();
31 if (it !=
fObjList.end())
return it->second;
57 if (
OPT.Contains(
"CREATE")) {
62 TString rpath = FP +
"objStore.root";
67 TString sqlpath = FP +
"objInfos.sqlite";
70 if (
OPT.Contains(
"CREATE")) {
90 if (!
fObjDB->has_table(
"objInfos")) {
98 fObjDB->add_missing_columns(
"objInfos", infos);
105 obj->
Write(unique_id);
109 fObjDB->prepare_data_insertion(
"objTable");
113 fObjDB->insert_data_row();
114 fObjDB->end_data_insertion();
116 fObjDB->select_data(
"objTable",
"obj_idx",
Form(
"unique_id=\"%s\"", unique_id.
Data()));
118 while (
fObjDB->get_next_result()) obj_idx =
get_objTable()[
"obj_idx"].get_data<
int>();
120 fObjDB->prepare_data_insertion(
"objInfos");
122 info_copy.
SetValue(
"obj_idx", obj_idx);
126 fObjDB->insert_data_row();
127 fObjDB->end_data_insertion();
154 while (!colnames.
End()) {
155 std::cout << colnames.
Next() << tabs;
157 std::cout <<
"\n==========================================================================================\n";
158 if (
fObjDB->select_data(
"objTable,objInfos", colnames)) {
159 while (
fObjDB->get_next_result()) {
161 while (!colnames.
End()) {
162 auto colname = colnames.
Next();
163 if (colname ==
"name" || colname ==
"class")
168 std::cout << std::endl;
172 Error(
"ls",
"Problem with KVSQLite::database::select_data");
221 fObjDB->select_data(
"objTable,objInfos",
"unique_id", where);
222 while (
fObjDB->get_next_result()) {
278 fObjDB->select_data(
"objTable,objInfos",
Form(
"unique_id,%s", numberlist_column.
Data()), where);
279 while (
fObjDB->get_next_result()) {
ClassImp(KVPartitionList) void KVPartitionList
Initialisation.
char * Form(const char *fmt,...)
R__EXTERN TSystem * gSystem
Handles lists of named parameters with different types, a list of KVNamedParameter objects.
void SetValue(const Char_t *name, value_type value)
Strings used to represent a set of ranges of values.
Bool_t Contains(Int_t val) const
returns kTRUE if the value 'val' is contained in the ranges defined by the number list
Combine ROOT file containing objects with SQLite database with info on the objects.
void WriteObject(const TObject *, const KVNameValueList &)
Write object in ROOT file, store infos given in list.
void FillListOfObjectsWithSelection(KVSeqCollection *list, const KVString &where)
KVSQLite::table & get_objTable() const
KVSQLite::table & get_objInfos() const
TObject * Get(const KVString &name) const
Return pointer to object with given name.
void ls(Option_t *="") const
List the contents of the file with associated infos.
std::unordered_map< std::string, TObject * > fObjList
for quick look-up of objects using unique id
TObject * get_object_with_UUID(const KVString &name) const
Retrieve object from file using its name.
void restore_working_directory()
KVString UUID_for_object(const KVString &) const
Return unique identifier used to store object with given name in ROOT file.
std::unique_ptr< TFile > fObjStore
std::unique_ptr< KVSQLite::database > fObjDB
KVSQLROOTFile(const KVString &filepath, Option_t *option="READ")
void save_working_directory()
Interface to ROOT SQLite database backend ,.
const column & add_primary_key(const TString &name)
TString get_column_names(const TString &exclude="", const TString &delim=",") const
column & add_column(const KVSQLite::column &c)
const column & add_foreign_key(const TString &other_table, const TString &other_column)
void prepare_data(const KVNameValueList &, const KVNamedParameter *=nullptr)
KaliVeda extensions to ROOT collection classes.
virtual void Add(TObject *obj)
Extension of ROOT TString class which allows backwards compatibility with ROOT v3....
void Begin(TString delim) const
KVString Next(Bool_t strip_whitespace=kFALSE) const
virtual Int_t Write(const char *name=0, Int_t option=0, Int_t bufsize=0)
virtual const char * GetName() const
virtual const char * ClassName() const
virtual void Error(const char *method, const char *msgfmt,...) const
TString & Append(char c, Ssiz_t rep=1)
const char * Data() const
virtual int mkdir(const char *name, Bool_t recursive=kFALSE)
virtual char * ExpandPathName(const char *path)
virtual int Unlink(const char *name)
const char * AsString() const