Hi Jon, Pulling this topic out of the other e-mail chain.
On Mon, Jun 4, 2012 at 6:00 AM, Sahananda (Jon) Wolfers <[email protected]> wrote: > I have been thinking about this some more, and I think that the low level > structure Mark is aiming for where you have an array where the first element > is metadata and the rest is data will make any high level wrapper around it > difficult to code and probably rather inefficient (assuming I have > understood correctly what he is aiming for). > > To dig a single column out of a dataset would then require something like > this: > > do row over rows~section(2) -- skip the metadata > say row[rows[1]~index('fieldname')] > end > > Which feels very awkward to me I'm saying this as a joke: Well you can always make something awkward and inefficient by making it arbitrarily move complex than needed. ;-) This is not inefficient nor awkward: colIndex = getColumnIndex(rows, 'fieldname') do i = 2 to rows~items row = rows[i]; say row[colIndex] end This code: do i = 1 to rows~items row = rows[i] -- do something with row end I think will always be more efficient than do row over rows -- do something with row end on large arrays because I'm pretty sure do row over rows creates a second array as big as the first. rows~section(2) returns a new array. So your do row over rows~section(2) probably has the original array and 2 copies of that array involved. And really, I would just code: do i = 2 to rows~items row = rows[i] say row[3] end knowing that 'fieldname' was column 3. But, in all seriousness. Lee's point about the database schema changing is a good one. And, I'm not arguing that a result set needs to be returned as an array of arrays. I'm saying maybe the user should be allowed to specify how they want the result set formed. As another data point, in the current ooSQLite implementation, I would code this, which shows start to finish for your 'dig a single column out' where 'fieldname' is 'name' in this database: dbConn = .ooSQLiteDB~new('ooFoods.rdbx') stmt = .ooSQLiteStmt~new(dbConn, "SELECT * FROM foods") index = stmt~columnIndex('name') do while stmt~step == .ooSQL~row say stmt~columnText(index) end Your: > do row over rows~section(2) -- skip the metadata > say row[rows[1]~index('fieldname')] > end doesn't show opening the database or executing the query, so I think the current code I showed is pretty equivalent. > I never like using that, and my opinion fwiw is that it would be better to > create a structure where the data and metadata are kept separate even at the > low level design. That is actually pretty close to what an ooSQLiteStmt object is. Originally I was going to have a result set class. But I'm not sure I see any real advantage to that at this point. -- Mark Miesfeld ------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ _______________________________________________ Oorexx-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/oorexx-devel
