Forum: Building VoltDB Applications

Post: resultTable.getRowCount() vs results.length

resultTable.getRowCount() vs results.length
henning
Aug 5, 2010
Is resultTable.getRowCount() the correct indicator for empty results, instead of results.length?

I am getting better results, both when the database is empty, or the query result, when I make this replacement in helloworld/Client.java:

Instead of

 final VoltTable results[] = response.getResults();
        if (results.length != 1) {
            System.out.printf("I can't say Hello in that language.");
            System.exit(-1);
        }
.
        VoltTable resultTable = results[0];



maybe
 final VoltTable results[] = response.getResults();
       VoltTable resultTable = results[0];
       if (resultTable.getRowCount() != 1) {
            System.out.printf("I can't say Hello in that language.");
            System.exit(-1);
        }


As it seems that response.getResults() delivers one array entry every time.
results.length vs. results[0].getRowCount()
izzy
Aug 5, 2010
Hi Henning,

In general, there are some error paths that return an empty results array to the client, so it isn't always safe to assume that results[0] will actually exist. However, looking at the helloworld example, it does seem like you've found a bug in the client. I've dropped this into JIRA (https://issues.voltdb.com/browse/ENG-683).

Thanks for the good catch!

Mike