Query Result

The QueryResult class provides a convenient way to inspect the results of a Data Refinery query. It wraps a Flip(the Java equivalent of a q table) class and provides table metadata and indexer access methods.

The QueryResult class exposes the following public properties and methods:

  • getColumnType : Returns the type for a given column.
  • getColumnNames : Returns the table's column names
  • getNumberOfRows : The number of rows returned by the query
  • getNumberOfColumns : The number of columns returned by the query
  • getColumnTypes : The types for all the columns

Example of the ColumnType method:

public void getColumnType_method_works()
        {
            QueryResult qr = new QueryResult(flip);
            Assert.AreEqual(String.class, qr.getColumnType().get(0));
            Assert.AreEqual(Timestamp.class, qr.getColumnType().get(1));
            Assert.AreEqual(long.class, qr.getColumnType().get(2));
        }

Example of the QueryResult indexer access methods:

public void Indexers_work_as_expected()
        {
            QueryResult qr = new QueryResult(_flip);
            Assert.AreEqual(3, qr.getNumberOfColumns);
            Assert.AreEqual(3, qr.getNumberOfRows);
            Assert.AreEqual("WAND.L", qr.getValue[1, 0]);
            Assert.AreEqual((long)15, qr.getValue["vol", 2]);
        }