Re: Scope of entity selection
On Thu, Oct 18, 2018 at 2:30 PM Christian Sakowski < christian.sakow...@heubach-media.de> wrote: > > > I did not find a way how to do a shared collection from selection, > > You don’t need this. Just pass the object into the process. The object will be copied. > If you have performance problems, please let me know your benchmarks. My testing data have now 15 record, so it will take a while. > > > > creates unordered selection, so order is lost. ds.Table.fromCollection may do that, but at a cost of significant overhead. > > Yes indeed. > > I create an ordered selection from a collection by doing this: > > ARRAY LONGINT($ids;0) > COLLECTION TO ARRAY($collection;$ids) > > QUERY WITH ARRAY([table]ID;$ids) > ORDER BY FORMULA([table];Find in array($ids;[table]ID)) > Following code seems to work: $selection:=ds.Table.newSelection(dk keep ordered) For each ($id;$collection) $selection.add(ds.Table.get($id)) End for each -- Peter Bozek ** 4D Internet Users Group (4D iNUG) Archive: http://lists.4d.com/archives.html Options: https://lists.4d.com/mailman/options/4d_tech Unsub: mailto:4d_tech-unsubscr...@lists.4d.com **
Re: Scope of entity selection
Christian, I *think* that the intent was to pass an ordered collection from process to process. i.e. - process 1 order the data in whatever manner is desired. - pass the collection from process 1 to process 2 - process 2 receive the ordered collection and do stuff with it, in the order in which it was passed -- without -- having to know the specifics of the ordering. All of that said... and me with NO use of collections or objects (I'm still in v13) could you: - create your collection - add a property to the collection which defines the desired ordering - pass collection to secondary process - use the collection's 'order' property to order the collection as desired. it does not 'pass an ordered collection', but it comes close; and would allow a generic routine on the receiving end to execute the ordering. Chip On Thu, 18 Oct 2018 14:30:43 +0200, Christian Sakowski via 4D_Tech wrote: > > I create an ordered selection from a collection by doing this: > > ARRAY LONGINT($ids;0) > COLLECTION TO ARRAY($collection;$ids) > > QUERY WITH ARRAY([table]ID;$ids) > ORDER BY FORMULA([table];Find in array($ids;[table]ID)) > --- Gas is for washing parts Alcohol is for drinkin' Nitromethane is for racing ** 4D Internet Users Group (4D iNUG) Archive: http://lists.4d.com/archives.html Options: https://lists.4d.com/mailman/options/4d_tech Unsub: mailto:4d_tech-unsubscr...@lists.4d.com **
Re: Scope of entity selection
> I did not find a way how to do a shared collection from selection, You don’t need this. Just pass the object into the process. The object will be copied. If you have performance problems, please let me know your benchmarks. > creates unordered selection, so order is lost. ds.Table.fromCollection may do > that, but at a cost of significant overhead. Yes indeed. I create an ordered selection from a collection by doing this: ARRAY LONGINT($ids;0) COLLECTION TO ARRAY($collection;$ids) QUERY WITH ARRAY([table]ID;$ids) ORDER BY FORMULA([table];Find in array($ids;[table]ID)) -- Grüße/Regards, [heubach-media] | Christian Sakowski christian.sakow...@heubach-media.de Tel: +49/(0)40/52 10 59-23 > Am 18.10.2018 um 14:14 schrieb Peter Bozek : > > > > On Sat, Oct 13, 2018 at 10:29 PM Christian Sakowski via 4D_Tech > <4d_tech@lists.4d.com> wrote: > > > > > > > like: > > $object.myIDs:=$entitySelection.toCollection("ID“).extract(„ID“) > > new process(…;$object) > > > > and in the new process just create the new entity selection: > > > > ds.Table.query(„ID IN :1“;$object.myIDs) > > > I tried simpler (but I believe identical) solution: > > $collection:=$selection.ID > $err:=New process("aaExecuteProcess";0;"test";$collection) > ... in the process > > $selection:=ds.Table.query("ID IN :1";$collection) > > There are several problems with it: first, I did not find a way how to do a > shared collection from selection, there is no "New shared collection form > selection". So passing collection to another process probably copies the > collection (I could not find in in documentation.) But more serious problem > for me is there is no way how to pass ordered selection - line > > $selection:=ds.Table.query("ID IN :1";$collection) > > creates unordered selection, so order is lost. ds.Table.fromCollection may do > that, but at a cost of significant overhead. > > So, it seems ORDA is nice, but for more advanced functionality, named > selections are way to go. > > > > > >> I am trying to do something like global named selection. Examples that, > > >> say, pass selections to workers pass a condition to build a selection. > > >> This > > >> seems to restricting. > > >> > > >> Am I overlooking something obvious? > > > -- > > Peter Bozek -- heubach media Osterfeldstr. 12-14 | Haus 1 | Eingang Nord 22529 Hamburg tel: 040 / 52 10 59 - 10 | fax: -99 mail: i...@heubach-media.de home: www.heubach-media.de Geschäftsführer|CEO: Matthias Heubach Mieten Sie Ihre Computer, iPads & Drucker für Ihre Events bei: http://www.milo-rental.com Diese E-Mail enthält vertrauliche und/oder rechtlich geschützte Informationen. Wenn Sie nicht der richtige Adressat sind oder diese E-Mail irrtümlich erhalten haben, informieren Sie bitte sofort den Absender und vernichten Sie diese Mail. Das unerlaubte Kopieren sowie die unbefugte Weitergabe dieser Mail ist nicht gestattet. This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and destroy this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden. ** 4D Internet Users Group (4D iNUG) Archive: http://lists.4d.com/archives.html Options: https://lists.4d.com/mailman/options/4d_tech Unsub: mailto:4d_tech-unsubscr...@lists.4d.com **
Re: Scope of entity selection
On Sat, Oct 13, 2018 at 10:29 PM Christian Sakowski via 4D_Tech < 4d_tech@lists.4d.com> wrote: > > > like: > $object.myIDs:=$entitySelection.toCollection("ID“).extract(„ID“) > new process(…;$object) > > and in the new process just create the new entity selection: > > ds.Table.query(„ID IN :1“;$object.myIDs) I tried simpler (but I believe identical) solution: $collection:=$selection.ID $err:=New process("aaExecuteProcess";0;"test";$collection) ... in the process $selection:=ds.Table.query("ID IN :1";$collection) There are several problems with it: first, I did not find a way how to do a shared collection from selection, there is no "New shared collection form selection". So passing collection to another process probably copies the collection (I could not find in in documentation.) But more serious problem for me is there is no way how to pass ordered selection - line $selection:=ds.Table.query("ID IN :1";$collection) creates unordered selection, so order is lost. ds.Table.fromCollection may do that, but at a cost of significant overhead. So, it seems ORDA is nice, but for more advanced functionality, named selections are way to go. > > >> I am trying to do something like global named selection. Examples that, > >> say, pass selections to workers pass a condition to build a selection. This > >> seems to restricting. > >> > >> Am I overlooking something obvious? -- Peter Bozek ** 4D Internet Users Group (4D iNUG) Archive: http://lists.4d.com/archives.html Options: https://lists.4d.com/mailman/options/4d_tech Unsub: mailto:4d_tech-unsubscr...@lists.4d.com **
Re: Scope of entity selection
Peter, Collections are ordered. So just sort the entity selection first. On Sat, Oct 13, 2018 at 2:40 PM Peter Bozek via 4D_Tech < 4d_tech@lists.4d.com> wrote: > On Sat, Oct 13, 2018 at 10:29 PM Christian Sakowski via 4D_Tech < > 4d_tech@lists.4d.com> wrote: > > > $object.myIDs:=$entitySelection.toCollection("ID“).extract(„ID“) > > new process(…;$object) > > > > and in the new process just create the new entity selection: > > > > ds.Table.query(„ID IN :1“;$object.myIDs) > > > > > > Christian, > > Thanks for idea, will look at it. I want to pass a sorted selection, not > sure if the above query will work. I have a code that does this with > interprocess selection, and that works OK, but thought ORDA will provide > more elegant solution. > > I could achieve it with LONGINT ARRAY FROM SELECTION - CREATE SELECTION > FROM ARRAY commands, and it resembles your suggestion (and the sort order > will be transferred) but wanted to avoid creating potentially huge array. > Interprocess named selection seems to have very low overhead (and, BTW, the > same argument as against shared entity selections can be used against > interprocess named selections.) > > -- > > Peter Bozek > ** > 4D Internet Users Group (4D iNUG) > Archive: http://lists.4d.com/archives.html > Options: https://lists.4d.com/mailman/options/4d_tech > Unsub: mailto:4d_tech-unsubscr...@lists.4d.com > ** -- Kirk Brooks San Francisco, CA === *We go vote - they go home* ** 4D Internet Users Group (4D iNUG) Archive: http://lists.4d.com/archives.html Options: https://lists.4d.com/mailman/options/4d_tech Unsub: mailto:4d_tech-unsubscr...@lists.4d.com **
Re: Scope of entity selection
On Sat, Oct 13, 2018 at 10:29 PM Christian Sakowski via 4D_Tech < 4d_tech@lists.4d.com> wrote: > $object.myIDs:=$entitySelection.toCollection("ID“).extract(„ID“) > new process(…;$object) > > and in the new process just create the new entity selection: > > ds.Table.query(„ID IN :1“;$object.myIDs) > > Christian, Thanks for idea, will look at it. I want to pass a sorted selection, not sure if the above query will work. I have a code that does this with interprocess selection, and that works OK, but thought ORDA will provide more elegant solution. I could achieve it with LONGINT ARRAY FROM SELECTION - CREATE SELECTION FROM ARRAY commands, and it resembles your suggestion (and the sort order will be transferred) but wanted to avoid creating potentially huge array. Interprocess named selection seems to have very low overhead (and, BTW, the same argument as against shared entity selections can be used against interprocess named selections.) -- Peter Bozek ** 4D Internet Users Group (4D iNUG) Archive: http://lists.4d.com/archives.html Options: https://lists.4d.com/mailman/options/4d_tech Unsub: mailto:4d_tech-unsubscr...@lists.4d.com **
Re: Scope of entity selection
> If not, you could try LONGINT ARRY FROM SELECTION and pack the array into > shared object. Bad idea. First, you should avoid strongly shared objects in this case. Second, LONGINT ARRY FROM SELECTION has nothing to do with ORDA. Third: entities are process depended, because they may use transactions. So you cannot pass entities to a new process, because these entities are may be invalid. Fourth: solution: just pass a collection of the ID’s to the new process: like: $object.myIDs:=$entitySelection.toCollection("ID“).extract(„ID“) new process(…;$object) and in the new process just create the new entity selection: ds.Table.query(„ID IN :1“;$object.myIDs) -- Grüße/Regards, [heubach-media] | Christian Sakowski christian.sakow...@heubach-media.de iChat/AIM: SakowskiF Tel: +49/(0)40/52 10 59-23 > Am 13.10.2018 um 19:30 schrieb Alan Chan via 4D_Tech <4d_tech@lists.4d.com>: > > Hi Peter, > > I haven't touched v17 yet. There might be easier way. If not, you could try > LONGINT ARRY FROM SELECTION and pack the array into shared object. > > Alan Chan > > 4D iNug Technical <4d_tech@lists.4d.com> writes: >> This may be related to other thread - Defining and documenting objects - as >> it is related to scope of new objects: I am playing a bit with 4D v17, and, >> if I understand it correctly, I can pass around shared objects and shared >> collection between processes (and workers, but I am not that far yet.) >> >> However, how I pass around entity selections? It does not seems I can pass >> them as a parameter (new process will get null.) I tested to declare entity >> selection as shared object, but it does not work either. >> >> I am trying to do something like global named selection. Examples that, >> say, pass selections to workers pass a condition to build a selection. This >> seems to restricting. >> >> Am I overlooking something obvious? >> >> -- >> >> Peter Bozek >> > > ** > 4D Internet Users Group (4D iNUG) > Archive: http://lists.4d.com/archives.html > Options: https://lists.4d.com/mailman/options/4d_tech > Unsub: mailto:4d_tech-unsubscr...@lists.4d.com > ** -- heubach media Osterfeldstr. 12-14 | Haus 1 | Eingang Nord 22529 Hamburg tel: 040 / 52 10 59 - 10 | fax: -99 mail: i...@heubach-media.de home: www.heubach-media.de Geschäftsführer|CEO: Matthias Heubach Mieten Sie Ihre Computer, iPads & Drucker für Ihre Events bei: http://www.milo-rental.com Diese E-Mail enthält vertrauliche und/oder rechtlich geschützte Informationen. Wenn Sie nicht der richtige Adressat sind oder diese E-Mail irrtümlich erhalten haben, informieren Sie bitte sofort den Absender und vernichten Sie diese Mail. Das unerlaubte Kopieren sowie die unbefugte Weitergabe dieser Mail ist nicht gestattet. This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and destroy this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden. ** 4D Internet Users Group (4D iNUG) Archive: http://lists.4d.com/archives.html Options: https://lists.4d.com/mailman/options/4d_tech Unsub: mailto:4d_tech-unsubscr...@lists.4d.com **
Re: Scope of entity selection
Hi Peter, I haven't touched v17 yet. There might be easier way. If not, you could try LONGINT ARRY FROM SELECTION and pack the array into shared object. Alan Chan 4D iNug Technical <4d_tech@lists.4d.com> writes: >This may be related to other thread - Defining and documenting objects - as >it is related to scope of new objects: I am playing a bit with 4D v17, and, >if I understand it correctly, I can pass around shared objects and shared >collection between processes (and workers, but I am not that far yet.) > >However, how I pass around entity selections? It does not seems I can pass >them as a parameter (new process will get null.) I tested to declare entity >selection as shared object, but it does not work either. > >I am trying to do something like global named selection. Examples that, >say, pass selections to workers pass a condition to build a selection. This >seems to restricting. > >Am I overlooking something obvious? > >-- > >Peter Bozek > ** 4D Internet Users Group (4D iNUG) Archive: http://lists.4d.com/archives.html Options: https://lists.4d.com/mailman/options/4d_tech Unsub: mailto:4d_tech-unsubscr...@lists.4d.com **
Scope of entity selection
This may be related to other thread - Defining and documenting objects - as it is related to scope of new objects: I am playing a bit with 4D v17, and, if I understand it correctly, I can pass around shared objects and shared collection between processes (and workers, but I am not that far yet.) However, how I pass around entity selections? It does not seems I can pass them as a parameter (new process will get null.) I tested to declare entity selection as shared object, but it does not work either. I am trying to do something like global named selection. Examples that, say, pass selections to workers pass a condition to build a selection. This seems to restricting. Am I overlooking something obvious? -- Peter Bozek ** 4D Internet Users Group (4D iNUG) Archive: http://lists.4d.com/archives.html Options: https://lists.4d.com/mailman/options/4d_tech Unsub: mailto:4d_tech-unsubscr...@lists.4d.com **