[SOLVED] SortedExampleSet Reader
zis
New Altair Community Member
Hi,
do you know the best way, how to read sorted data from SortedExampleSet?
I have an implementation for ExampleSet through DataRowReader:
I found SortedExampleReader, but he not inherits from DataRowReader and I dont know how to use it.
Thanks for ideas
Regards,
John
do you know the best way, how to read sorted data from SortedExampleSet?
I have an implementation for ExampleSet through DataRowReader:
But SortedExampleSet has ExampleSet and his mapping indicies. Indicies and Iterator in while cycle is not good way to solve (conditions if counter = 33 then ...).
DataRowReader dataRowReader = exampleTable.getDataRowReader();
while( dataRowReader.hasNext() )
{
DataRow dr = dataRowReader.next();
dr.get( attribute );
...
}
I found SortedExampleReader, but he not inherits from DataRowReader and I dont know how to use it.
Thanks for ideas
Regards,
John
0
Answers
-
Ok,
I found solution. Best way is used to more abstraction:
Then in while:
Iterator dataRowReader;
if(exampleSet instanceof SortedExampleSet)
dataRowReader = new SortedExampleReader( exampleSet );
else
dataRowReader = exampleSet.getExampleTable.getDataRowReader();
And code logic is stay same...
while( dataRowReader.hasNext() )
{
DataRow dr;
if(exampleSet instanceof SortedExampleSet)
dr = ((Example)dataRowReader.next()).getDataRow();
else
dr = (DataRow)dataRowReader.next();
...
}0