Append single Row to 1D array


#1

Hello everybody,

I’ve read this topic http://forum.paradigm4.com/t/append-data-to-existing-array/749 but this is not really my use case and probably too complicated for me at the moment since I just started with SciDB.

I’m currently using SciDB 18.1 on my VM on Ubuntu 14.04, my ultimate goal is to use the SciDB JDBC feature, because we’re using alot of JAVA. I got my data inside a Database and my table rundata is reflecting the array.

I create the array in the following way:

CREATE ARRAY rundata
<id:int64, signal:string, timekey:double, value:double>[dim0];

id, signal, timekey, value are the columns of the database table rundata.

Now what I want to do is something like this:

ResultSet rundata = db.executeQuery("Select run_id, signal_name, timekey, value from rundata");
		while(rundata.next()){
			StringBuilder sb = new StringBuilder("'[");
			//'[(0, ALFA, 0.0, 0.0)]'
			sb.append("(");
			sb.append(rundata.getInt(1));
			sb.append(", ");
			sb.append(rundata.getString(2));
			sb.append(", ");
			sb.append(rundata.getFloat(3));
			sb.append(", ");
			sb.append(rundata.getFloat(4));
			sb.append("), ");
			sb.append("]'");
			insertInto(conn, "rundata", sb.toString());
		}

whereas the insertInto(conn, “rundata”, sb.toString()); function should append one row to the rundata array, but the “INSERT INTO” statement always replaces the first entry of the rundata array.

private static void insertInto(Connection conn, String into, String data) throws SQLException {
    Statement st = conn.createStatement();
    st.executeQuery("INSERT INTO " + into + " " + data);
    st.close();
    conn.commit();
}

Do I need to use the proposed solution at http://forum.paradigm4.com/t/append-data-to-existing-array/749 or is there a more simple way?

I’m currently trying to do it via CSV but exporting the data from the database to CSV is taking quite a long time and I would appriciate it, if I could skip it.

Greetings
Ninti