119 std::cout <<
"==== Printout of Sql structures ===== " << std::endl;
121 std::cout <<
"=========== End printout ============ " << std::endl;
170 if ((shift >= 0) && (shift <= fObjectsInfos->GetLast())) {
178 Info(
"SqlObjectInfo",
"Standard not works %lld", objid);
222 Info(
"SqlObjectData",
"After request res = 0x%zx", (
size_t)alldata);
238 Error(
"SqlObjectData",
"Missmatch in pools map !!! CANNOT BE !!!");
246 Error(
"SqlObjectData",
"Can not find row for objid = %lld in table %s", objid, sqlinfo->
GetClassTableName());
255 blobdata =
fSQL->GetBlobClassData(objid, sqlinfo);
257 return new TSQLObjectData(sqlinfo, objid, classdata, classrow, blobdata, blobstmt);
266 Int_t streamer_index)
269 Info(
"SqlWriteObject",
"Object: %p Class: %s", obj, (cl ? cl->
GetName() :
"null"));
287 Info(
"SqlWriteObject",
"Find objectid %ld", (
long)objid);
303 (*streamer)(*
this, (
void *)obj, streamer_index);
305 ((
TClass *)cl)->Streamer((
void *)obj, *
this);
308 Info(
"SqlWriteObject",
"Done write of %s", cl->
GetName());
319 const TClass *onFileClass)
330 if (!refid || (strlen(refid) == 0)) {
331 Error(
"SqlReadObject",
"Invalid object reference value");
339 Info(
"SqlReadObject",
"Starting objid: %ld column: %s", (
long)objid,
fCurrentData->GetLocatedField());
345 }
else if (objid == -1) {
348 void *obj1 =
nullptr;
359 if ((
gDebug > 3) && findptr)
360 Info(
"SqlReadObject",
"Found pointer %p cl %s", obj, ((cl && *cl) ? (*cl)->GetName() :
"null"));
369 Error(
"SqlReadObject",
"Object reference or pointer is not found in blob data");
376 if ((
gDebug > 2) || (objid < 0))
377 Info(
"SqlReadObject",
"Found object reference %ld", (
long)objid);
396 Info(
"SqlReadObjectDirect",
"objid = %lld clname = %s ver = %d", objid, clname.
Data(), version);
404 if (!objClass || !sqlinfo) {
405 Error(
"SqlReadObjectDirect",
"Class %s is not known", clname.
Data());
410 obj = objClass->
New();
437 Error(
"SqlReadObjectDirect",
"No found raw data for obj %lld in class %s version %d table", objid,
438 clname.
Data(), version);
450 (*streamer)(*
this, (
void *)obj, streamer_index);
452 objClass->
Streamer((
void *)obj, *
this, onFileClass);
458 Info(
"SqlReadObjectDirect",
"Read object of class %s done", objClass->
GetName());
482 Info(
"IncrementLevel",
"Info: %s", info->
GetName());
493 if (
Stack()->GetElement())
501 Info(
"DecrementLevel",
"Info: %s", info->
GetName());
511 if (
Stack()->GetElement())
517 Error(
"SetStreamerElementNumber",
"Error in structures stack");
558 if (classversion < 0)
598 Error(
"ClassMember",
"Invalid member name");
607 if (strcmp(typeName,
"raw:data") == 0)
618 if (strcmp(
name, typeName) == 0) {
626 if (tname[tname.
Length() - 1] ==
'*') {
632 Error(
"ClassMember",
"Invalid class specifier %s", typeName);
657 }
else if ((typ_id > 0) && (typ_id < 20)) {
673 Error(
"ClassMember",
"Invalid combination name = %s type = %s",
name, typeName);
709 sobjid.
Form(
"%lld", objid);
714 Error(
"WorkWithClass",
"cannot define object id");
721 Error(
"WorkWithClass",
"Can not find table for class %s version %d", classname, classversion);
728 Error(
"WorkWithClass",
"Request error for data of object %lld for class %s version %d", objid, classname,
749 Info(
"WorkWithElement",
"elem = %s", elem->
GetName());
763 Error(
"WorkWithElement",
"Object data is lost");
773 Error(
"WorkWithElement",
"Cannot locate correct column in the table");
817 Info(
"ReadVersion",
"from buffer = %d", (
int)res);
822 Info(
"ReadVersion",
"from blob %s = %d",
fCurrentData->GetBlobPrefixName(), (
int)res);
825 Error(
"ReadVersion",
"No correspondent tags to read version");
871 Info(
"WriteObjectClass",
"class %s", (actualClass ? actualClass->
GetName() :
" null"));
882 Info(
"SqlReadArrayContent",
"size %d", (
int)(arrsize));
884 Int_t indx(0), first, last;
886 while (indx < arrsize) {
889 sscanf(
name,
"[%d", &first);
892 sscanf(
name,
"[%d..%d", &first, &last);
894 if ((first != indx) || (last < first) || (last >= arrsize)) {
895 Error(
"SqlReadArrayContent",
"Error reading array content %s",
name);
901 arr[indx++] = arr[first];
904 while (indx < arrsize)
909 Info(
"SqlReadArrayContent",
"done");
1138template <
typename T>
1161 if (!buf || (
n <= 0))
1166 memcpy(
c, buf,
size);
1276 const TClass *onFileClass)
1279 Info(
"ReadFastArray",
"(void *");
1287 int objectSize = cl->
Size();
1288 char *obj = (
char *)
start;
1289 char *end = obj +
n * objectSize;
1291 for (; obj < end; obj += objectSize) {
1304 const TClass *onFileClass)
1307 Info(
"ReadFastArray",
"(void ** pre = %d n = %d", isPreAlloc,
n);
1320 for (
Int_t j = 0; j <
n; j++) {
1326 (*streamer)(*
this, (
void *)
start,
n);
1334 for (
Int_t j = 0; j <
n; j++) {
1350 for (
Int_t j = 0; j <
n; j++) {
1358 Info(
"ReadFastArray",
"(void ** Done");
1370 if (!value || (strlen(value) == 0))
1372 Int_t sz = atoi(value);
1376template <
typename T>
1379 if (!withsize && (arrsize <= 0))
1381 if (arrsize > std::numeric_limits<Int_t>::max()) {
1382 Fatal(
"SqlWriteArray",
"Array larger than 2^31 elements cannot be stored in SQL");
1388 while (indx < arrsize) {
1389 Int_t curr = indx++;
1390 while ((indx < arrsize) && (arr[indx] == arr[curr]))
1396 for (; indx < arrsize; indx++) {
1655 char *obj = (
char *)
start;
1684 (*streamer)(*
this, (
void *)
start,
n);
1698 if (!strInfo && !
start[j] && !oldStyle)
1729 ((
TObject *)obj)->TObject::Streamer(*
this);
1732 ((
TNamed *)obj)->TNamed::Streamer(*
this);
1738 Info(
"StreamObject",
"class %s", (cl ? cl->
GetName() :
"none"));
1749 const TClass *onFileClass)
1755 Info(
"StreamObjectExtra",
"class = %s", cl->
GetName());
1897 char *data =
new char[nbig+1];
1925 const char *data = s.
Data();
1939 Error(
"ReadStdString",
"The std::string address is nullptr but should not");
1954 obj->resize(nbig,
'\0');
1957 obj->resize(nwh,
'\0');
1979 Int_t nbig = obj->length();
2005 s =
new char[nch + 1];
2144 snprintf(buf,
sizeof(buf),
"%d", value);
2154 snprintf(buf,
sizeof(buf),
"%hd", value);
2164 snprintf(buf,
sizeof(buf),
"%d", value);
2174 snprintf(buf,
sizeof(buf),
"%ld", value);
2183 std::string buf = std::to_string(value);
2221 snprintf(buf,
sizeof(buf),
"%u", value);
2231 snprintf(buf,
sizeof(buf),
"%hu", value);
2241 snprintf(buf,
sizeof(buf),
"%u", value);
2251 snprintf(buf,
sizeof(buf),
"%lu", value);
2260 std::string buf = std::to_string(value);
2283 sscanf(res,
"%d", &
n);
2296 sscanf(res,
"%hd", &value);
2308 sscanf(res,
"%d", &value);
2320 sscanf(res,
"%ld", &value);
2344 sscanf(res,
"%f", &value);
2356 sscanf(res,
"%lf", &value);
2381 sscanf(res,
"%ud", &
n);
2394 sscanf(res,
"%hud", &value);
2406 sscanf(res,
"%u", &value);
2418 sscanf(res,
"%lu", &value);
2444 Error(
"SqlReadValue",
"No object data to read from");
2476 Int_t strid =
fSQL->IsLongStringCode(objid, res);
2518 while ((depth-- > 0) && curr)
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
unsigned short UShort_t
Unsigned Short integer 2 bytes (unsigned short).
int Int_t
Signed integer 4 bytes (int).
short Version_t
Class version identifier (short).
unsigned char UChar_t
Unsigned Character 1 byte (unsigned char).
char Char_t
Character 1 byte (char).
unsigned int UInt_t
Unsigned integer 4 bytes (unsigned int).
unsigned long ULong_t
Unsigned long integer 4 bytes (unsigned long). Size depends on architecture.
long Long_t
Signed long integer 4 bytes (long). Size depends on architecture.
bool Bool_t
Boolean (0=false, 1=true) (bool).
short Short_t
Signed Short integer 2 bytes (short).
double Double_t
Double 8 bytes.
long long Long64_t
Portable signed long integer 8 bytes.
unsigned long long ULong64_t
Portable unsigned long integer 8 bytes.
float Float_t
Float 4 bytes (float).
void ForceWriteInfo(TVirtualStreamerInfo *info, Bool_t force) override
force writing the TStreamerInfo to the file
void MapObject(const TObject *obj, UInt_t offset=1) override
Add object to the fMap container.
Long64_t GetObjectTag(const void *obj)
Returns tag for specified object from objects map (if exists) Returns 0 if object not included into o...
void GetMappedObject(UInt_t tag, void *&ptr, TClass *&ClassPtr) const override
Retrieve the object stored in the buffer's object map at 'tag' Set ptr and ClassPtr respectively to t...
Int_t WriteObjectAny(const void *obj, const TClass *ptrClass, Bool_t cacheReuse=kTRUE) override
Write object to I/O buffer.
Long64_t fObjIdCounter
! counter of objects id
void SetStreamerElementNumber(TStreamerElement *elem, Int_t comp_type) final
Function is called from TStreamerInfo WriteBuffer and Readbuffer functions and add/verify next elemen...
TSQLStructure * PopStack()
Pop stack.
Bool_t SqlObjectInfo(Long64_t objid, TString &clname, Version_t &version)
Returns object info like classname and version Should be taken from buffer, which is produced in the ...
void ClassBegin(const TClass *, Version_t=-1) final
This method inform buffer data of which class now will be streamed.
void StreamObjectExtra(void *obj, TMemberStreamer *streamer, const TClass *cl, Int_t n=0, const TClass *onFileClass=nullptr)
Stream object to/from buffer.
void ReadUShort(UShort_t &s) final
Reads UShort_t value from buffer.
Long64_t fFirstObjId
! id of first object to be read from the database
Bool_t SqlWriteBasic(Char_t value)
converts Char_t to string and creates correspondent sql structure
void WriteFastArrayString(const Char_t *c, Long64_t n) final
Write array of n characters into the I/O buffer.
TSQLObjectData * fCurrentData
!
Int_t fErrorFlag
! Error id value
void WriteShort(Short_t s) final
Writes Short_t value to buffer.
void DecrementLevel(TVirtualStreamerInfo *) final
Function is called from TStreamerInfo WriteBuffer and Readbuffer functions and decrease level in sql ...
void WriteULong64(ULong64_t l) final
Writes ULong64_t value to buffer.
void WriteChar(Char_t c) final
Writes Char_t value to buffer.
void WriteCharStar(char *s) final
Write a char* string.
void WriteCharP(const Char_t *c) final
Writes array of characters to buffer.
void WriteFastArray(const Bool_t *b, Long64_t n) final
Write array of Bool_t to buffer.
Long64_t fLastObjId
! id of last object correspond to this key
void WriteInt(Int_t i) final
Writes Int_t value to buffer.
TSQLStructure * PushStack()
Push stack with structural information about streamed object.
void * ReadObjectAny(const TClass *clCast) final
Read object from buffer. Only used from TBuffer.
void ReadLong64(Long64_t &l) final
Reads Long64_t value from buffer.
Int_t SqlReadArray(T *&arr, Bool_t is_static=kFALSE)
void WriteULong(ULong_t l) final
Writes ULong_t value to buffer.
void WriteUInt(UInt_t i) final
Writes UInt_t value to buffer.
void ReadLong(Long_t &l) final
Reads Long_t value from buffer.
void WriteLong(Long_t l) final
Writes Long_t value to buffer.
Int_t fIOVersion
! I/O version from TSQLFile
void WriteUShort(UShort_t s) final
Writes UShort_t value to buffer.
TSQLFile * fSQL
! instance of TSQLFile
Int_t ReadStaticArray(Bool_t *b) final
Read array of Bool_t from buffer.
void WriteStdString(const std::string *s) final
Write a std::string.
Int_t fReadVersionBuffer
! buffer, used to by ReadVersion method
void ClassMember(const char *name, const char *typeName=nullptr, Int_t arrsize1=-1, Int_t arrsize2=-1) final
Method indicates name and typename of class memeber, which should be now streamed in custom streamer ...
void ReadFastArray(Bool_t *b, Int_t n) final
Read array of Bool_t from buffer.
void StreamObject(void *obj, const TClass *cl, const TClass *onFileClass=nullptr) final
Stream object to/from buffer.
Bool_t fIgnoreVerification
! ignore verification of names
void ReadUChar(UChar_t &c) final
Reads UChar_t value from buffer.
void ReadShort(Short_t &s) final
Reads Short_t value from buffer.
void ReadBool(Bool_t &b) final
Reads Bool_t value from buffer.
void ReadTString(TString &s) final
Read a TString.
TBufferSQL2()
Default constructor, should not be used.
void ReadFastArrayString(Char_t *c, Int_t n) final
Read array of n characters from the I/O buffer.
TVirtualStreamerInfo * GetInfo() final
Return current streamer info element.
TSQLStructure * fStructure
! structures, created by object storing
void WriteBool(Bool_t b) final
Writes Bool_t value to buffer.
TClass * ReadClass(const TClass *cl=nullptr, UInt_t *objTag=nullptr) final
Suppressed function of TBuffer.
UInt_t WriteVersion(const TClass *cl, Bool_t useBcnt=kFALSE) final
Copies class version to buffer, but not writes it to sql immidiately Version will be used to produce ...
void ReadCharP(Char_t *c) final
Reads array of characters from buffer.
TMap * fPoolsMap
! map of pools with data from different tables
TSQLStructure * Stack(Int_t depth=0)
returns head of stack
void ClassEnd(const TClass *) final
Method indicates end of streaming of classdata in custom streamer.
void ReadFloat(Float_t &f) final
Reads Float_t value from buffer.
void SetCompressionLevel(int level)
const char * SqlReadValue(const char *tname)
Read string value from current stack node.
TString fReadBuffer
! Buffer for read value
TSQLStructure * fStk
! pointer on current active structure (stack head)
void ReadUInt(UInt_t &i) final
Reads UInt_t value from buffer.
const char * SqlReadCharStarValue()
Read CharStar value, if it has special code, request it from large table.
void SqlReadArrayContent(T *arr, Int_t arrsize, Bool_t withsize)
Template method to read array content.
friend class TSQLStructure
void WriteClass(const TClass *cl) final
Suppressed function of TBuffer.
Int_t SqlReadArraySize()
Reads array size, written in raw data table.
void * SqlReadObject(void *obj, TClass **cl=nullptr, TMemberStreamer *streamer=nullptr, Int_t streamer_index=0, const TClass *onFileClass=nullptr)
Read object from the buffer.
void WorkWithClass(const char *classname, Version_t classversion)
This function is a part of IncrementLevel method.
void IncrementLevel(TVirtualStreamerInfo *) final
Function is called from TStreamerInfo WriteBuffer and Readbuffer functions and indent new level in da...
Int_t ReadArray(Bool_t *&b) final
Read array of Bool_t from buffer.
void ReadChar(Char_t &c) final
Reads Char_t value from buffer.
Int_t SqlWriteObject(const void *obj, const TClass *objClass, Bool_t cacheReuse, TMemberStreamer *streamer=nullptr, Int_t streamer_index=0)
Write object to buffer.
void WriteArray(const Bool_t *b, Int_t n) final
Write array of Bool_t to buffer.
void ReadStdString(std::string *s) final
Read a std::string.
void ReadDouble(Double_t &d) final
Reads Double_t value from buffer.
void SqlReadFastArray(T *arr, Int_t arrsize)
Template method to read content of array, which not include size of array.
void ReadCharStar(char *&s) final
Read a char* string.
void ReadInt(Int_t &i) final
Reads Int_t value from buffer.
void SkipObjectAny() final
?
Bool_t SqlWriteValue(const char *value, const char *tname)
void WriteTString(const TString &s) final
Write a TString.
void * SqlReadObjectDirect(void *obj, TClass **cl, Long64_t objid, TMemberStreamer *streamer=nullptr, Int_t streamer_index=0, const TClass *onFileClass=nullptr)
Read object data.
void WriteFloat(Float_t f) final
Writes Float_t value to buffer.
void WorkWithElement(TStreamerElement *elem, Int_t comp_type)
This function is a part of SetStreamerElementNumber method.
void WriteObjectClass(const void *actualObjStart, const TClass *actualClass, Bool_t cacheReuse) final
Write object to buffer. Only used from TBuffer.
TSQLObjectData * SqlObjectData(Long64_t objid, TSQLClassInfo *sqlinfo)
Creates TSQLObjectData for specified object id and specified class.
TSQLStructure * SqlWriteAny(const void *obj, const TClass *cl, Long64_t objid)
Convert object of any class to sql structures Return pointer on created TSQLStructure TSQLStructure o...
void WriteDouble(Double_t d) final
Writes Double_t value to buffer.
void ReadULong64(ULong64_t &l) final
Reads ULong64_t value from buffer.
void WriteUChar(UChar_t c) final
Writes UChar_t value to buffer.
void SqlWriteArray(T *arr, Long64_t arrsize, Bool_t withsize=kFALSE)
void * SqlReadAny(Long64_t keyid, Long64_t objid, TClass **cl, void *obj=nullptr)
Recreate object from sql structure.
Version_t ReadVersion(UInt_t *start=nullptr, UInt_t *bcnt=nullptr, const TClass *cl=nullptr) final
Read version value from buffer actually version is normally defined by table name and kept in interme...
TObjArray * fObjectsInfos
! array of objects info for selected key
~TBufferSQL2() override
Destroy sql buffer.
void WriteLong64(Long64_t l) final
Writes Long64_t value to buffer.
void SqlReadBasic(Char_t &value)
Read current value from table and convert it to Char_t value.
Int_t fCompressLevel
! compress level used to minimize size of data in database
void ReadULong(ULong_t &l) final
Reads ULong_t value from buffer.
static const char * ConvertFloat(Float_t v, char *buf, unsigned len, Bool_t not_optimize=kFALSE)
convert float to string with configured format
TBufferText()
Default constructor.
static const char * ConvertDouble(Double_t v, char *buf, unsigned len, Bool_t not_optimize=kFALSE)
convert float to string with configured format
TClass instances represent classes, structs and namespaces in the ROOT type system.
void Streamer(void *obj, TBuffer &b, const TClass *onfile_class=nullptr) const
void * New(ENewType defConstructor=kClassNew, Bool_t quiet=kFALSE) const
Return a pointer to a newly allocated object of this class.
Int_t Size() const
Return size of object of this class.
Bool_t IsTObject() const
Return kTRUE is the class inherits from TObject.
Version_t GetClassVersion() const
static TClass * GetClass(const char *name, Bool_t load=kTRUE, Bool_t silent=kFALSE)
Static method returning pointer to TClass of the specified class name.
Basic data type descriptor (datatype information is obtained from CINT).
Int_t GetCompressionLevel() const
TMap implements an associative array of (key,value) pairs using a THashTable for efficient retrieval ...
virtual void SetOnFileClass(const TClass *cl)
The TNamed class is the base class for all named ROOT classes.
const char * GetName() const override
Returns name of object.
Int_t IndexOf(const TObject *obj) const override
Mother of all ROOT objects.
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
virtual void Fatal(const char *method, const char *msgfmt,...) const
Issue fatal error message.
virtual void Info(const char *method, const char *msgfmt,...) const
Issue info message.
Contains information about tables specific to one class and version.
Bool_t IsClassTableExist() const
const char * GetClassTableName() const
Access an SQL db via the TFile interface.
Int_t GetIOVersion() const
TSQLRow * GetObjectRow(Long64_t objid)
Returns single sql row with object data for that class.
TSQLResult * GetClassData() const
TSQLClassInfo * GetSqlInfo() const
TSQLObjectData is used in TBufferSQL2 class in reading procedure.
Bool_t PrepareForRawData()
prepare to read data from raw table
Info (classname, version) about object in database.
Version_t GetObjVersion() const
const char * GetObjClassName() const
Long64_t GetObjId() const
TSQLStructure * GetParent() const
Int_t LocateElementColumn(TSQLFile *f, TBufferSQL2 *buf, TSQLObjectData *data)
find column in TSQLObjectData object, which correspond to current element
void AddVersion(const TClass *cl, Int_t version=-100)
add child as version
void SetObjectPointer(Long64_t ptrid)
set structure type as kSqlPointer
void SetArray(Int_t sz=-1)
Set structure as array element.
TSQLObjectData * GetObjectData(Bool_t search=false)
searches for objects data
TStreamerInfo * GetStreamerInfo() const
return TStreamerInfo* if type is kSqlStreamerInfo
void SetCustomClass(const TClass *cl, Version_t version)
set structure type as kSqlCustomClass
static Bool_t UnpackTString(TSQLFile *f, TBufferSQL2 *buf, TSQLObjectData *data, Long64_t objid, Int_t clversion)
Unpack TString data in form, accepted by custom TString streamer.
void AddValue(const char *value, const char *tname=nullptr)
Add child structure as value.
void SetStreamerInfo(const TStreamerInfo *info)
set structure type as kSqlStreamerInfo
void AddObjectData(TSQLObjectData *objdata)
add element with pointer to object data
static Bool_t UnpackTObject(TSQLFile *f, TBufferSQL2 *buf, TSQLObjectData *data, Long64_t objid, Int_t clversion)
Unpack TObject data in form, accepted by custom TObject streamer.
void ChangeValueOnly(const char *value)
change value of this structure used as "workaround" to keep object id in kSqlElement node
void SetCustomElement(TStreamerElement *elem)
set structure type as kSqlCustomElement
void SetObjectRef(Long64_t refid, const TClass *cl)
set structure type as kSqlObject
Long64_t DefineObjectId(Bool_t recursive=kTRUE)
defines current object id, to which this structure belong make life complicated, because some objects...
TStreamerElement * GetElement() const
return TStremerElement* if type is kSqlElement
void SetStreamerElement(const TStreamerElement *elem, Int_t number)
set structure type as kSqlElement
void ChildArrayIndex(Int_t index, Int_t cnt=1)
set array index for last child element if (cnt<=1) return;
Describe one element (data member) to be Streamed.
virtual void SetArrayDim(Int_t dim)
Set number of array dimensions.
virtual void SetMaxIndex(Int_t dim, Int_t max)
set maximum index for array with dimension dim
Describes a persistent version of a class.
TObjArray * GetElements() const override
Int_t Atoi() const
Return integer value of string.
const char * Data() const
void Resize(Ssiz_t n)
Resize the string. Truncate or add blanks as necessary.
void Form(const char *fmt,...)
Formats a string using a printf style format descriptor.
Abstract Interface class describing Streamer information for one class.
static Bool_t CanDelete()
static function returning true if ReadBuffer can delete object
virtual Int_t GetClassVersion() const =0