Page 1 of 1
Writing / reading collection of Arrays.
Posted: Sat Mar 11, 2017 11:08 pm
by monki
So, I will have 60 to 70 separate arrays that will populate a bunch of interface fields and controls, 10 or so, when the group is clicked. Some fields have the usual mix of standard punctuation--commas, quotes, hyphens, etc--associated with writing, but no tabs. The arrays are simple. The keys for each array holds the control name (button "summary menu"), and the value holds the value that control will be set to.
My question is, how best to write and read these arrays to files? Would it be better to save each object's array separately in its own file? Creating a bunch of files to deal with. Or, collect all the arrays together and write them to a single file? How best to do that so they can be separated out for each object again? Would nesting the arrays and encoding them work? Or would they decode into a mess? I'm not trying to encrypt the data at all, I could just parse it out into a text file and create a parse method to bring it all back in. But don't want to go to a bunch of work that's not needed if there's an existing method for doing this.
Thanks.
Re: Writing / reading collection of Arrays.
Posted: Sat Mar 11, 2017 11:25 pm
by FourthWorld
LC's arrayEncode and arrayDecode functions are pretty efficient for what they do. Personally, for the sake of simplicity of nothing else, unless I absolutely needed those as separate arrays I'd be tempted to put them all as sub-arrays in one larger array, and then just setialize/deserialze for disk I/O in one move.
Re: Writing / reading collection of Arrays.
Posted: Sat Mar 11, 2017 11:38 pm
by monki
FourthWorld wrote:LC's arrayEncode and arrayDecode functions are pretty efficient for what they do. Personally, for the sake of simplicity of nothing else, unless I absolutely needed those as separate arrays I'd be tempted to put them all as sub-arrays in one larger array, and then just setialize/deserialze for disk I/O in one move.
I would like to keep them as separate arrays, but could I just place the arrays into single array and save that? Set the key to the objectName and save its array to that key's value?
MasterArray
- key = objectName, vlu = object's array
key = objectName, vlu = object's array
key = objectName, vlu = object's array
etc. 60 times
If array encode/decode can handle 600 values and keep them all connected, that sounds like the way to go. I'm just getting my head wrapped around this whole array thing, so still not sure what the limits are.
Thanks.
Re: Writing / reading collection of Arrays.
Posted: Sat Mar 11, 2017 11:58 pm
by FourthWorld
The outline for the master array you showed looks good to me. Just make sure each key is indeed unique and you should be fine.
There are limits to arrays, but I don't know what they are. Somewhere up in the millions of keys, or so I've heard, but that may be dependent on other factors like the amount of data stored in each element, or the depth of subarrays across so many arrays, etc.
The only firm guidance on limits with arrays that I can offer is that LC's internal address using 4-byte integers, so a serialized array is logically limited to about 4GB. And of course LC's internal mapping must exist within that space, so by the time we account for the engine, any objects in RAM, the array elements, their pointers, and the serialized copy, actual size limit would be much smaller, likely > 2 GB. On some systems actual size will be further limited by other factors, such as what the relevant OS APIs support for a given operation.
But in your case, unless those variables contain really large amounts of data, I think you'd be more than fine with 600 elements. You could probably go up a couple orders of magnitude if you need and still never run into limits.
Re: Writing / reading collection of Arrays.
Posted: Sun Mar 12, 2017 1:43 am
by monki
OK, I'll go that route then.
Thanks
