|
The way you do this is to NOT use a field, ONLY use a pointer that is first Allocated to 1 record, and then Reallocated for an additional record each time you read another record in. This creates a completely dynamic and contiguous memory block that holds the records for the file. The externally described Data Structure to the file is Based on a Pointer, and you re-calculate this pointer to the correct position in the dynamic memory block. Under V4R4, you are supposed to be able to Allocate up to a terabyte of memory, but there are special considerations for large memory blocks, and you should read about these in the RPG Reference. Another technique in the RPG Programmer's guide is to create a Linked List. The problem with this is that it requires at least 2 pointers per record, and possibly 3, and creates a lot of pointer management issues. The above technique requires only 1 pointer for the data, and an additional pointer for the Based Data Structure. > ---------- > From: M. Lazarus[SMTP:mlazarus@ttec.com] > Reply To: RPG400-L@midrange.com > Sent: Friday, December 08, 2000 11:00 AM > To: RPG400-L@midrange.com > Subject: Based variables > > Hi all, > > I have a program that uses a based (not to waste unused memory) array, > DIM'ed to the max (32,767). The reason I chose that route is for > performance. The application must output the same batch data multiple > times, once for each store. > > In order to do this via a *PF, I would have to read each batch over and > over in order to output the batch for each store. That just rubs me > wrong, > since there can be up to 5,000 stores and an undetermined number of > batches. > > My solution was to read through a batch, loading the array via an > externally described DS referencing the input file, moving the pointer up > for each record. > > So far, this works well, since the current expected maximum number of > records per batch is less than 5,000. I'm trying to think ahead and would > > like to accommodate a much larger batch. > Input record length that I am storing in the array is 148. > > According to the RPG manual, ALLOC can handle 16,776,704 bytes. Is > there > a way I can create a based field that would handle the maximum > length? That would bump up the maximum records from 32,767 to 113,356 > (16776704 / 148). > > I know that this can be done via a *USRSPC, but wouldn't that incur > additional disk I/O? > > > Store file = primary > > Store ID > 1 > 5 > 6 > 10 > etc... (5,000 maximum) > > > Batch file = secondary > > Batch Seq# > 1 1 > 1 2 > 2 1 > 2 2 > 2 3 > 2 4 > etc. etc. > > Output > > Store Batch Seq# > 1 1 1 > 1 1 2 > 1 2 1 > 1 2 2 > 1 2 3 > 1 2 4 > 5 1 1 > 5 1 2 > 5 2 1 > 5 2 2 > 5 2 3 > 5 2 4 > 6 1 1 > 6 1 2 > 6 2 1 > 6 2 2 > 6 2 3 > 6 2 4 > etc. etc. > > > Any suggestions? > > TIA. > > -mark > > +--- > | This is the RPG/400 Mailing List! > | To submit a new message, send your mail to RPG400-L@midrange.com. > | To subscribe to this list send email to RPG400-L-SUB@midrange.com. > | To unsubscribe from this list send email to RPG400-L-UNSUB@midrange.com. > | Questions should be directed to the list owner/operator: > david@midrange.com > +--- > +--- | This is the RPG/400 Mailing List! | To submit a new message, send your mail to RPG400-L@midrange.com. | To subscribe to this list send email to RPG400-L-SUB@midrange.com. | To unsubscribe from this list send email to RPG400-L-UNSUB@midrange.com. | Questions should be directed to the list owner/operator: david@midrange.com +---
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.