Skip to content

Commit 078fbdb

Browse files
committed
Small fixes in use of existing raw buffer in TBranch
1 parent 24802e7 commit 078fbdb

File tree

2 files changed

+45
-40
lines changed

2 files changed

+45
-40
lines changed

scripts/JSRootIOEvolution.js

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -631,6 +631,29 @@
631631
return obj;
632632
}
633633

634+
JSROOT.TBuffer.prototype.ReadBasketEntryOffset = function(basket, offset) {
635+
// this is remaining part of TBasket streamer to decode fEntryOffset
636+
// after unzipping of the TBasket data
637+
638+
this.locate(basket.fLast - offset);
639+
640+
if (this.remain() <= 0) {
641+
if (!basket.fEntryOffset && (basket.fNevBuf <=1)) basket.fEntryOffset = [ basket.fKeylen ];
642+
if (!basket.fEntryOffset) console.warn("No fEntryOffset when expected for basket with", basket.fNevBuf, "entries");
643+
return;
644+
}
645+
646+
basket.fEntryOffset = this.ReadFastArray(this.ntoi4(), JSROOT.IO.kInt);
647+
if (!basket.fEntryOffset) basket.fEntryOffset = [ basket.fKeylen ];
648+
649+
if (this.remain() > 0)
650+
basket.fDisplacement = this.ReadFastArray(this.ntoi4(), JSROOT.IO.kInt);
651+
else
652+
basket.fDisplacement = undefined;
653+
654+
return basket;
655+
}
656+
634657
JSROOT.TBuffer.prototype.ReadTRef = function(obj) {
635658
this.ClassStreamer(obj, "TObject");
636659
if (obj.fBits & JSROOT.IO.kHasUUID)
@@ -1960,7 +1983,6 @@
19601983
buf.CheckBytecount(ver, this.typename);
19611984
}
19621985

1963-
19641986
} else {
19651987
JSROOT.console('fail to provide function for ' + element.fName + ' (' + element.fTypeName + ') typ = ' + element.fType);
19661988
member.func = function(buf,obj) {

scripts/JSRootTree.js

Lines changed: 22 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1409,15 +1409,25 @@
14091409
staged_prev: 0, // entry limit of previous I/O request
14101410
staged_now: 0, // entry limit of current I/O request
14111411
progress_showtm: 0, // last time when progress was showed
1412-
GetBasketEntry : function(k) {
1412+
GetBasketEntry: function(k) {
14131413
if (!this.branch || (k > this.branch.fMaxBaskets)) return 0;
14141414
var res = (k < this.branch.fMaxBaskets) ? this.branch.fBasketEntry[k] : 0;
14151415
if (res) return res;
14161416
var bskt = (k>0) ? this.branch.fBaskets.arr[k-1] : null;
14171417
return bskt ? (this.branch.fBasketEntry[k-1] + bskt.fNevBuf) : 0;
14181418
},
1419-
LocateBuffer : function(entry) {
1420-
// locate buffer position like GetEntry()
1419+
GetTarget: function(tgtobj) {
1420+
// returns target object which should be used for the branch reading
1421+
if (!this.tgt) return tgtobj;
1422+
for (var k=0;k<this.tgt.length;++k) {
1423+
var sub = this.tgt[k];
1424+
if (!tgtobj[sub.name]) tgtobj[sub.name] = sub.lst.Create();
1425+
tgtobj = tgtobj[sub.name];
1426+
}
1427+
return tgtobj;
1428+
},
1429+
GetEntry: function(entry, tgtobj) {
1430+
// This should be equivalent to TBranch::GetEntry() method
14211431
var shift = entry - this.first_entry, off;
14221432
if (!this.branch.TestBit(JSROOT.IO.BranchBits.kDoNotUseBufferMap))
14231433
this.raw.ClearObjectMap();
@@ -1429,15 +1439,8 @@
14291439
off = this.basket.fKeylen + this.basket.fNevBufSize * shift;
14301440
}
14311441
this.raw.locate(off - this.raw.raw_shift);
1432-
},
1433-
GetTarget : function(tgtobj) {
1434-
if (!this.tgt) return tgtobj;
1435-
for (var k=0;k<this.tgt.length;++k) {
1436-
var sub = this.tgt[k];
1437-
if (!tgtobj[sub.name]) tgtobj[sub.name] = sub.lst.Create();
1438-
tgtobj = tgtobj[sub.name];
1439-
}
1440-
return tgtobj;
1442+
1443+
this.member.func(this.raw, this.GetTarget(tgtobj));
14411444
}
14421445
};
14431446

@@ -2043,25 +2046,6 @@
20432046
handle.selector.ShowProgress(portion);
20442047
}
20452048

2046-
function ReadBasketEntryOffset(branch, basket, buf) {
2047-
if (branch.fEntryOffsetLen <= 0) return;
2048-
2049-
// ready entry offest len when necessary
2050-
2051-
buf.locate(basket.fLast - buf.raw_shift);
2052-
2053-
basket.fEntryOffset = buf.ReadFastArray(buf.ntoi4(), JSROOT.IO.kInt);
2054-
if (!basket.fEntryOffset) basket.fEntryOffset = [ basket.fKeylen ];
2055-
2056-
if (buf.remain() > 0)
2057-
basket.fDisplacement = buf.ReadFastArray(buf.ntoi4(), JSROOT.IO.kInt);
2058-
else
2059-
basket.fDisplacement = undefined;
2060-
2061-
// rollback buffer - not needed in the future
2062-
// buf.locate(buf.raw_shift);
2063-
}
2064-
20652049
function ProcessBlobs(blobs) {
20662050
if (!blobs || ((places.length>2) && (blobs.length*2 !== places.length)))
20672051
return JSROOT.CallBack(baskets_call_back, null);
@@ -2103,7 +2087,8 @@
21032087

21042088
bitems[k].raw = buf; // here already unpacket buffer
21052089

2106-
ReadBasketEntryOffset(bitems[k].branch, basket, buf);
2090+
if (bitems[k].branch.fEntryOffsetLen > 0)
2091+
buf.ReadBasketEntryOffset(basket, buf.raw_shift);
21072092
}
21082093

21092094
if (ExtractPlaces())
@@ -2170,10 +2155,10 @@
21702155
bitem.raw.locate(0); // reset pointer - same branch may be read several times
21712156
else
21722157
bitem.raw = JSROOT.CreateTBuffer(null, 0, handle.file); // create dummy buffer - basket has no data
2173-
bitem.raw.raw_shift = 0;
2158+
bitem.raw.raw_shift = bskt.fKeylen;
21742159

2175-
if (bskt.fBufferRef)
2176-
ReadBasketEntryOffset(elem.branch, bskt, bitem.raw);
2160+
if (bskt.fBufferRef && (elem.branch.fEntryOffsetLen > 0))
2161+
bitem.raw.ReadBasketEntryOffset(bskt, bitem.raw.raw_shift);
21772162

21782163
bitem.bskt_obj = bskt;
21792164
is_direct = true;
@@ -2302,14 +2287,12 @@
23022287

23032288
// main processing loop
23042289
while(loopentries--) {
2290+
23052291
for (n=0;n<handle.arr.length;++n) {
23062292
elem = handle.arr[n];
23072293

23082294
// locate buffer offest at proper place
2309-
elem.LocateBuffer(handle.current_entry);
2310-
2311-
// read only element where entry id matches
2312-
elem.member.func(elem.raw, elem.GetTarget(handle.selector.tgtobj));
2295+
elem.GetEntry(handle.current_entry, handle.selector.tgtobj);
23132296
}
23142297

23152298
handle.selector.Process(handle.current_entry);

0 commit comments

Comments
 (0)