try
{
//Here we try to parse only the Header Row
str = reader.readLine();
if (str == null )
throw new ARQException("TSV Results malformed, input is empty (no header row)") ;
if ( ! str.isEmpty() )
{
String[] tokens = pattern.split(str,-1);
for ( String token : tokens )
{
Node v ;
try {
v = NodeFactoryExtra.parseNode(token) ;
if ( v == null || ! v.isVariable())
throw new ResultSetException("TSV Results malformed, not a variable: "+token);
} catch (RiotException ex)
{ throw new ResultSetException("TSV Results malformed, variable names must begin with a ? in the header: "+token); }
Var var = Var.alloc(v);
vars.add(var);
varNames.add(var.getName());
}
}
}
catch ( IOException ex )
{
throw new ARQException(ex) ;
}
//Generate an instance of ResultSetStream using TSVInputIterator
//This will parse actual result rows as needed thus minimising memory usage
return new ResultSetStream(varNames, null, new TSVInputIterator(reader, vars));