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 <4d_tech@lists.4d.com> writes:
>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?

**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

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. Find in array and Find in sorted array are
variants on the same thing, so they're easy to compare. Object keys? No
idea. As far as I can tell, 4D refused to offer any information about how
the work that the company will stand behind publicly. Thats okay, I'm used
to black box testing and I like it...but it's time-consuming.

The point of these comparisons isn't to figure out if one approach is
"better" than another so much as how they work *in the real world.* Put
another way, the goal is to come up with some rules of thumb about what to
use when. Binary search kicks ass, and I know why. Object key lookups kick
ass, and I don't know why. My take-away is to

* Use objects when when they're easier or more appropriate for the problem
at hand.

* Use sorted arrays when when they're easier or more appropriate for the
problem at hand.

* Don't shift from arrays to objects based on a notion that they're
"faster."

* Consider objects instead of arrays if you don't have or can't be sure of
a sorted array order because object key lookups are way faster than
sequential array traversal (Find in array.)

* Don't worry about speed at all unless you've got a solid reason to.

Thinking best on my tests, a few points for anyone that wants to tweak them:

-- If you want sequential searches to look better, just search for the
first items. Search time should be directly related to the position of the
target in the array. I avoided this trap on purpose.

-- I used very small text values for lookups and keys! Long strings might
behave differently, I don't know. I would actually find that an interesting
result, if anyone feels like checking.

-- The object keys are inserted into the test object in sorted order. This
should not make any difference if there's a hash underneath, but we don't
actually know that. Although it does see likely. From the few results I've
gotten, I'd wildly guess that there's:

-- An excellent hash function where "excellent" means "low collision, high
dispersal and fast."

-- A secondary structure off the hash bins that is itself smart. So, not a
linked list (The CS 101 approach), but a second good hash or a tree of some
kind. Or something else.

-- A pretty large range of hash slots to reduce secondary lookup times.

-- Probably some smart scheme for changing the hash table size dynamically
under stress. That's an expensive maneuver (or normally is, I can think of
ways to make it not too expensive.)

Just speculating, I'm probably wrong in every detail here. Doesn't matter.
It's a black box.
**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

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 in array
> * Binary Find in sorted array
> * Object lookup




**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

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
three ways:

* Sequential Find in array
* Binary Find in sorted array
* Object lookup

For reference, here's a link to the original file full of words:
https://github.com/dwyl/english-words/blob/master/words.zip

I tried not to bias the tests as what I'd like are useful results. Still, I
didn't test a whole lot of different ways and bias is nearly impossible to
avoid. Even if my test is totally fair, there's no way that it's complete -
results always depend on the data under test. This is part of why
algorithms are described using big O terminology. You have a way of talking
about the performance envelope around the algorithm under various sorts of
conditions. (That's a terrible description, but so be it.) As an example,
it's very easy to compare s sequential find in array with a binary search.
There are only a couple of cases where sequential is faster, no matter the
size of the array. With 4D's object lookups, we just don't know.  Even if
they are a hash table (likely but not confirmed), this doesn't tell us
much. (Hash tables have a whole lot of components in their implementation,
some of which can behave in weird ways, depending on your data set+hashing
function. It also matters what you use to find actual values, not just hash
bins.)

Anyway, here are a set of results in a compiled system with ~465,000
words/keys:

Words: 466,474
Tests: 10,000
Sequential: 107,777
Binary: 153
Object: 9

The three times are in milliseconds. As in, "Searching for 10,000 different
words in an array of 466,474 unique words took a little over 1/10th of a
second using a sorted array." That's roughly 1/2 of a blink. (Not kidding.)

Comments and take-aways:

* Binary search is great.

* Object search is great.

* Sequential search is not so great, but it still only took about 11
seconds.

* I noticed that setting up the sorted array took no time and that setting
up the object took time that I could feel. I didn't do timing results on
this. But if it's true, the *overall* time (including setup) for the object
was *unfavorable.*

Conclusion: I'll use objects when I need them and sorted arrays when I need
them. The performance difference is too small to be a factor, it will come
down to other properties of these data structures.

++ To Justin on the whole 'use the lookup value as the key' tip (Rob has
mentioned this too.) I sue that all of the time in objects, it's a really
excellent practice.

If anyone wants to re-run the tests or check my code for logic errors, dumb
errors, bias, etc., here's the code with comments:

If (False)
 // https://github.com/dwyl/english-words/blob/master/words.zip
 // Imported into a new table in 4D.
 // Cleared ones starting with numbers or punctuation.
 // 466,475 words left.
End if

  //
  // Setup
  //
ALL RECORDS([word])
ORDER BY([word];[word]word) // 4D indexed sort

ARRAY TEXT($words_at;0)
SELECTION TO ARRAY([word]word;$words_at)  // Sorted arraa of 464K+ words

C_OBJECT($words_object)
C_LONGINT($words_count)
C_LONGINT($word_index)
$words_object:=JSON Parse("{}")
$words_count:=Size of array($words_at)

For ($word_index;1;$words_count)
C_TEXT($word)
$word:=$words_at{$word_index}
 // {"hello":"HELLO"} - no reason for the lower/upper other than to make it
read in the Debugger.
OB SET($words_object;Lowercase($word);Uppercase($word))
End for

  // Let's build an array of random words from the main array of words.
C_LONGINT($test_words_count)
$test_words_count:=1  // Note: Cannot be larger than the $words_count


  // Hmmm. Not getting a good distribution of indexes from Random.
  // Instead, I'll pick words from different positions along the array.

ARRAY TEXT($test_words_at;$test_words_count)
$test_words_at{1}:=$words_at{1}  // Best case for a sequential scan
$test_words_at{2}:=$words_at{$words_count}  // Worst case for a sequential
scan

C_LONGINT($interval)
  // Now we want to fill in the rest of the test array.
  // The selected words are grabbed from even intervals along the array.

  // The speed difference for a sequential search should be linear.

  // The speed difference for a binary search should be very small amongst
words.
  // It should take up to about ~18 reads to find the word.

  // The speed difference for the object? No clue, we don't know how
they're implemented.
  // With a fast hash and a large hash table, it could be very quick. Hard
to say.
$interval:=$words_count\$test_words_count

C_LONGINT($test_word_index)
For ($test_word_index;3;$test_words_count)  // Start at 3 because we just
filled in 1 & 2 by hand.
C_LONGINT($word_index)
$word_index:=$interval*

Re: Thinking through object/text fields: Findings summarized, advice solicited

2017-07-17 Thread David Adams via 4D_Tech
Hey Lee, thanks for the suggestions, that should save me some time for sure.

On Tue, Jul 18, 2017 at 3:26 AM, Lee Hinde via 4D_Tech <4d_tech@lists.4d.com
> wrote:

> On Mon, Jul 17, 2017 at 5:40 AM, David Adams via 4D_Tech <
> 4d_tech@lists.4d.com> wrote:
>
> >
> > My biggest problem with PostgreSQL is the relative lack of nice front-end
> > tools. My beloved SequelPro for MySQL has long hinted at a PostgreSQL
> > version, but it doesn't seem to be there yet. For MySQL though, it's
> great
> > (and free):
> >
> > http://www.sequelpro.com/
> >
> > Navicat can do more (stored procedures, copy data across structures,
> better
> > trigger support, etc.) but, dang, that "Look Ma! I wrote it in Java!" UI
> is
> > just so ugly. I'll pay for it, I'll use it, I'll be grateful...but I
> won't
> > be loving it.
> >
> > Any recommendations for good PostgreSQL tools?
> >
>
>
> Agreed on how great Sequel Pro is.
>
> For Postgres, I use PostgresApp https://postgresapp.com/ to run Postgres
> on
> my mac.
>
> For the client I use Navicat Premium Essentials (their cheaper Swiss Army
> Knife tool.) It's ugly, but you can do what you need to do.
>
> The fellow who wrote the Postrgres Mac App has a client app, called
> Positco: https://eggerapps.at/postico/
>
> Something to check out.
> **
> 4D Internet Users Group (4D iNUG)
> FAQ:  http://lists.4d.com/faqnug.html
> Archive:  http://lists.4d.com/archives.html
> Options: http://lists.4d.com/mailman/options/4d_tech
> Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
> **
>
**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: Thinking through object/text fields: Findings summarized, advice solicited

2017-07-17 Thread David Adams via 4D_Tech
On Tue, Jul 18, 2017 at 2:08 AM, Kirk Brooks via 4D_Tech <
4d_tech@lists.4d.com> wrote:

> Hi John,
> I haven't done very much communicating from 4D to a SQL database so this is
> a very naive question - but could you talk about how a tool like Navicat
> helps you with 4D?


It doesn't. But if you're piping data to PostgreSQL from 4D, then it's
great to have a visual SQL client to go and look and and manipulate the
data in the outside database. It's super handy, for example, to be able to
see that all of your values transferred the way that you want.
**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Database Settings Publishing Info IP Address - Tip

2017-07-17 Thread Allan Udy via 4D_Tech

Here's another tip for the archives...

We have one client running a web server db under 4D v14.4. We're working 
at moving this to v16 in the very near future, but wanted to do a few 
tidy up's in v14 before we started the update process.


Things went badly and suddenly no one could connect to the web server.  :-(

After many hours of immense frustration trying to solve this we found 
that the following setting


  Database Settings >  Web >  Configuration >  Publishing Info >  
IP Address:


in the current source was now blank (i.e. the popup had nothing selected).

In the source on which the previous build was based, the setting was :   
   IP Address: All


Changes the setting to ALL in the current soutrce, and voila, it works 
perfectly as advertised!


We suspect that a minor upgrade from v14.4 to v14.5 between releasing 
these two versions of the app may have reset that setting somehow.


Anyway, the story is, if you have a web server app that stops working 
for some reason, and EVEN IF your browser will still connect to the 
server via a local loop-back (e.g. 127.0.0.1) MAKE sure that the Web 
Database Settings are as they should be.


Hope this saves someone else a few hours

Cheers,
Allan Udy

Golden Micro Solutions Ltd, Blenheim, New Zealand
http://www.golden.co.nz

**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: version of openssl in 15.4 mac

2017-07-17 Thread Keisuke Miyako via 4D_Tech
you could also...

$version:=""
$param:=Get database parameter(94;$version)

but it is good to make it a habit of reading the release notes for every update.



**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Tip: Finding scheduling conflicts

2017-07-17 Thread David Adams via 4D_Tech
Ever had to do date math where you need to detect conflict schedules?
Recently, I had to do some data analysis that involved checking for
potential conflicts in a schedule, counting them, and figuring out how big
the conflicts were. This isn't a live schedule, it's historical scheduling
data used to model future demand against available resources. The idea is
to surface obvious material shortfalls. If you were an event planner, you
might use October 2016 demand to project 2017 demand to see if you have
enough chairs, caterers, dancing bears, clowns, kegs of beer, etc.
available. \Of course, scheduling efficiency and other constraints might be
issues, but that's not what this model is working on...it's trying to
measure fixed inventory against projected demand to see if more inventory
is needed. Right, too much backstory...welcome to me.

Anyway, I've always "hated" date math. As it turns out, I just wasn't
looking for existing solutions efficiently and I don't hate date math at
all now. It didn't take long to find out that time interval calculations
have been studied exhaustively as have algorithms for doing conflict
detection, optimal fitting, etc. In my case, I just need a couple of things:

* Do these two time ranges intersect?
* By how much?

My particular problem takes more than that to sort out, and I also do
another form of projection that's a tweak on this, but that's the nub of
the interval math right there. As a highlight of what I'm talking about,
here are some comments adapted from a StackOverflow post on the subject:

// Great explanation on StackOverflow here:
//
https://stackoverflow.com/questions/143552/comparing-date-ranges/143568#143568

// Best. Ascii. Diagram. Ever. This blocks out eleven possible interval
comparison outcomes.
// I've added discussion of two special cases and show what catches them.
-- DPA

//|---|  compare to this one
//|-|contained within
//|--|   contained within, equal start
//|---|  contained within, equal end
//|---|  contained within, equal
start+end
//  ||   not fully contained, overlaps
start
//|---|  not fully contained, overlaps
end
//  |-|  overlaps start, bigger
//|---|  overlaps end, bigger
//  |--|

// on the other hand, let me post all those that don't overlap:
//
//|---|  compare to this one
//  |---|ends before
//  |---|starts after

// Notes about two possibly confusing cases
//|---|  compare to this one
//  |-|  ends at start is a case of
//  ||   not fully contained, overlaps
start

//|---|  compare to this one
//|-|starts at end is a case of
//|---|  not fully contained, overlaps
end



Below I'm posting a method for calculating the overlap between two time
ranges in seconds. A few notes:

* All of this code assumes and requires date times on a consistent
timezone. If you do a lot of datetime stuff and haven't already moved
everything to Zulu with offsets stored somewhere for display purposes, your
making your life needlessly hard. But all this code requires is that
datetimes are on the same time zone, whatever that is.

* Midnight is just another moment like any other, with datetimes, midnight
doesn't take any special consideration.

* The routine has minimal error checking on the parameters. It chokes on
end times earlier than start times and that's it. It doesn't detect 
type times and those might screw you up.

* There are a bunch of subroutines listed that I'm not posting. Most folks
will have their own versions or use a different style that doesn't require
some of my subroutines. (I'm big on parameter checking, most people aren't.)

* I didn't write the date time utilities and haven't even looked at them.
They work, that's all I know.

* I've also included a manual test routine that works in conjunction with
the main method. Good luck trying to do something like this without a test
case that you can run over an over until all of the bugs quit moving. Stay
down bug! Just stay down!

* Speaking of bugs, if anyone finds one (or more), PLEASE tell me. Ideally,
fix it and tell me...but at least tell me/the list.

* If anyone from 4D, etc. ever wants to clean this up and make it into a
tech note, please post a link when it's published. I'd use it!

* If all you need is to detect that two appointments overlap and don't care
by how much, see the notes. It's eaasier to fig

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 20x faster looking up object keys as opposed to find in array in
interpreted. And when you compile, it’s literally hundred of times faster
(400-500x) at 100k keys - and the benefits just get bigger and bigger with
more keys. That’s both for filling the cache and for retrieving values
(objects save you from having to check if a key is already in the array
before adding it).

--
Justin Leavens
jus...@jitbusiness.com   (818) 986-7298 x 701
Just In Time Consulting, Inc.
Custom software for unique businesses
http://www.linkedin.com/in/justinleavens

On July 17, 2017 at 3:46:26 AM, Peter Jakobsson via 4D_Tech (
4d_tech@lists.4d.com) wrote:

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 this with objects ? Enumerate the keys in some
systematic way and then populate the object like this >

For($i;1;$SIZE)

$key:=string($i)
$value:=myarrayVAL{$i}
OB SET($object;$key;$value)

End For

Then for retreiving:

$key:=string($1)

$0:=OB Get($object;$key)

…or was JPR suggesting we use object arrays and do some kind of “find” over
the object arrays ?

Best Regards

Peter

**
4D Internet Users Group (4D iNUG)
FAQ: http://lists.4d.com/faqnug.html
Archive: http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub: mailto:4d_tech-unsubscr...@lists.4d.com
**
**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: version of openssl in 15.4 mac

2017-07-17 Thread Lee Hinde via 4D_Tech
Thanks Tim.

> On Jul 17, 2017, at 11:06 AM, Timothy Penner  wrote:
> 
> v15.3 had an update:
> http://download.4d.com/Documents/Products_Documentation/LastVersions/Line_15/VIntl/4D_v15_3_ReleaseNotes_US.pdf
> 
> Library Update
> Open SSL: Upgrade to version 1.0.2j
> 
> -Tim
> 
> 

**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

RE: version of openssl in 15.4 mac

2017-07-17 Thread Timothy Penner via 4D_Tech
v15.3 had an update:
http://download.4d.com/Documents/Products_Documentation/LastVersions/Line_15/VIntl/4D_v15_3_ReleaseNotes_US.pdf

Library Update
Open SSL: Upgrade to version 1.0.2j

-Tim



**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

RE: version of openssl in 15.4 mac

2017-07-17 Thread Timothy Penner via 4D_Tech
Hi Lee,

This sort of change should be in a document called "Release Notes" available 
from the Downloads Page:
http://www.4d.com/downloads/products.html

For example, v16.1 shows this:

Library Update
Open SSL: Upgrade to version 1.0.2k

http://download.4d.com/Documents/Products_Documentation/LastVersions/Line_16/VIntl/4D_v16_1_ReleaseNotes.pdf

But I don’t see anything for v15.4 about OpenSSL:
http://download.4d.com/Documents/Products_Documentation/LastVersions/Line_15/VIntl/4D_v15_4_ReleaseNotes_US.pdf

-Tim




**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

version of openssl in 15.4 mac

2017-07-17 Thread Lee Hinde via 4D_Tech
I read somewhere that the openssl version got bumped in version 15.4. But I
can't find where.

I did find this:

http://kb.4d.com/assetid=76175 : Tech Tip: How to Find the Version of
OpenSSL used in 4D

with this:


   - Windows
  1. Locate the folder containing 4D.exe or 4D Server.exe
  2. In the same folder as 4D.exe (or 4DServer.exe) is a file named
  libeay32.dll and ssleay32.dll
  3. Locate the libeay32.dll or ssleay32.dll file and right-click on
  either of these files, then choose properties
  4. The version number specified in the properties is the version of
  OpenSSL used
   - Mac OS X
  1. This information is not available on the Mac side
**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: Thinking through object/text fields: Findings summarized, advice solicited

2017-07-17 Thread Lee Hinde via 4D_Tech
On Mon, Jul 17, 2017 at 5:40 AM, David Adams via 4D_Tech <
4d_tech@lists.4d.com> wrote:

>
> My biggest problem with PostgreSQL is the relative lack of nice front-end
> tools. My beloved SequelPro for MySQL has long hinted at a PostgreSQL
> version, but it doesn't seem to be there yet. For MySQL though, it's great
> (and free):
>
> http://www.sequelpro.com/
>
> Navicat can do more (stored procedures, copy data across structures, better
> trigger support, etc.) but, dang, that "Look Ma! I wrote it in Java!" UI is
> just so ugly. I'll pay for it, I'll use it, I'll be grateful...but I won't
> be loving it.
>
> Any recommendations for good PostgreSQL tools?
>


Agreed on how great Sequel Pro is.

For Postgres, I use PostgresApp https://postgresapp.com/ to run Postgres on
my mac.

For the client I use Navicat Premium Essentials (their cheaper Swiss Army
Knife tool.) It's ugly, but you can do what you need to do.

The fellow who wrote the Postrgres Mac App has a client app, called
Positco: https://eggerapps.at/postico/

Something to check out.
**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

SQL Issue

2017-07-17 Thread Charles Miller via 4D_Tech
Environment MAC 4D v15
internal sql
Given the following code

Begin SQL
update [Tracking]
set
[Tracking].[IssueDate] = :$NewTracking_d
where
[Tracking].[PatientRef] = :$PatientRef_L
and
[Tracking].[TestRef] = 62;

End SQL


Where all fields are correct I see a warning on the Set Line and when run,
I get a parsing error

When I change the code as follows
Begin SQL
update [Tracking]
set
IssueDate = :$NewTracking_d
where
[Tracking].[PatientRef] = :$PatientRef_L
and
[Tracking].[TestRef] = 62;

End SQL

The second sample works. I have no idea as to what the difference is. Any
ideas out there

Thanks and regards
Chuck
-- 
-
 Chuck Miller Voice: (617) 739-0306 Fax: (617) 232-1064
 Informed Solutions, Inc.
 Brookline, MA 02446 USA Registered 4D Developer
   Providers of 4D, Sybase & SQL Sever connectivity
  http://www.informed-solutions.com
-
This message and any attached documents contain information which may be
confidential, subject to privilege or exempt from disclosure under
applicable law.  These materials are intended only for the use of the
intended recipient. If you are not the intended recipient of this
transmission, you are hereby notified that any distribution, disclosure,
printing, copying, storage, modification or the taking of any action in
reliance upon this transmission is strictly prohibited.  Delivery of this
message to any person other than the intended recipient shall not
compromise or waive such confidentiality, privilege or exemption
from disclosure as to this communication.
**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: Resetting The Explorer Window - Tip

2017-07-17 Thread Douglas von Roeder via 4D_Tech
Allan:

Thank you for passing this along.

It's very helpful.

--
Douglas von Roeder
949-336-2902

On Sun, Jul 16, 2017 at 8:32 PM, Allan Udy via 4D_Tech <4d_tech@lists.4d.com
> wrote:

> Hi All,
>
> Here's a quick tip if you suddenly loose the buttons at the bottom of your
> Explorer window, as I did this afternoon -- I couldn't view method
> Comments  (no Preview/Comments button), nor could I Add [+] or Delete [-]
> methods etc -- those options were just not available to me.
>
> What to do when your development environment goes belly up... and when a
> computer restart, software restart, and software reinstall don't solve the
> problem?
>
> 1. Close the Explorer window
>
> 2. Hold the Shift key down, and
>
> 3. Select the menu item:   Design >  Explorer >  Methods
>
> This has the effect of 'resetting' the size and location of the Explorer
> window, and thankfully, making the buttons at the bottom of the screen
> 'magically' reappear.
>
> Spent over half an hour trying to find any info about this, and trying to
> work out where my buttons and options had disappeared to.  Found the
> solution above by luck, although you could say it was found because of
> nearly thirty years of experience ;-)
>
> Hope this helps someone else sometime.  Still don't know where my buttons
> went, or why
>
> Cheers,
> Allan Udy
>
> Golden Micro Solutions Ltd, Blenheim, New Zealand
> http://www.golden.co.nz
>
>
>
>
>
>
> Cheers,
> Allan Udy
>
> Golden Micro Solutions Ltd, Blenheim, New Zealand
> http://www.golden.co.nz
>
> **
> 4D Internet Users Group (4D iNUG)
> FAQ:  http://lists.4d.com/faqnug.html
> Archive:  http://lists.4d.com/archives.html
> Options: http://lists.4d.com/mailman/options/4d_tech
> Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
> **
**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: Thinking through object/text fields: Findings summarized, advice solicited

2017-07-17 Thread Kirk Brooks via 4D_Tech
Hi John,
I haven't done very much communicating from 4D to a SQL database so this is
a very naive question - but could you talk about how a tool like Navicat
helps you with 4D?

On Mon, Jul 17, 2017 at 8:39 AM, John DeSoi via 4D_Tech <
4d_tech@lists.4d.com> wrote:

> I bought Navicat 11 a few months ago after they made some nice
> improvements in the SQL editor. I thought it was the most Mac friendly of
> any PostgreSQL tools.
> ​...
> > On Jul 17, 2017, at 8:40 AM, David Adams via 4D_Tech <
> 4d_tech@lists.4d.com> wrote:
> >
> > Navicat can do more (stored procedures, copy data across structures,
> better
> > trigger support, etc.) but, dang, that "Look Ma! I wrote it in Java!" UI
> is
> > just so ugly.
>
-- 
Kirk Brooks
San Francisco, CA
===

*The only thing necessary for the triumph of evil is for good men to do
nothing.*

*- Edmund Burke*
**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: Thinking through object/text fields: Findings summarized, advice solicited

2017-07-17 Thread John DeSoi via 4D_Tech
I bought Navicat 11 a few months ago after they made some nice improvements in 
the SQL editor. I thought it was the most Mac friendly of any PostgreSQL tools. 
Shortly thereafter Navicat 12 was released. I'm pretty sure it is not Java, but 
I think they switched to some other GUI library to make their cross platform 
work easier. It seems not as Mac friendly and I think they did some other 
things to make it less usable. I have version 12, but I'm still using version 
11. They seem to be receptive to feedback, so you might send them some comments 
on why you think their Mac implementation looks like it is done in Java.

John DeSoi, Ph.D.



> On Jul 17, 2017, at 8:40 AM, David Adams via 4D_Tech <4d_tech@lists.4d.com> 
> wrote:
> 
> Navicat can do more (stored procedures, copy data across structures, better
> trigger support, etc.) but, dang, that "Look Ma! I wrote it in Java!" UI is
> just so ugly. I'll pay for it, I'll use it, I'll be grateful...but I won't
> be loving it.
> 
> Any recommendations for good PostgreSQL tools?

**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

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

**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

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 object system optimizes it by itself.
Only no need to calculate as my dictionary table is quite simple:

WordKey
Language
Word

so I queried for the language I needed and then

apply to selection([dict];ob set(<>Dict;[dict]WordKey;[dict]Word)

ready
set
go

could not be conceivably easier

cheers

> Am 17.07.2017 um 16:45 schrieb Peter Jakobsson via 4D_Tech 
> <4d_tech@lists.4d.com>:
> 
> Thanks Alexander.
> 
> Which style of implementation did you use ? Did you use the old array lookup 
> key as the new object key in the key/value pair ? i.e. did you enumerate the 
> keys like this: ?
> 
> === OLD WAY ===
> 
> ARRAY LONGINT(vArrKeysID; 1000)
> ARRAY LONGINT(vArrKeysNames; 1000)
> 
> $x:=Find in Array(vArrKeysID;345)
> 
> If($x>0)
> $0:= vArrKeysNames{$x}
> End if
> 
> === NEW WAY ===
> 
> C_OBJECT($myOBJECT)
> 
> For($i;1;1000)
> 
> $key:=String($i)
> $value:=$i
> OB SET($myOBJECT;$key;$value)
> 
> End For
> 
> …then for finding (passing the ID in $1:
> 
> $key:=string($1)
> 
> $0:=ob get($myOBJECT;$key)
> 
> ==
> 
> Is that how you did it ? (i.e. with calculated/hashed keys).
> 
> Peter
> 
> 
> On 17 Jul 2017, at 13:17, Herr Alexander Heintz via 4D_Tech 
> <4d_tech@lists.4d.com> wrote:
> 
>> Using objects was MAGNITUDES faster than synchronised arrays
> 
> **
> 4D Internet Users Group (4D iNUG)
> FAQ:  http://lists.4d.com/faqnug.html
> Archive:  http://lists.4d.com/archives.html
> Options: http://lists.4d.com/mailman/options/4d_tech
> Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
> **

**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: Arrays vs Object for Key/Value pair lookups

2017-07-17 Thread Peter Jakobsson via 4D_Tech
Thanks Alexander.

Which style of implementation did you use ? Did you use the old array lookup 
key as the new object key in the key/value pair ? i.e. did you enumerate the 
keys like this: ?

=== OLD WAY ===

ARRAY LONGINT(vArrKeysID; 1000)
ARRAY LONGINT(vArrKeysNames; 1000)

$x:=Find in Array(vArrKeysID;345)

If($x>0)
$0:= vArrKeysNames{$x}
End if

=== NEW WAY ===

C_OBJECT($myOBJECT)

For($i;1;1000)

 $key:=String($i)
 $value:=$i
 OB SET($myOBJECT;$key;$value)

End For

…then for finding (passing the ID in $1:

$key:=string($1)

$0:=ob get($myOBJECT;$key)

==

Is that how you did it ? (i.e. with calculated/hashed keys).

Peter


On 17 Jul 2017, at 13:17, Herr Alexander Heintz via 4D_Tech 
<4d_tech@lists.4d.com> wrote:

> Using objects was MAGNITUDES faster than synchronised arrays

**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: Set_Exists() function: Simple version

2017-07-17 Thread Chip Scheide via 4D_Tech
this is basically what I did, but used arrays rather then ab object.

shameless plug :
https://www.dropbox.com/s/075k0ap7afervs8/Sets_Component_v1.0.zip?dl=0

Distributed as shareware $15 ($35 for source & a suite testing 
routines), it is a compiled/built component created in v13. If you like 
it you are free to reuse/distribute etc.

On Mon, 17 Jul 2017 10:38:04 +0200, Rob Laveaux via 4D_Tech wrote:
> Maybe you should take a slightly different approach here.
> 
> In the JavaScript framework that comes with NTK Plugin, 4D sets are 
> implemented as follows (simplified version).
> 
> function RecordSet( table )
> {
>   assert( table instanceof Table, 'Table object expected' );
>   this.id = UUID.new();
>   this.table = table;
>   app.eval4D( 116, 'CREATE SET', '([' + this.table.name + '];"' + 
> this.id + '")' );
> }
> 
> So basically a RecordSet is an object with two properties: the 
> id/name of the set (a UUID) and a reference to the table. There are 
> some more set related functions that build upon this, but I have not 
> listed those here.
> 
> If you would translate this into 4D, you would get something like this:
> 
>   // (PM) Set_Create
>   // $1 = Table
>   // $0 = RecordSet object
> 
> C_POINTER($1;$table)
> C_OBJECT($0;$recordSet)
> C_TEXT($id)
> 
> $table:=$1
> $id:=Generate UUID
> 
> CREATE SET($table->;$id)
> 
> OB SET($recordSet;"table";$table;"id";$id)
> 
> $0:=$recordSet
> 
> Now you have the name of the set and the table it belongs to wrapped 
> in a single variable. You can then add some more wrapper methods 
> which use this RecordSet object.
> 
> HTH,
> 
> - Rob Laveaux
> 
> 
> Pluggers Software
> Scholekstersingel 48
> 2496 MP  Den Haag
> The Netherlands
> 
> Email: rob.lave...@pluggers.nl
> Website: http://www.pluggers.nl
> 
> 
> 
> 
> 
> **
> 4D Internet Users Group (4D iNUG)
> FAQ:  http://lists.4d.com/faqnug.html
> Archive:  http://lists.4d.com/archives.html
> Options: http://lists.4d.com/mailman/options/4d_tech
> Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
> **
---
Gas is for washing parts
Alcohol is for drinkin'
Nitromethane is for racing 
**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: Set_Exists() function: Simple version

2017-07-17 Thread Chip Scheide via 4D_Tech
David,
I wrote a complete collection of set operation routines
here : 
https://www.dropbox.com/s/075k0ap7afervs8/Sets_Component_v1.0.zip?dl=0

Distributed as shareware $15 ($35 for source & a suite testing 
routines), it is a compiled/built component created in v13. If you like 
it you are free to reuse/distribute etc.

it includes a method to test if the set exists, and does not require 
error handlers.

On Sat, 15 Jul 2017 10:10:21 +1000, David Adams via 4D_Tech wrote:
> Chip was asking about testing if a set exists or not and put in a feature
> request related to this subject. (I voted for it.)
> 
> I was just consolidating some old code and ran across something that I
> wrote some time back called Set_Exists. No clue. It seems to work, but I
> can't say why.
> 
> C_BOOLEAN($0;$exists)
> C_TEXT($1;$set_name)
> 
> $set_name:=$1
> 
> Error:=0
> 
> ErrorHandler_Install ("ErrorHandler_SuppressError")
> 
> C_BOOLEAN($is_in_set)
> $is_in_set:=Is in set($set_name)
> 
> ErrorHandler_InstallPrevious
> 
> $exists:=Error=0  // You could test for error 39 to be a bit more specific.
> 
> $0:=$exists
> 
> Here's a little routine I wrote to try it out:
> 
> ALL RECORDS([Cart])
> CREATE SET([Cart];"Cart_All")
> REDUCE SELECTION([Cart];0)
> UNLOAD RECORD([Cart])
> 
> $this_returns_true_correctly:=Set_Exists ("Cart_All")
> 
> $this_returns_false_correctly:=Set_Exists ("Foo")
> 
> Obviously, you would need to use a table name that exists in your structure
> to check this out.
> 
> Can anyone confirm/deny that this code is reliable? Seriously, I have no
> memory of writing this...Not that unusual for me, frankly...I tend to punch
> out reams of code/writing and don't always look back.
> **
> 4D Internet Users Group (4D iNUG)
> FAQ:  http://lists.4d.com/faqnug.html
> Archive:  http://lists.4d.com/archives.html
> Options: http://lists.4d.com/mailman/options/4d_tech
> Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
> **
---
Gas is for washing parts
Alcohol is for drinkin'
Nitromethane is for racing 
**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

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 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 this with objects ? Enumerate the keys in some 
> systematic way and then populate the object like this >
> 
> For($i;1;$SIZE)
> 
>  $key:=string($i)
>  $value:=myarrayVAL{$i}
>  OB SET($object;$key;$value)
> 
> End For
> 
> Then for retreiving:
> 
> $key:=string($1)
> 
> $0:=OB Get($object;$key)
> 
> …or was JPR suggesting we use object arrays and do some kind of “find” over 
> the object arrays ?
> 
> Best Regards
> 
> Peter
> 
> **
> 4D Internet Users Group (4D iNUG)
> FAQ:  http://lists.4d.com/faqnug.html
> Archive:  http://lists.4d.com/archives.html
> Options: http://lists.4d.com/mailman/options/4d_tech
> Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
> **

**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: Thinking through object/text fields: Findings summarized, advice solicited

2017-07-17 Thread David Adams via 4D_Tech
Better and better, thanks John. That's great, I'd seen mention of TOAST but
wasn't sure how it fit in. Now after 1 hour total, I'm feeling like a
PostgreSQL smartie ;-)

Since we're on this (not 4D) subject, I'll just mention a key detail about
jsonb queries in PostgreSQL:

   They cannot take advantage of the query optimizers frequency tables.

I don' think that 4D has frequency tables (or at least not much, cluster
B-Trees might do much the same.) The idea is to maintain a list of unique
values in a table and their occurrence. This lets the query planner
optimize individual queries based on the values in your query statement and
the values in your database. So, the database engine maintains table
statistics per table, to improve performance. Sweet.

Rob has a PostgreSQL plug-in for 4D:

http://www.pluggers.nl/product/postgresql-plugin/

I checked the manual and it made no mention of json or jsonb field types. I
wrote Rob and he says that passing the data as text works just fine with
PostgreSQL. PostgreSQL has long had an extensible type system and it's able
to coerce text values into more specific types on the server.  (Assuming I
understood Rob correctly and am not mis-quotting.)

My biggest problem with PostgreSQL is the relative lack of nice front-end
tools. My beloved SequelPro for MySQL has long hinted at a PostgreSQL
version, but it doesn't seem to be there yet. For MySQL though, it's great
(and free):

http://www.sequelpro.com/

Navicat can do more (stored procedures, copy data across structures, better
trigger support, etc.) but, dang, that "Look Ma! I wrote it in Java!" UI is
just so ugly. I'll pay for it, I'll use it, I'll be grateful...but I won't
be loving it.

Any recommendations for good PostgreSQL tools?
**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

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 elements, it takes
something like 36 operations max to find a value. If you have an unsorted
array of 1,000,000 items then it can take 1,000,000 comparisons to check
for a value.

Kind of a big deal.

A naive, sequential Find in array and a smart binary search on a sorted
array are *very* different animals. Conflating the two makes search results
based on one meaningless.

That's why I'm trying to sort out which of these animals you were comparing
with searches on objects. Object may be using some kind of hash table
which, for sure, ought to beat a sequential find in array. We don't know
how many buckets are in the hash table, but say that it's 4,096. You cut
your initial search space down to roughly 256 values. (This could be 0
values or it could be 1,000 - it depends on the data and the hashing
function.) That gives you a *massive* optimization very inexpensively. It's
still hard to beat a binary search under a normal distribution of values
and searches, but it's still way faster than a sequential search.

Then again, we don't actually know *anything* about the way object searches
work in 4D so anything is possible. 4D won't say anything on the subject
for reasons they will not discuss. I find this completely puzzling, but
there it is.
**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: Resetting The Explorer Window - Tip

2017-07-17 Thread Ken Daniel via 4D_Tech
Allan, thanks for the tip. It helped me. Ken

On Sun, Jul 16, 2017 at 11:32 PM, Allan Udy via 4D_Tech <
4d_tech@lists.4d.com> wrote:

> Hi All,
>
> Here's a quick tip if you suddenly loose the buttons at the bottom of your
> Explorer window, as I did this afternoon -- I couldn't view method
> Comments  (no Preview/Comments button), nor could I Add [+] or Delete [-]
> methods etc -- those options were just not available to me.
>
> What to do when your development environment goes belly up... and when a
> computer restart, software restart, and software reinstall don't solve the
> problem?
>
> 1. Close the Explorer window
>
> 2. Hold the Shift key down, and
>
> 3. Select the menu item:   Design >  Explorer >  Methods
>
> This has the effect of 'resetting' the size and location of the Explorer
> window, and thankfully, making the buttons at the bottom of the screen
> 'magically' reappear.
>
> Spent over half an hour trying to find any info about this, and trying to
> work out where my buttons and options had disappeared to.  Found the
> solution above by luck, although you could say it was found because of
> nearly thirty years of experience ;-)
>
> Hope this helps someone else sometime.  Still don't know where my buttons
> went, or why
>
> Cheers,
> Allan Udy
>
> Golden Micro Solutions Ltd, Blenheim, New Zealand
> http://www.golden.co.nz
>
>
>
>
>
>
> Cheers,
> Allan Udy
>
> Golden Micro Solutions Ltd, Blenheim, New Zealand
> http://www.golden.co.nz
>
> **
> 4D Internet Users Group (4D iNUG)
> FAQ:  http://lists.4d.com/faqnug.html
> Archive:  http://lists.4d.com/archives.html
> Options: http://lists.4d.com/mailman/options/4d_tech
> Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
> **
**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: Thinking through object/text fields: Findings summarized, advice solicited

2017-07-17 Thread John DeSoi via 4D_Tech
Note: PostgreSQL automatically and transparently compresses large variable 
length column values.

https://www.postgresql.org/docs/9.6/static/storage-toast.html

John DeSoi, Ph.D.


> On Jul 17, 2017, at 12:10 AM, David Adams via 4D_Tech <4d_tech@lists.4d.com> 
> wrote:
> 
> The jsonb type restructures the JSON into a
> custom binary format for index optimization. Not to save space, but to make
> searches possible, flexible, and fast.

**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

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 measurable differences here, 1ms to several 
hundred), so I immediately trashed the old array based code and rewrite with 
objects.
Never looked back :-) 

Cheers
Alex

> Am 17.07.2017 um 12:46 schrieb Peter Jakobsson via 4D_Tech 
> <4d_tech@lists.4d.com>:
> 
> 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 this with objects ? Enumerate the keys in some 
> systematic way and then populate the object like this >
> 
> For($i;1;$SIZE)
> 
>  $key:=string($i)
>  $value:=myarrayVAL{$i}
>  OB SET($object;$key;$value)
> 
> End For
> 
> Then for retreiving:
> 
> $key:=string($1)
> 
> $0:=OB Get($object;$key)
> 
> …or was JPR suggesting we use object arrays and do some kind of “find” over 
> the object arrays ?
> 
> Best Regards
> 
> Peter
> 
> **
> 4D Internet Users Group (4D iNUG)
> FAQ:  http://lists.4d.com/faqnug.html
> Archive:  http://lists.4d.com/archives.html
> Options: http://lists.4d.com/mailman/options/4d_tech
> Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
> **

**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

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 this with objects ? Enumerate the keys in some 
systematic way and then populate the object like this >

For($i;1;$SIZE)

  $key:=string($i)
  $value:=myarrayVAL{$i}
  OB SET($object;$key;$value)

End For

Then for retreiving:

$key:=string($1)

$0:=OB Get($object;$key)

…or was JPR suggesting we use object arrays and do some kind of “find” over the 
object arrays ?

Best Regards

Peter

**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: Set_Exists() function: Simple version

2017-07-17 Thread Robert Livingston via 4D_Tech
First I have to get some more logical errors out of my code. The below is 
cleaned up.



C_BOOLEAN($0;$setDoesExist)
C_TEXT($1;$setName)
C_BOOLEAN($testInSet)
C_LONGINT($numInSet)

$setName:=$1

$numInSet:=Records in set($setName)

If ($numInSet>0)
$setDoesExist:=True
Else 

  // two possibilities
  // 1. set does not exist
  // 2. set exists but has no records

  // logic: The documentation says: // ADD TO SET ( {aTable ;} set ) … 
ADD TO SET adds the current record of aTable to set. The set must already 
exist; if it does not, an error occurs.
  // if the set does not exist, I will get an error.
  // if it does exist then I will NOT get an error but it is safe 
because I will not have changed the state of anything since adding zero records 
to an existing set does nothing.
fErrorHappened:=False  // this is a process variable that is created at 
startup
ON ERR CALL("ErrorIgnore")  // ErrorIgnore is a method that sets 
fErrorHappened to true
ADD TO SET($setName)  // if the set does not exist, this will throw an 
error. This particular "Set" command is sensitive as to whether the set exists
ON ERR CALL("")

If (fErrorHappened)
$setDoesExist:=False
Else 
$setDoesExist:=True
End if 


End if 

$0:=$setDoesExist


> On Jul 17, 2017, at 1:07 AM, Julio Carneiro via 4D_Tech 
> <4d_tech@lists.4d.com> wrote:
> 
> Just out of curiosity, what happens if there is no current record to add to 
> the set?
> - do you get an error, which might only indicate no record exists to add to 
> an existing set?
> - nothing happens, even if set does not exist?



I am doing the testing in a simple interpreted environment. No server etc.

If there is an empty current selection then the code (interpreted) correctly 
determines whether the set exists or does not exist.

If there is a multi-record current selection but the current record does not 
exist than the code (interpreted) correctly determines whether the set exists 
or does not exist.
**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: Set_Exists() function: Simple version

2017-07-17 Thread Rob Laveaux via 4D_Tech
Maybe you should take a slightly different approach here.

In the JavaScript framework that comes with NTK Plugin, 4D sets are implemented 
as follows (simplified version).

function RecordSet( table )
{
assert( table instanceof Table, 'Table object expected' );
this.id = UUID.new();
this.table = table;
app.eval4D( 116, 'CREATE SET', '([' + this.table.name + '];"' + this.id 
+ '")' );
}

So basically a RecordSet is an object with two properties: the id/name of the 
set (a UUID) and a reference to the table. There are some more set related 
functions that build upon this, but I have not listed those here.

If you would translate this into 4D, you would get something like this:

  // (PM) Set_Create
  // $1 = Table
  // $0 = RecordSet object

C_POINTER($1;$table)
C_OBJECT($0;$recordSet)
C_TEXT($id)

$table:=$1
$id:=Generate UUID

CREATE SET($table->;$id)

OB SET($recordSet;"table";$table;"id";$id)

$0:=$recordSet

Now you have the name of the set and the table it belongs to wrapped in a 
single variable. You can then add some more wrapper methods which use this 
RecordSet object.

HTH,

- Rob Laveaux


Pluggers Software
Scholekstersingel 48
2496 MP  Den Haag
The Netherlands

Email: rob.lave...@pluggers.nl
Website: http://www.pluggers.nl





**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

RE: PHP Execute

2017-07-17 Thread Bruno LEGAY via 4D_Tech
Hi,

A classic problem with PHP Execute is that it is depending on the embedded fast 
cgi which it communicates with using tcp (ip + port).
If you run many copies of 4D on your machine, it is likely the default php fast 
cgi port for fast cgi is already used by another 4D.
Then calling PHP Execute will fail...

You can change it but you have to choose an available port...

Just my 2 cents...

HTH
Bruno 
**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: Print Project Form

2017-07-17 Thread Robert Livingston via 4D_Tech

> On Jul 16, 2017, at 3:41 PM, Keisuke Miyako via 4D_Tech 
> <4d_tech@lists.4d.com> wrote:
> 
> the command is called Print form, it can not be more obvious!

Keisuke: Thanks for taking time to reply


In my world, things are often not obvious.

In this case the reason is that the documentation refers to a first parameter 
as being optional {aTable}, but if it is not provided then it uses the Default 
Table.
I could not understand what the Default Table of a Project Form would be.

The fact that this command, Print form,  had this parameter scared me off of it.

Your reply got me burrowing a little deeper in the documentation. The 
discussion of the command

NO DEFAULT TABLE

has, I believe, clarified for me the whole issue of this first parameter in 
form commands. 

I have certainly used the analogous DIALOG command on project forms blithely 
ignoring the {aTable} first parameter without any problem so I can see why one 
might wonder how any such person could trip up when considering  Print form. 

But I managed :)



****************

Print form ( {aTable ;} form {; area1 {; area2}} ) -> Function result   

Parameter  Type  Description
aTable Table --> Table owning the form, or Default 
table, if omitted
form   String--> Form to print
area1  Longint   --> Print marker, or Beginning area 
(if area2 is specified)
area2  Longint   --> Ending area (if area1 specified)
Function resultLongint <--   Height of printed section




Cheers,

RRL

**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: Set_Exists() function: Simple version

2017-07-17 Thread Julio Carneiro via 4D_Tech
Robert,

Just out of curiosity, what happens if there is no current record to add to the 
set?
- do you get an error, which might only indicate no record exists to add to an 
existing set?
- nothing happens, even if set does not exist?

> On Jul 17, 2017, at 8:48 AM, Robert Livingston via 4D_Tech 
> <4d_tech@lists.4d.com> wrote:
> 
> In the sample code:
> 
> 
> 
> $testInSet:=ADD TO SET($setName) 
> 
> 
> should just be
> 
> 
> 
> ADD TO SET($setName) 
> 

--
Julio Carneiro
jjfo...@gmail.com



**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: Set_Exists() function: Simple version

2017-07-17 Thread David Adams via 4D_Tech
Hey! Don't get me wrong about sets, they are GREAT. In my opinion, there
one of 4D's great unsung features. SQL is always doing full set math, but
that's *very* different to doing bit math on these big bit arrays (not
exactly what a 4D set is, but for the sake of conversation...) 4D set
operations are/can be super, super fast, network efficient, and
memory-efficient. Imagine you're making a cross-tab/pivot. Get all of the
main searches done, create a set for each row/column and then intersect
away. You get the results easily and in very little time. It's a great
feature...just hard to explain to people that haven't had it.

I'm just not into the nuances of where they're stored, which behaviors are
not documented because no one remembered to vs. no one thought they should,
etc.
**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: Set_Exists() function: Simple version

2017-07-17 Thread Robert Livingston via 4D_Tech
In the sample code:



$testInSet:=ADD TO SET($setName) 


should just be



ADD TO SET($setName) 
**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: Set_Exists() function: Simple version

2017-07-17 Thread David Adams via 4D_Tech
...or am I supposed to but Wayne to put in a tech support ticket?

On Mon, Jul 17, 2017 at 5:44 PM, David Adams  wrote:

> Okay, on to my next remedial question: How do we find out if this is a
> reliable behavior?
>
> I'm on the forums in France now a bit (where I've been making friends and
> helping everyone great each new day with optimism and good cheer), but I
> don't know where I meant to ask questions that will end up in official
> answers. Is there such a place? If so, tell me where and I can go ask over
> there and one of us can post back when the real answer comes back. Or
> better, anyone but me ask and let us all know...
>
>
>
**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: Set_Exists() function: Simple version

2017-07-17 Thread David Adams via 4D_Tech
Okay, on to my next remedial question: How do we find out if this is a
reliable behavior?

I'm on the forums in France now a bit (where I've been making friends and
helping everyone great each new day with optimism and good cheer), but I
don't know where I meant to ask questions that will end up in official
answers. Is there such a place? If so, tell me where and I can go ask over
there and one of us can post back when the real answer comes back. Or
better, anyone but me ask and let us all know...
**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: Set_Exists() function: Simple version

2017-07-17 Thread Robert Livingston via 4D_Tech

> On Jul 16, 2017, at 9:18 PM, David Adams via 4D_Tech <4d_tech@lists.4d.com> 
> wrote:
> 
> So, I'd be grateful if anyone that is Really Into Sets (we all know you're
> out there!) gave it some thought. If it's reliable, great! If not, I'll
> kill it rather than rely on it.

I really should shut up since I have already penned an inaccurate post on this 
subject.

But in the interest of keeping the conversation going, how about using ADD TO 
SET as the command to test whether a set exists?

You can first check to see whether the proposed set has more than zero records. 
If it does, then the set exists.

If Records in set returns zero records then it might be because the set does 
not exist and it might be because the set is valid but has zero records. Now 
apply the ADD TO SET command and see if it throws an error.

ADD TO SET is documented to throw an error if the set does not exist.

If it does exist, then adding zero records to some set should not cause any 
harm.

WARNING: I would not actually rely on the code below without, as David has 
said, having people who are "Really Into Sets" make a contribution. It has been 
previously demonstrated that I am not "Really Into Sets"  :)





****************
******

  // PROJECT METHOD: rfSetExist  PATH: rfSetExist
  // PARAMETERS
  // $1 = Set name being tested
  // 
  // RETURNED VALUE(s)
  //$0 Type: Boolean
  //    
  // DESCRIPTION: Tells you whether a set exists. If True then the set exists


C_BOOLEAN($0;$setDoesExist)
C_TEXT($1;$setName)
C_BOOLEAN($testInSet)
C_LONGINT($numInSet)

$setName:=$1

$numInSet:=Records in set($setName) // Documentation: Records in set returns 
the number of records in set. If set does not exist, or if there are no records 
in set, the command returns 0.

If ($numInSet>0)

$setDoesExist:=True

Else 

  // two possibilities
  // 1. set does not exist
  // 2. set exists but has no records

  // logic: The documentation says: // ADD TO SET ( {aTable ;} set ) … 
ADD TO SET adds the current record of aTable to set. The set must already 
exist; if it does not, an error occurs.
  // if the set does not exist, I will get an error.
  // if it does exist then I will NOT get an error but it is safe 
because I will not have changed the state of anything since adding zero records 
to an existing set does nothing.

fErrorHappened:=False  // this is a process variable that is created at 
startup
ON ERR CALL("ErrorIgnore")  // ErrorIgnore is a method that sets 
fErrorHappened to true
$testInSet:=ADD TO SET($setName)  // if the set does not exist, this 
will throw an error. This particular "Set" command is sensitive as to whether 
the set exists
ON ERR CALL("")

If (fErrorHappened)
$setDoesExist:=False
Else 
$setDoesExist:=True
End if 

$0:=$setDoesExist

End if
**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

RE: PHP Execute

2017-07-17 Thread Epperlein, Lutz (agendo) via 4D_Tech
> (please say yes)

Yes!

What's the reason of the question? Or, why do you think PHP and 4D don't work 
in a compiled environment?

Regards
Lutz

--  
Lutz Epperlein  
--
Agendo Gesellschaft für politische Planung mbH
Köpenicker Str. 9
10997 Berlin
http://www.agendo.de/
--


**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: Set_Exists() function: Simple version

2017-07-17 Thread Justin Carr via 4D_Tech
On 17 Jul 2017, at 5:03 pm, Robert Livingston  wrote:
> 
> 
>> On Jul 16, 2017, at 9:09 PM, Justin Carr via 4D_Tech <4d_tech@lists.4d.com 
>> > wrote:
>> 
>> Are you able to provide a link to where the documentation states this?
> 
> I really have to totally retreat here. Talk about faulty memory| When I wrote 
> that note, I was "convinced" that I had just read in the documentation that   
> Is In setreturned an error when the set did not exist.
> 
> Then I went back to find it in the current documentation. No luck.
> 
> I was SO convinced that I had seen this, that I then looked at multiple old 
> versions of the documentation thinking that perhaps it was there but I could 
> not find it anywhere. 

Phew! That's actually a relief for me. I did the same as you, searching back 
through older versions of the language ref, so I was starting to wonder if the 
way I use the documentation set was somehow incomplete/lacking.

Cheers
J
**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: Set_Exists() function: Simple version

2017-07-17 Thread Robert Livingston via 4D_Tech

> On Jul 16, 2017, at 9:09 PM, Justin Carr via 4D_Tech <4d_tech@lists.4d.com> 
> wrote:
> 
> Are you able to provide a link to where the documentation states this?

I really have to totally retreat here. Talk about faulty memory| When I wrote 
that note, I was "convinced" that I had just read in the documentation that 
  Is In setreturned an error when the set did not exist.

Then I went back to find it in the current documentation. No luck.

I was SO convinced that I had seen this, that I then looked at multiple old 
versions of the documentation thinking that perhaps it was there but I could 
not find it anywhere. 

So I reluctantly conclude that I am simply wrong and retract all of my comments 
on this matter.

SoIs In setat least sometimes does return an error when applied to a 
set that does not exist, but that is not to say it is "reliable" in this which 
was, of course, Davids's original question.



> I would strongly discourage the use of an interprocess variable here.

Thanks for your warning here.

**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**