Hi Rene,
thanks for answering. I see it now in the code of TBranch::GetEntry(). It's
clever, but please, add a description of this feature in the htmldoc and
user guide. It may cause a hidden bug in user programs. See what I did:
UInt_t fTradeIndex;
fTradeIndexTree->SetBranchAddress("TradeIndex", &fTradeIndex);
::GetFirst(DayNumber) {
fTradeIndexTree->GetEntry(DayNumber);
}
::GetNext()
{
while ()
fTradeIndex++;
...
}
If you run GetFirst() GetNext() sequence first time, it works fine. If you
run it second time for the same DayNumber, it will give wrong answer!
Regards,
Anton
http://www.smartquant.com
----- Original Message -----
From: Rene Brun <brun@pcbrun.cern.ch>
To: Anton Fokin <anton.fokin@smartquant.com>
Cc: roottalk <roottalk@pcroot.cern.ch>; Rene Brun <Rene.Brun@cern.ch>
Sent: Monday, March 05, 2001 11:59 PM
Subject: Re: Tree
> Anton,
> This result is correct. GetEntry returns the number of bytes read from the
> file. In case you read the same entry again, Root does not have to do any
> I/O unless the branch addresses have changed. In this case GetEntry
> returns 1 (I cannot return 0 because many people uses 0 to assume that
> an error has occured during reading).
>
> Rene Brun
>
> On Mon, 5 Mar 2001, Anton Fokin wrote:
>
> > Hi Rene,
> >
> > I've got the following strange result. The piece of code is (I simply
read
> > the same entry three times)
> >
> > ---
> >
> > Index = 4;
> >
> > Int_t NBytes = fTradeIndexTree->GetEntry(Index);
> >
> > printf("NBytes = %d\n", NBytes);
> >
> > NBytes = fTradeIndexTree->GetEntry(Index);
> >
> > printf("NBytes = %d\n", NBytes);
> >
> > NBytes = fTradeIndexTree->GetEntry(Index);
> >
> > printf("NBytes = %d\n", NBytes);
> >
> > ---
> >
> > the output:
> >
> > NBytes = 4
> > NBytes = 1
> > NBytes = 1
> >
> > I also see that I fill my fTradeIndex in the first read only.
> >
> > If I insert
> >
> > fTradeIndexTree->SetBranchAddress("TradeIndex", &fTradeIndex);
> >
> > before every GetEntry(), I get right result.
> >
> > fTradeIndexTree is simple:
> >
> > UInt_t TradeIndex = 0;
> > TradeIndexTree->Branch("TradeIndex", &TradeIndex, "TradeIndex/i",
16*1024);
> >
> >
> > Any ideas how it can happen in principle? Any hints to trace the problem
> > down?
> >
> > Root3.05 on win98
> >
> > Regards,
> > Anton
> >
> > http://www.smartquant.com
> >
> >
> >
>
>
>
This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:50:38 MET