Skip to content
Snippets Groups Projects
Commit f7adf914 authored by gmantele's avatar gmantele
Browse files

[TAP] Log format reports and end of ADQLExecutor execution, add an OVERFLOW...

[TAP] Log format reports and end of ADQLExecutor execution, add an OVERFLOW notification for the text/plain output and check by default that the given service connection is not null in constructor.
parent 17ee5de9
No related branches found
No related tags found
No related merge requests found
......@@ -370,6 +370,9 @@ public class ADQLExecutor {
// Set the total duration in the report:
report.setTotalDuration(System.currentTimeMillis() - start);
// Log and report the end of this execution:
logger.logTAP(LogLevel.INFO, report, "END_EXEC", "ADQL query execution finished.", null);
}
}
......
......@@ -42,7 +42,7 @@ import adql.db.DBColumn;
* Format any given query (table) result into JSON.
*
* @author Grégory Mantelet (CDS;ARI)
* @version 2.0 (09/2014)
* @version 2.0 (10/2014)
*/
public class JSONFormat implements OutputFormat {
......@@ -59,9 +59,11 @@ public class JSONFormat implements OutputFormat {
* However if you want this behavior you must you {@link #JSONFormat(ServiceConnection, boolean)}.</i></p>
*
* @param service Description of the TAP service.
*
* @throws NullPointerException If the given service connection is <code>null</code>.
*/
public JSONFormat(final ServiceConnection service){
this(service, false);
public JSONFormat(final ServiceConnection service) throws NullPointerException{
this(service, true);
}
/**
......@@ -69,8 +71,13 @@ public class JSONFormat implements OutputFormat {
*
* @param service Description of the TAP service.
* @param logFormatReport <i>true</i> to write a log entry (with nb rows and columns + writing duration) each time a result is written, <i>false</i> otherwise.
*
* @throws NullPointerException If the given service connection is <code>null</code>.
*/
public JSONFormat(final ServiceConnection service, final boolean logFormatReport){
public JSONFormat(final ServiceConnection service, final boolean logFormatReport) throws NullPointerException{
if (service == null)
throw new NullPointerException("The given service connection is NULL!");
this.service = service;
this.logFormatReport = logFormatReport;
}
......@@ -130,9 +137,9 @@ public class JSONFormat implements OutputFormat {
service.getLogger().logTAP(LogLevel.INFO, execReport, "FORMAT", "Result formatted (in JSON ; " + nbRows + " rows ; " + columns.length + " columns) in " + (System.currentTimeMillis() - start) + "ms!", null);
}catch(JSONException je){
throw new TAPException("Error while writing a query result in JSON !", je);
throw new TAPException("Error while writing a query result in JSON!", je);
}catch(IOException ioe){
throw new TAPException("Error while writing a query result in JSON !", ioe);
throw new TAPException("Error while writing a query result in JSON!", ioe);
}
}
......
......@@ -63,8 +63,10 @@ public class SVFormat implements OutputFormat {
*
* @param service Description of the TAP service.
* @param colSeparator Column separator to use.
*
* @throws NullPointerException If the given service connection is <code>null</code>.
*/
public SVFormat(final ServiceConnection service, char colSeparator){
public SVFormat(final ServiceConnection service, char colSeparator) throws NullPointerException{
this(service, colSeparator, true);
}
......@@ -74,9 +76,11 @@ public class SVFormat implements OutputFormat {
* @param service Description of the TAP service.
* @param colSeparator Column separator to use.
* @param delimitStrings <i>true</i> if String values must be delimited by double quotes, <i>false</i> otherwise.
*
* @throws NullPointerException If the given service connection is <code>null</code>.
*/
public SVFormat(final ServiceConnection service, char colSeparator, boolean delimitStrings){
this(service, colSeparator, delimitStrings, false);
public SVFormat(final ServiceConnection service, char colSeparator, boolean delimitStrings) throws NullPointerException{
this(service, colSeparator, delimitStrings, true);
}
/**
......@@ -86,8 +90,10 @@ public class SVFormat implements OutputFormat {
* @param colSeparator Column separator to use.
* @param delimitStrings <i>true</i> if String values must be delimited by double quotes, <i>false</i> otherwise.
* @param logFormatReport <i>true</i> to write a log entry (with nb rows and columns + writing duration) each time a result is written, <i>false</i> otherwise.
*
* @throws NullPointerException If the given service connection is <code>null</code>.
*/
public SVFormat(final ServiceConnection service, char colSeparator, boolean delimitStrings, final boolean logFormatReport){
public SVFormat(final ServiceConnection service, char colSeparator, boolean delimitStrings, final boolean logFormatReport) throws NullPointerException{
separator = "" + colSeparator;
delimitStr = delimitStrings;
this.service = service;
......@@ -99,8 +105,10 @@ public class SVFormat implements OutputFormat {
*
* @param service Description of the TAP service.
* @param colSeparator Column separator to use.
*
* @throws NullPointerException If the given service connection is <code>null</code>.
*/
public SVFormat(final ServiceConnection service, String colSeparator){
public SVFormat(final ServiceConnection service, String colSeparator) throws NullPointerException{
this(service, colSeparator, true);
}
......@@ -110,8 +118,13 @@ public class SVFormat implements OutputFormat {
* @param service Description of the TAP service.
* @param colSeparator Column separator to use.
* @param delimitStrings <i>true</i> if String values must be delimited by double quotes, <i>false</i> otherwise.
*
* @throws NullPointerException If the given service connection is <code>null</code>.
*/
public SVFormat(final ServiceConnection service, String colSeparator, boolean delimitStrings){
public SVFormat(final ServiceConnection service, String colSeparator, boolean delimitStrings) throws NullPointerException{
if (service == null)
throw new NullPointerException("The given service connection is NULL!");
separator = (colSeparator == null) ? ("" + COMMA_SEPARATOR) : colSeparator;
delimitStr = delimitStrings;
this.service = service;
......
......@@ -36,7 +36,7 @@ import cds.util.AsciiTable;
* (columns' width are adjusted so that all columns are well aligned and of the same width).
*
* @author Gr&eacute;gory Mantelet (CDS;ARI)
* @version 2.0 (09/2014)
* @version 2.0 (10/2014)
*/
public class TextFormat implements OutputFormat {
......@@ -50,9 +50,11 @@ public class TextFormat implements OutputFormat {
* Build a {@link TextFormat}.
*
* @param service Description of the TAP service.
*
* @throws NullPointerException If the given service connection is <code>null</code>.
*/
public TextFormat(final ServiceConnection service){
this(service, false);
public TextFormat(final ServiceConnection service) throws NullPointerException{
this(service, true);
}
/**
......@@ -60,8 +62,13 @@ public class TextFormat implements OutputFormat {
*
* @param service Description of the TAP service.
* @param logFormatReport <i>true</i> to write a log entry (with nb rows and columns + writing duration) each time a result is written, <i>false</i> otherwise.
*
* @throws NullPointerException If the given service connection is <code>null</code>.
*/
public TextFormat(final ServiceConnection service, final boolean logFormatReport){
public TextFormat(final ServiceConnection service, final boolean logFormatReport) throws NullPointerException{
if (service == null)
throw new NullPointerException("The given service connection is NULL!");
this.service = service;
this.logFormatReport = logFormatReport;
}
......@@ -108,6 +115,11 @@ public class TextFormat implements OutputFormat {
output.write(l.getBytes());
output.write('\n');
}
// Add a line in case of an OVERFLOW:
if (execReport.parameters.getMaxRec() > 0 && nbRows >= execReport.parameters.getMaxRec())
output.write("\nOVERFLOW (more rows were available but have been truncated by the TAP service)".getBytes());
output.flush();
// Report stats about the result writing:
......
......@@ -107,7 +107,7 @@ public class VOTableFormat implements OutputFormat {
protected String shortMimeType;
/**
* <p>Creates a VOTable formatter without format report.</p>
* <p>Creates a VOTable formatter.</p>
*
* <p><i>Note:
* The MIME type is automatically set to "application/x-votable+xml" = "votable".
......@@ -119,7 +119,7 @@ public class VOTableFormat implements OutputFormat {
* @throws NullPointerException If the given service connection is <code>null</code>.
*/
public VOTableFormat(final ServiceConnection service) throws NullPointerException{
this(service, false);
this(service, true);
}
/**
......@@ -141,7 +141,7 @@ public class VOTableFormat implements OutputFormat {
* @throws NullPointerException If the given service connection is <code>null</code>.
*/
public VOTableFormat(final ServiceConnection service, final DataFormat votFormat) throws NullPointerException{
this(service, votFormat, null, false);
this(service, votFormat, null, true);
}
/**
......@@ -164,7 +164,7 @@ public class VOTableFormat implements OutputFormat {
* @throws NullPointerException If the given service connection is <code>null</code>.
*/
public VOTableFormat(final ServiceConnection service, final DataFormat votFormat, final VOTableVersion votVersion) throws NullPointerException{
this(service, votFormat, votVersion, false);
this(service, votFormat, votVersion, true);
}
/**
......@@ -206,7 +206,7 @@ public class VOTableFormat implements OutputFormat {
*/
public VOTableFormat(final ServiceConnection service, final DataFormat votFormat, final VOTableVersion votVersion, final boolean logFormatReport) throws NullPointerException{
if (service == null)
throw new NullPointerException("The given service connection is NULL !");
throw new NullPointerException("The given service connection is NULL!");
this.service = service;
this.logFormatReport = logFormatReport;
......@@ -384,7 +384,7 @@ public class VOTableFormat implements OutputFormat {
if (logFormatReport)
service.getLogger().logTAP(LogLevel.INFO, execReport, "FORMAT", "Result formatted (in VOTable ; " + table.getNbReadRows() + " rows ; " + table.getColumnCount() + " columns) in " + (System.currentTimeMillis() - start) + "ms!", null);
}catch(IOException ioe){
throw new TAPException("Error while writing a query result in VOTable !", ioe);
throw new TAPException("Error while writing a query result in VOTable!", ioe);
}
}
......@@ -610,7 +610,7 @@ public class VOTableFormat implements OutputFormat {
* </p>
*
* @author Gr&eacute;gory Mantelet (CDS;ARI)
* @version 2.0 (07/2014)
* @version 2.0 (10/2014)
* @since 2.0
*/
private static class LimitedStarTable extends AbstractStarTable {
......@@ -702,6 +702,7 @@ public class VOTableFormat implements OutputFormat {
if (hasNext){
for(int i = 0; i < nbCol && tableIt.hasNextCol(); i++)
row[i] = tableIt.nextCol();
nbRows++;
}else
row = null;
return hasNext;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment