return outFile;
}
- String[] fetchData(String ids, String f, File outFile)
+ /**
+ * Fetches queries and either saves the response to a file or returns as
+ * string data
+ *
+ * @param ids
+ * @param format
+ * @param outFile
+ * @return
+ * @throws OutOfMemoryError
+ */
+ String[] fetchData(String ids, String format, File outFile)
throws OutOfMemoryError
{
- String[] rslts = new String[0];
StringBuilder querystring = new StringBuilder(ids.length());
- String db = parseIds(ids, querystring);
- if (db == null)
+ String database = parseIds(ids, querystring);
+ if (database == null)
{
System.err.println("Invalid Query string : '" + ids + "'");
System.err.println("Should be of form 'dbname:q1;q2;q3;q4'");
return null;
}
- String[] rslt = fetchBatch(querystring.toString(), db, f, outFile);
- if (rslt != null)
- {
- String[] nrslts = new String[rslt.length + rslts.length];
- System.arraycopy(rslts, 0, nrslts, 0, rslts.length);
- System.arraycopy(rslt, 0, nrslts, rslts.length, rslt.length);
- rslts = nrslts;
- }
- return (rslts.length == 0 ? null : rslts);
+ // note: outFile is currently always specified, so return value is null
+ String[] rslt = fetchBatch(querystring.toString(), database, format, outFile);
+
+ return (rslt != null && rslt.length > 0 ? rslt : null);
}
/**
return database;
}
- String[] fetchBatch(String ids, String dbPath, String format,
+ /**
+ * Fetches queries and either saves the response to a file or (if no file
+ * specified) returns as string data
+ *
+ * @param ids
+ * @param database
+ * @param format
+ * @param outFile
+ * @return
+ * @throws OutOfMemoryError
+ */
+ String[] fetchBatch(String ids, String database, String format,
File outFile) throws OutOfMemoryError
{
// long time = System.currentTimeMillis();
- String url = buildUrl(ids, dbPath, format);
+ String url = buildUrl(ids, database, format);
try
{
}
} catch (OutOfMemoryError er)
{
-
- System.out.println("OUT OF MEMORY DOWNLOADING QUERY FROM " + dbPath
+ System.out.println("OUT OF MEMORY DOWNLOADING QUERY FROM " + database
+ ":\n" + ids);
throw er;
} catch (Exception ex)
return null;
}
System.err.println("Unexpected exception when retrieving from "
- + dbPath
+ + database
+ "\nQuery was : '" + ids + "'");
ex.printStackTrace(System.err);
return null;