TITLE:: FluidDataSetQuery
summary:: Query a FluidDataSet
categories:: UGens>FluidManipulation
related:: Classes/FluidDataSet

DESCRIPTION::
A selection of columns and a set of conditions that match rows of a FluidDataSet.
Use to filter and search in a database of descriptors.

CLASSMETHODS::

METHOD:: new
Make a new instance
ARGUMENT:: server
The server on which to run this object

INSTANCEMETHODS::

PRIVATE:: init

METHOD:: addColumn
Add a column to the query
ARGUMENT:: column
Column index
ARGUMENT:: action
Run when done

METHOD:: addRange
Add a range of columns to the query
ARGUMENT:: start
First index
ARGUMENT:: count
Number of columns
ARGUMENT:: action
Run when done

METHOD:: filter
Filter rows according to some condition.

Example: (3, ">", 0.5) filters rows where the value of the 4th column (starting at 0) is larger than 0.5.
ARGUMENT:: column
Column index
ARGUMENT:: condition
Condition string. Possible values: "==", "!=", "<", "<=", ">", ">="
ARGUMENT:: value
Condition value
ARGUMENT:: action
Run when done

METHOD:: and
Add a condition to an existing filter with an "and" connector.
ARGUMENT:: column
Column index
ARGUMENT:: condition
Condition string. Possible values: "==", "!=", "<", "<=", ">", ">="
ARGUMENT:: value
Condition value
ARGUMENT:: action
Run when done


METHOD:: or
Add a condition to an existing filter with an "or" connector.
ARGUMENT:: column
Column index
ARGUMENT:: condition
Condition string. Possible values: "==", "!=", "<", "<=", ">", ">="
ARGUMENT:: value
Condition value
ARGUMENT:: action
Run when done

METHOD:: limit
Limit the number of resulting rows.
ARGUMENT:: rows
Maximum number of rows
ARGUMENT:: action
Run when done

METHOD:: clear
Clear the query, remove all columns, filters and limit.
ARGUMENT:: action
Run when done

METHOD:: transform
Apply the query to a source link::Classes/FluidDataSet:: and write to a destination. Can be the same.
ARGUMENT:: sourceDataSet
Source data, or the DataSet name
ARGUMENT:: destDataSet
Destination data, or the DataSet name
ARGUMENT:: action
Run when done


EXAMPLES::

code::

s.boot;


// Create a DataSet with random data
~dataSet= FluidDataSet(s,\help_fluid_dataset_query);

(
~points = 100.collect{|i|5.collect{|j|j+(i/100)}};
~dataSet.clear;
~tmpbuf = Buffer.alloc(s,5);

fork{
    s.sync;
    ~points.do{|x,i|
        ~tmpbuf.setn(0,x);
        ~dataSet.addPoint(i,~tmpbuf);
        s.sync
    }
}
)

//check the source
~dataSet.print;

// Prepare a FluidDataSetQuery object
~query = FluidDataSetQuery.new;
~out = FluidDataSet(s,\help_fluid_dataset_query_out);

// prepare a simple query
~query.filter(0,"<",0.04);
~query.addColumn(2);
~query.transform(~dataSet, ~out);

// check the result
~out.print;

//prepare a more complex query
~query.clear;
~query.filter(0,">",0.03);
~query.and(1,"<",1.08);
~query.or(2,">",2.98);
~query.addRange(1,2);
~query.transform(~dataSet, ~out);

// Check the results
~out.print;

::
