Doug,

I may be misunderstanding your application, but wouldn’t API Pack’s Record to 
Blob and Blob to Record functions work?  (It’s from pluggers.nl)

We use that, first compressing then converting the Blob that contains the 
entire record to text before sending it as a variable via an HTTP Post.  So, on 
the sending side the pseudocode is:

$err:=API Record to Blob ($tablenum;$record)
COMPRESS BLOB ($record)
BASE64 ENCODE ($record)
$varToSend:= BLOB to text ($record;UTF8 C string)

On the other end, the variable is converted back to a Blob and then we use Blob 
to Record to create a 4D record with all of the fields.  

TEXT TO BLOB($record;$recblob;UTF8 C string)
BASE64 DECODE($recblob)
EXPAND BLOB($recblob)
         // do some stuff here using other passed variables to identify/load 
the table and record, or create a new record, per below, and then
$err:=API Blob To Record ($tablenum;$recblob)

Along with the variable containing the record data, the HTTP post contains a 
few other variables including the table number, the key index field and the key 
index value, so the receiving database knows what table it’s updating and 
whether it’s revising an existing record or adding a new one.  Using UUID’s 
instead of sequence numbers as the key field takes care of any issue of 
duplication between locally-generated records and received records from a 
remote system. Other than that we don’t need metadata for each field, as Record 
to Blob and Blob to Record handle that.

Hope this helps!

Ron Rosell


> On Apr 24, 2017, at 6:42 PM, Wayne Stewart via 4D_Tech <[email protected]> 
> wrote:
> 
> Doug,
> 
> I do something similar.
> 
> I use Web services (lazy option).  The sync records are in JSON (v13 so I
> used NTK later versions use C_OBJECT commands) for the "small" fields and
> pack big fields into a Blob.
> 
> I can send code if you're interested.
> 
> 
> 
> Regards,
> 
> Wayne
> 
> 
> [image: --]
> Wayne Stewart
> [image: http://]about.me/waynestewart
> <http://about.me/waynestewart>
> 
> 
> On 25 April 2017 at 11:25, Douglas von Roeder via 4D_Tech <
> [email protected]> wrote:
> 
>> Anyone here have experience with Brad Weber's "FTSY Sync" code?
>> 
>> The code in question was written almost 20 years ago to synchronize records
>> between standalones and a client server system, and I know that is was used
>> by a couple of companies inclduing Husqvarna in North Carolina.
>> 
>> One aspect of the code that's challenging is that the V11+ code (the "new"
>> code) could no longer use 4D Open so the design was changed to pack field
>> data into BLOB's. The BLOB's contain metadata for every field including the
>> field number, the field type, the data length, etc.
>> 
>> When the synch records are unpacked, the metadata is used to move
>> sequentially through the BLOB, converting each byte range back to its
>> native 4D type using BLOB to text, BLOB to real, BLOB to longint, etc.
>> 
>> My suspicion is that this method of encoding/decoding is contributing to
>> poor performance* for updating records and I'm hoping that someone has
>> resolved this issue.
>> 
>> 
>> 
>> The underlying question is how much faster/slower would it be to
>> encode/decode data using an alternative method?
>> 
>> A much more simple alternative is to use a "field ID" (String(Table
>> number;"000")+ the ID (a string)" as the tag/property name and use OB
>> Get/Set(property;data;field type) to deal with the data.
>> 
>> This approach would eliminate a significant amount of code, no question,
>> but what would be the impact on performance?
>> 
>> Comments, thoughts, and questions appreciated.
>> 
>> 
>> *this is a V13 system so I can't use Pause index
>> 
>> --
>> Douglas von Roeder
>> 949-336-2902
>> **********************************************************************
>> 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:[email protected]
>> **********************************************************************
> **********************************************************************
> 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:[email protected]
> **********************************************************************

__

Ron Rosell
President
StreamLMS

301-3537 Oak Street
Vancouver, BC V6H 2M1
Canada

Direct phone (all numbers reach me)
Vancouver: (+1) (604) 628-1933  |  Seattle: (+1) (425) 956-3570  |  Palm Beach: 
(+1) (561) 351-6210     
email: [email protected]  |  fax: (+1) (815) 301-9058  |  Skype: ronrosell

**********************************************************************
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:[email protected]
**********************************************************************

Reply via email to