From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,ead02e7101c0c023 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-03-01 11:38:16 PST Path: supernews.google.com!sn-xit-02!supernews.com!news.tele.dk!213.56.195.71!fr.usenet-edu.net!usenet-edu.net!feeder1.proxad.net!grolier!club-internet!not-for-mail From: Laurent Guerby Newsgroups: comp.lang.ada Subject: Re: Problems with large records (GNAT) [continued] Date: 01 Mar 2001 20:38:55 +0100 Organization: Club-Internet (France) Message-ID: <86hf1djn3k.fsf@acm.org> References: <3A9CD67C.9B15C417@linuxchip.demon.co.uk> <86lmqq8xks.fsf@acm.org> <3A9E05B0.46B406ED@linuxchip.demon.co.uk> NNTP-Posting-Host: nas22-115.vlt.club-internet.fr X-Trace: front2m.grolier.fr 983475350 28699 195.36.172.115 (1 Mar 2001 19:35:50 GMT) NNTP-Posting-Date: 1 Mar 2001 19:35:50 GMT X-Newsreader: Gnus v5.7/Emacs 20.5 Xref: supernews.google.com comp.lang.ada:5365 Date: 2001-03-01T19:35:50+00:00 List-Id: Dr Adrian Wrigley writes: > Since you ask, I have something like the following... > ------------------------------------ > type PriceSummary_T is record > OpenPrice : Float; > HighPrice : Float; > LowPrice : Float; > ClosePrice : Float; -- Split and dividend corrected price > UncorrectedClose : Float; -- Raw share price > Volume : Integer; > Time : Time_T; > end record; > > type StockIndex_T is new Integer range 1 .. 3000; > type TradingDay_T is new Integer range 0 .. 1860; > > type DailyArray_T is array (TradingDay_T, StockIndex_T) of PriceSummary_T; > > type BooleanDailyArray_T is array (TradingDay_T, StockIndex_T) of Boolean; > pragma Pack (BooleanDailyArray_T); > > type Oracle_T is record > -- Various other record values may go here! > Tradeable : BooleanDailyArray_T; > Daily : DailyArray_T; > end record; > ------------------------------------ Nice to see we're not alone using Ada for critical applications in the financial world ;-). (Note that we have a support contract from Ada Core Technologies, if you have one you can probably discuss the record size limitation with them.) Anyway, here I would probably want a few things: - control the layout of the data to match computational access, if you process your serie along time or stock. - lazy loading (ie not mmap'ing the whole thing at once). To do so, I wouldn't put all the things in the record, I would use access types hidden behind proper abstraction. type PriceSummary_TV is array (Positive) of aliased PriceSummary_T; type PriceSummary_TVA is access all PriceSummary_TV; type Oracle_T is record N1 : Natural := 0; P1 : PriceSummary_TVA; end record; You mmap your stock history and store the pointer to it in your Oracle_T (unchecked_convertion from the address returned by mmap to PriceSummary_TVA). You need to use array of P1/N1 to implement everything. The "aliased" allow you to access any record by access instead of copy when you're hiding things. N1 is needed to do manual checking in your abstraction. Note that if you compute historical volatilities or correlations, you will probably be memory-bound performance wise (algorithm complexity proportional to data size, with a small enough computation factor so that memory access becomes dominant). -- Laurent Guerby