Re: Arrays vs Object for Key/Value pair lookups

2017-07-20 Thread David Adams via 4D_Tech
Hey John! Glad to see you're still digging into details. C_OBJECT is great, I use it all the time. It's always nice to have more choices in 4D. (You know more languages than most people, so you doubtlessly were already missing something like C_OBJECT.) I posted speed numbers a few days ago with

Re: Arrays vs Object for Key/Value pair lookups

2017-07-20 Thread John Baughman via 4D_Tech
, the more > efficient will be associative arrays compared with classic parsing of arrays. > > My very best, > > JPR > > > >> Message: 7 >> Date: Mon, 17 Jul 2017 11:43:12 -0700 >> From: Justin Leavens <jus...@jitbusiness.com> >> To: 4D iNug Technical <4d_tech@lists.4d.com> >> Subject: Re: Arrays vs Object for Key/Value pair lookups >> Message-ID: >>

Re: Arrays vs Object for Key/Value pair lookups

2017-07-20 Thread Peter Jakobsson via 4D_Tech
On 20 Jul 2017, at 11:39, JPR via 4D_Tech <4d_tech@lists.4d.com> wrote: > In case of an object, the properties are 'indexed' by using an internal Hash > table, so the access to one particular Property doesn't need a sequential > parsing of the list of values, but an almost direct access. I

Re: Arrays vs Object for Key/Value pair lookups

2017-07-20 Thread JPR via 4D_Tech
gt; To: 4D iNug Technical <4d_tech@lists.4d.com> > Subject: Re: Arrays vs Object for Key/Value pair lookups > Message-ID: >

Re: Arrays vs Object for Key/Value pair lookups

2017-07-17 Thread Alan Chan via 4D_Tech
Case sensitive comparison support in Find in array/Find in sorted array is long overdue. Even best, supported in string compariosn operator (or new operator for string) $true:=($string1=*$string2) $true:=($string1>*$string2) $true:=($string1<*$string2) Alan Chan 4D iNug Technical

Re: Arrays vs Object for Key/Value pair lookups

2017-07-17 Thread David Adams via 4D_Tech
> "Find" commands accept wild cards and evaluate using collation algorithms (case-insensitive comparison plus some > other locale specific rules) is it really fair to compare the two against object keys? I'm not sure what "fair" means here, but it's definitely not a apples-to-apples comparison.

Re: Arrays vs Object for Key/Value pair lookups

2017-07-17 Thread Keisuke Miyako via 4D_Tech
the "Find" commands accept wild cards and evaluate using collation algorithms (case-insensitive comparison plus some other locale specific rules) is it really fair to compare the two against object keys? > 2017/07/18 9:44、David Adams via 4D_Tech <4d_tech@lists.4d.com> のメール: > > * Sequential Find

Re: Arrays vs Object for Key/Value pair lookups

2017-07-17 Thread David Adams via 4D_Tech
Hello all, I've been interested in this topic for some time but have never taken the time to run any tests. I don't have the time now (for sure), but I took some anyway. What I did was grab a huge unique word file, clear out words that are obviously illegal JSON key names and tried doing lookups

Re: Arrays vs Object for Key/Value pair lookups

2017-07-17 Thread Justin Leavens via 4D_Tech
I did a 2014 Summit presentation (5 JSON Tips) which should be available for download that demonstrated the benefits of using objects for key/value pair cache lookups, but in the end it’s pretty easy to demonstrate. The benefits start to show up with a few hundred keys, but at 100,000 it’s easily

Re: Arrays vs Object for Key/Value pair lookups

2017-07-17 Thread Peter Jakobsson via 4D_Tech
On 17 Jul 2017, at 17:03, Herr Alexander Heintz via 4D_Tech <4d_tech@lists.4d.com> wrote: > so I queried for the language I needed and then > apply to selection([dict];ob set(<>Dict;[dict]WordKey;[dict]Word) Ah ! So you just ‘hoover up’ into your dictionary object. Like a hoover ? Peter

Re: Arrays vs Object for Key/Value pair lookups

2017-07-17 Thread Herr Alexander Heintz via 4D_Tech
That’s basically it. only I don not need the wrapper anymore, i go directly to word:=OB Get(<>Dict;$t_MyKey;is Text) Using arrays I sorted the key array and used my own optimized array query routine (same as the new Find in sorted array introduced in V16). With object, no need to sort, the

Re: Arrays vs Object for Key/Value pair lookups

2017-07-17 Thread Keith Culotta via 4D_Tech
Take a look at the new http://livedoc.4d.com/4D-Language-Reference-15.4/Arrays/Find-in-sorted-array.301-3274895.en.html. This would change the FIA side of the equation. Keith - CDI > On Jul 17, 2017, at 5:46 AM, Peter Jakobsson via 4D_Tech > <4d_tech@lists.4d.com> wrote: > > Hi > > I

Re: Arrays vs Object for Key/Value pair lookups

2017-07-17 Thread David Adams via 4D_Tech
Interesting subject. Just to make sure I am able to interpret the the findings correctly, were you comparing Find in array with object find, or *binary* find in array on a sorted array? Binary search is very hard (but certainly not impossible) to compete with. If you have an array of 1,000,000

Re: Arrays vs Object for Key/Value pair lookups

2017-07-17 Thread Herr Alexander Heintz via 4D_Tech
I did a lot of testing for this as I need to keep a dictionary of words identified by word IDs with some 300 000 items around. I need to retrieve the words based on their ID. Using objects was MAGNITUDES faster than synchronised arrays (Cannot find the number anymore but we are talking

Arrays vs Object for Key/Value pair lookups

2017-07-17 Thread Peter Jakobsson via 4D_Tech
Hi I remember at last year’s summit, JPR was emphasising how objects were far more optimised than arrays for doing lookups over large numbers of key value pairs. e.g. we usually do this: $x:=find in array(myKEYS;”product_code_x”) if($x>0) $0:=myPRICES{$x} end if How do people prefer to do