diff --git a/release-packaging/Classes/FluidDataSetQuery.sc b/release-packaging/Classes/FluidDataSetQuery.sc index c66a121..a0bcb48 100644 --- a/release-packaging/Classes/FluidDataSetQuery.sc +++ b/release-packaging/Classes/FluidDataSetQuery.sc @@ -46,4 +46,7 @@ FluidDataSetQuery : FluidManipulationClient { this.prSendMsg(\transform,[sourceDataSet.asSymbol, destDataSet.asSymbol],action); } + transformJoin{|source1DataSet, source2DataSet, destDataSet, action| + this.prSendMsg(\transformJoin,[source1DataSet.asSymbol, source2DataSet.asSymbol, destDataSet.asSymbol],action); + } } diff --git a/release-packaging/HelpSource/Classes/FluidDataSet.schelp b/release-packaging/HelpSource/Classes/FluidDataSet.schelp index fca0752..a0029ce 100644 --- a/release-packaging/HelpSource/Classes/FluidDataSet.schelp +++ b/release-packaging/HelpSource/Classes/FluidDataSet.schelp @@ -56,7 +56,7 @@ METHOD:: clear Empty the data set. ​ METHOD:: merge -Merge sourceDataSet in the current DataSet. It will update the value of points with the same label if overwrite is set to 1. +Merge sourceDataSet in the current DataSet. It will update the value of points with the same label if overwrite is set to 1. To add columns instead, see the 'transformJoin' method of link::Classes/FluidDataSetQuery:: METHOD:: free Destroy the object on the server. @@ -118,8 +118,12 @@ fork{ FreeSelf.kr(count - 8); }.play.onFree{~ds.dump{|o| o.postln; ~ds.free}} ) +:: + +STRONG:: Merging Datasets:: -//merging +code:: +//this is how to add items between 2 datasets. //create 2 datasets ( ~dsA = FluidDataSet.new(s,\simple1d_4a); diff --git a/release-packaging/HelpSource/Classes/FluidDataSetQuery.schelp b/release-packaging/HelpSource/Classes/FluidDataSetQuery.schelp index 9b736b9..3d9e731 100644 --- a/release-packaging/HelpSource/Classes/FluidDataSetQuery.schelp +++ b/release-packaging/HelpSource/Classes/FluidDataSetQuery.schelp @@ -91,6 +91,17 @@ Destination data, or the DataSet name ARGUMENT:: action Run when done +METHOD:: transformJoin +Apply the query to a source link::Classes/FluidDataSet:: and join all items of a source2 with the same label to a destination. Can be the same. To add items at the end of a dataset instead, see the 'merge' method of link::Classes/FluidDataSet:: +ARGUMENT:: source1DataSet +Source data, or the DataSet name +ARGUMENT:: source2DataSet +Source data, or the DataSet name +ARGUMENT:: destDataSet +Destination data, or the DataSet name +ARGUMENT:: action +Run when done + EXAMPLES:: @@ -144,3 +155,33 @@ fork{ ~out.print; :: + +STRONG:: Joining Datasets:: + +code:: +//this is how to join 2 datasets, adding columns to items with the same label +//create 3 datasets +( +~dsA = FluidDataSet.new(s,\joinA); +~dsB = FluidDataSet.new(s,\joinB); +~dsC = FluidDataSet.new(s,\joinC); +) + +//feed them items with the same labels but with different dimensions +~dsA.load(Dictionary.newFrom([\cols, 2, \data, Dictionary.newFrom([\zero, [0,0], \one,[1,11],\two,[2,22], \three,[3,33],\four,[4,44]])])); +~dsB.load(Dictionary.newFrom([\cols, 2, \data, Dictionary.newFrom([\one,[111,1111],\two,[222,2222], \three,[333,3333],\four,[444,4444],\five,[555,5555]])])); +~dsA.print; +~dsB.print; + +// no query/filter defined, copies all items with labels common to both, and all of the defined column of the first input +~joiner = FluidDataSetQuery.new; +~joiner.transformJoin(~dsA,~dsB,~dsC) +~dsC.print + +// all the sophisticated conditions applicable to 'transform' can be done on the first dataset too +~joiner.filter(1,">",2.1) +~joiner.and(1,"<", 40) +~joiner.addColumn(0) +~joiner.transformJoin(~dsA,~dsB,~dsC) +~dsC.print +::