I have a simple main where I'm trying to read long values from a column in Java:
import java.util.Vector;
import org.jlab.ccdb.Assignment;
import org.jlab.ccdb.CcdbPackage;
import org.jlab.ccdb.JDBCProvider;
import org.jlab.ccdb.TypeTableColumn;
public class ReadTest {
static final String CONNECTION = "sqlite:////u/ey/jeremym/hps-dev/ccdb-scratch/scratch/ccdb.sqlite";
static final int RUN = 5772;
static final String TABLE = "/ECAL/calibrations";
public static void main(String[] args) {
JDBCProvider provider = CcdbPackage.createProvider(CONNECTION);
provider.connect();
provider.setDefaultRun(5772);
Assignment a = provider.getData(TABLE);
Vector<TypeTableColumn> typeTable = a.getTypeTable().getColumns();
for (TypeTableColumn col : typeTable) {
System.out.println(col.getName() + ":" + col.getCellType());
}
Vector<Long> channelIds = a.getColumnValuesLong(0); // Throws exception but column is actually a long!
Vector<Double> pedestals = a.getColumnValuesDouble(1);
Vector<Double> noise = a.getColumnValuesDouble(2);
int len = channelIds.size();
for (int i = 0; i < len; i++) {
System.out.println(channelIds.get(i) + " " + pedestals.get(i) + " " + noise.get(i));
}
provider.close();
}
}
The column info in the db looks like:
+------------------------------------------+
| Columns info |
+------------------------------------------+
Columns info
N. (type) : (name)
0 long : ecal_channel_id
1 double : pedestal
2 double : noise
The test does not work though. The Java API is not able to read back the long values, e.g.
Exception in thread "main" java.lang.NumberFormatException: For input string: "1L"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
at java.lang.Long.parseLong(Long.java:589)
at java.lang.Long.parseLong(Long.java:631)
at org.jlab.ccdb.Assignment.getColumnValuesLong(model.kt:355)
at ReadTest.main(ReadTest.java:26)
The Java API seems to know the correct column types though:
ecal_channel_id:long
pedestal:double
noise:double
Any idea why this might be?
I was seeing similar problems for int columns as well.
This is using Java 1.8 with the CCDB master and Python 2.7 (I'm suspecting there's an issue here with python 2.7 adding the 'L' to these values).
I have a simple main where I'm trying to read long values from a column in Java:
The column info in the db looks like:
The test does not work though. The Java API is not able to read back the long values, e.g.
The Java API seems to know the correct column types though:
Any idea why this might be?
I was seeing similar problems for int columns as well.
This is using Java 1.8 with the CCDB master and Python 2.7 (I'm suspecting there's an issue here with python 2.7 adding the 'L' to these values).