changeset 57:7c3a84de7605 embedded

More cleanup, finished null values mappings.
author Pedro Ferreira <pedro.ferreira@monetdbsolutions.com>
date Tue, 22 Nov 2016 12:13:34 +0100 (2016-11-22)
parents 9da3f178a115
children 2053a9fc56ca
files src/main/java/nl/cwi/monetdb/embedded/env/MonetDBEmbeddedConnection.java src/main/java/nl/cwi/monetdb/embedded/env/MonetDBEmbeddedDatabase.java src/main/java/nl/cwi/monetdb/embedded/mapping/MonetDBEmbeddedBlob.java src/main/java/nl/cwi/monetdb/embedded/mapping/MonetDBToJavaMapping.java src/main/java/nl/cwi/monetdb/embedded/resultset/QueryResultSetBooleanColumn.java src/main/java/nl/cwi/monetdb/embedded/resultset/QueryResultSetByteColumn.java src/main/java/nl/cwi/monetdb/embedded/resultset/QueryResultSetDoubleColumn.java src/main/java/nl/cwi/monetdb/embedded/resultset/QueryResultSetFloatColumn.java src/main/java/nl/cwi/monetdb/embedded/resultset/QueryResultSetIntColumn.java src/main/java/nl/cwi/monetdb/embedded/resultset/QueryResultSetLongColumn.java src/main/java/nl/cwi/monetdb/embedded/resultset/QueryResultSetObjectColumn.java src/main/java/nl/cwi/monetdb/embedded/resultset/QueryResultSetShortColumn.java src/main/java/nl/cwi/monetdb/embedded/tables/MonetDBTable.java
diffstat 13 files changed, 222 insertions(+), 136 deletions(-) [+]
line wrap: on
line diff
--- a/src/main/java/nl/cwi/monetdb/embedded/env/MonetDBEmbeddedConnection.java
+++ b/src/main/java/nl/cwi/monetdb/embedded/env/MonetDBEmbeddedConnection.java
@@ -12,8 +12,7 @@ import nl.cwi.monetdb.embedded.resultset
 import nl.cwi.monetdb.embedded.tables.MonetDBTable;
 import nl.cwi.monetdb.embedded.utils.StringEscaper;
 
-import java.util.HashSet;
-import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
 
 /**
  * A single connection to a MonetDB database instance
@@ -27,10 +26,12 @@ public class MonetDBEmbeddedConnection {
 
 	protected final long connectionPointer;
 
-    private final Set<AbstractConnectionResult> results = new HashSet<>();
+    private final ConcurrentHashMap<Long, AbstractConnectionResult> results = new ConcurrentHashMap<>();
 
 	protected MonetDBEmbeddedConnection(long connectionPointer) { this.connectionPointer = connectionPointer; }
 
+    protected long getConnectionPointer() { return connectionPointer; }
+
     /**
      * Gets the current schema set on the connection.
      *
@@ -95,7 +96,7 @@ public class MonetDBEmbeddedConnection {
             query += ";";
         }
         UpdateResultSet res = this.sendUpdateInternal(this.connectionPointer, query, true);
-        results.add(res);
+        results.put(res.getConnectionPointer(), res);
         return res;
     }
 
@@ -122,7 +123,7 @@ public class MonetDBEmbeddedConnection {
             query += ";";
 		}
         QueryResultSet res = this.sendQueryInternal(this.connectionPointer, query, true);
-        results.add(res);
+        results.put(res.getConnectionPointer(), res);
         return res;
 	}
 
@@ -147,7 +148,7 @@ public class MonetDBEmbeddedConnection {
      */
     public MonetDBTable getMonetDBTable(String schemaName, String tableName) throws MonetDBEmbeddedException {
         MonetDBTable res = this.getMonetDBTableInternal(this.connectionPointer, schemaName, tableName);
-        results.add(res);
+        results.put(res.getConnectionPointer(), res);
         return res;
     }
 
@@ -215,7 +216,7 @@ public class MonetDBEmbeddedConnection {
      * When the database is shuts down, this method is called instead
      */
     protected void closeConnectionImplementation() {
-        for(AbstractConnectionResult res : this.results) {
+        for(AbstractConnectionResult res : this.results.values()) {
             res.closeImplementation();
         }
         this.closeConnectionInternal(this.connectionPointer);
@@ -239,7 +240,7 @@ public class MonetDBEmbeddedConnection {
     /**
      * Removes a query result from this connection.
      */
-    protected void removeQueryResult(AbstractConnectionResult res) { this.results.remove(res); }
+    protected void removeQueryResult(AbstractConnectionResult res) { this.results.remove(res.getConnectionPointer()); }
 
     /**
      * Internal implementation of sendUpdate.
--- a/src/main/java/nl/cwi/monetdb/embedded/env/MonetDBEmbeddedDatabase.java
+++ b/src/main/java/nl/cwi/monetdb/embedded/env/MonetDBEmbeddedDatabase.java
@@ -8,8 +8,7 @@
 
 package nl.cwi.monetdb.embedded.env;
 
-import java.util.HashSet;
-import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
 
 /**
  * An embedded version of a MonetDB database.
@@ -68,23 +67,41 @@ public class MonetDBEmbeddedDatabase {
     /**
      * Get the database farm directory.
      *
+     * @throws MonetDBEmbeddedException If the database is not running
      * @return A String representing the farm directory
      */
-    public static String GetDatabaseDirectory() { return MonetDBEmbeddedDatabase.databaseDirectory; }
+    public static String GetDatabaseDirectory() throws MonetDBEmbeddedException {
+        if(MonetDBEmbeddedDatabase == null) {
+            throw new MonetDBEmbeddedException("The database is not running!");
+        }
+        return MonetDBEmbeddedDatabase.databaseDirectory;
+    }
 
     /**
      * Check if the Silent Flag was set while creating the database.
      *
+     * @throws MonetDBEmbeddedException If the database is not running
      * @return The Silent Flag
      */
-    public static boolean IsSilentFlagSet() { return MonetDBEmbeddedDatabase.silentFlag; }
+    public static boolean IsSilentFlagSet() throws MonetDBEmbeddedException {
+        if(MonetDBEmbeddedDatabase == null) {
+            throw new MonetDBEmbeddedException("The database is not running!");
+        }
+        return MonetDBEmbeddedDatabase.silentFlag;
+    }
 
     /**
      * Check if the Sequential Flag was set while creating the database.
      *
+     * @throws MonetDBEmbeddedException If the database is not running
      * @return The Sequential Flag
      */
-    public static boolean IsSequentialFlagSet() { return MonetDBEmbeddedDatabase.sequentialFlag; }
+    public static boolean IsSequentialFlagSet() throws MonetDBEmbeddedException {
+        if(MonetDBEmbeddedDatabase == null) {
+            throw new MonetDBEmbeddedException("The database is not running!");
+        }
+        return MonetDBEmbeddedDatabase.sequentialFlag;
+    }
 
     /**
      * Stops the database. All the pending connections will be shut down as well.
@@ -95,7 +112,7 @@ public class MonetDBEmbeddedDatabase {
         if(MonetDBEmbeddedDatabase == null) {
             throw new MonetDBEmbeddedException("The database is not running!");
         } else {
-            for(MonetDBEmbeddedConnection mdbec : MonetDBEmbeddedDatabase.connections) {
+            for(MonetDBEmbeddedConnection mdbec : MonetDBEmbeddedDatabase.connections.values()) {
                 mdbec.closeConnectionImplementation();
             }
             MonetDBEmbeddedDatabase.connections.clear();
@@ -119,7 +136,7 @@ public class MonetDBEmbeddedDatabase {
 
     private final boolean sequentialFlag;
 
-    private final Set<MonetDBEmbeddedConnection> connections = new HashSet<>();
+    private final ConcurrentHashMap<Long, MonetDBEmbeddedConnection> connections = new ConcurrentHashMap<>();
 
     private MonetDBEmbeddedDatabase(String dbDirectory, boolean silentFlag, boolean sequentialFlag) {
         this.databaseDirectory = dbDirectory;
@@ -134,7 +151,13 @@ public class MonetDBEmbeddedDatabase {
      * @throws MonetDBEmbeddedException If the database is not running or an error in the database occurred
      */
     public static MonetDBEmbeddedConnection CreateConnection() throws MonetDBEmbeddedException {
-        return MonetDBEmbeddedDatabase.createConnectionInternal();
+        if(MonetDBEmbeddedDatabase == null) {
+            throw new MonetDBEmbeddedException("The database is not running!");
+        } else {
+            MonetDBEmbeddedConnection con = MonetDBEmbeddedDatabase.createConnectionInternal();
+            MonetDBEmbeddedDatabase.connections.put(con.getConnectionPointer(), con);
+            return con;
+        }
     }
 
     /**
@@ -151,7 +174,7 @@ public class MonetDBEmbeddedDatabase {
      * Removes a connection from this database.
      */
     protected static void RemoveConnection(MonetDBEmbeddedConnection con) {
-        MonetDBEmbeddedDatabase.connections.remove(con);
+        MonetDBEmbeddedDatabase.connections.remove(con.connectionPointer);
     }
 
     /**
--- a/src/main/java/nl/cwi/monetdb/embedded/mapping/MonetDBEmbeddedBlob.java
+++ b/src/main/java/nl/cwi/monetdb/embedded/mapping/MonetDBEmbeddedBlob.java
@@ -19,7 +19,7 @@ import java.util.Collections;
  *
  * @author <a href="mailto:pedro.ferreira@monetdbsolutions.com">Pedro Ferreira</a>
  */
-public class MonetDBEmbeddedBlob implements Serializable, Blob {
+public class MonetDBEmbeddedBlob implements Serializable, Blob, Comparable<MonetDBEmbeddedBlob> {
 
     /**
      * The BLOB's content as a Java byte array.
@@ -156,4 +156,14 @@ public class MonetDBEmbeddedBlob impleme
         this.checkFreed();
         return new ByteArrayInputStream(Arrays.copyOfRange(this.blob, (int) pos, (int) length));
     }
+
+    @Override
+    public int compareTo(MonetDBEmbeddedBlob o) {
+        byte[] first = this.blob, second = o.blob;
+        int len = Math.min(first.length, second.length), res = 0;
+        for(int i = 0; i < len ; i++) {
+            res = res + first[i] - second[i];
+        }
+        return res;
+    }
 }
--- a/src/main/java/nl/cwi/monetdb/embedded/mapping/MonetDBToJavaMapping.java
+++ b/src/main/java/nl/cwi/monetdb/embedded/mapping/MonetDBToJavaMapping.java
@@ -15,6 +15,7 @@ import java.net.URL;
 import java.sql.Date;
 import java.sql.Time;
 import java.sql.Timestamp;
+import java.util.EnumMap;
 import java.util.HashMap;
 import java.util.UUID;
 
@@ -39,6 +40,11 @@ public enum MonetDBToJavaMapping {
      */
     private static final HashMap<String, MonetDBToJavaMapping> MonetDBMappings;
 
+    /**
+     * The mapping between MonetDB data types and enum values.
+     */
+    private static final EnumMap<MonetDBToJavaMapping, Class<?>> AppendMappings;
+
     static {
         MonetDBMappings = new HashMap<>();
         MonetDBMappings.put("boolean", Boolean);
@@ -69,6 +75,36 @@ public enum MonetDBToJavaMapping {
         MonetDBMappings.put("inet", Inet);
         MonetDBMappings.put("json", JSON);
         MonetDBMappings.put("uuid", UUID);
+
+        AppendMappings = new EnumMap<>(MonetDBToJavaMapping.class);
+        AppendMappings.put(Boolean, boolean[].class);
+        AppendMappings.put(Char, String[].class);
+        AppendMappings.put(Varchar, String[].class);
+        AppendMappings.put(Clob, String[].class);
+        AppendMappings.put(Oid, long[].class);
+        AppendMappings.put(Tinyint, byte[].class);
+        AppendMappings.put(Smallint, short[].class);
+        AppendMappings.put(Int, int[].class);
+        AppendMappings.put(Wrd, long[].class);
+        AppendMappings.put(Bigint, long[].class);
+        AppendMappings.put(Hugeint, BigInteger[].class);
+        AppendMappings.put(Decimal, BigDecimal[].class);
+        AppendMappings.put(Real, float[].class);
+        AppendMappings.put(Double, double[].class);
+        AppendMappings.put(MonthInterval, int[].class);
+        AppendMappings.put(SecondInterval, long[].class);
+        AppendMappings.put(Time, Time[].class);
+        AppendMappings.put(TimeTz, Time[].class);
+        AppendMappings.put(Date, Date[].class);
+        AppendMappings.put(Timestamp, Timestamp[].class);
+        AppendMappings.put(TimestampTz, Timestamp[].class);
+        AppendMappings.put(Blob, MonetDBEmbeddedBlob[].class);
+        AppendMappings.put(Geometry, MonetDBEmbeddedBlob[].class);
+        AppendMappings.put(GeometryA, MonetDBEmbeddedBlob[].class);
+        AppendMappings.put(URL, URL[].class);
+        AppendMappings.put(Inet, Inet4Address[].class);
+        AppendMappings.put(JSON, MonetDBEmbeddedBlob[].class);
+        AppendMappings.put(UUID, UUID[].class);
     }
 
     /**
@@ -82,11 +118,21 @@ public enum MonetDBToJavaMapping {
     }
 
     /**
+     * Get the corresponding MonetDBToJavaMapping from MonetDB internal data type.
+     *
+     * @param value A MonetDBToJavaMapping entry
+     * @return The corresponding Java array class or null if no mapping
+     */
+    public static Class<?> GetArrayMappingFromEnumValue(MonetDBToJavaMapping value) {
+        return AppendMappings.get(value);
+    }
+
+    /**
      * The corresponding Java class for the enum value.
      */
     private final Class<?> javaClass;
 
-    MonetDBToJavaMapping(Class<?> javaClass) { this.javaClass = javaClass;}
+    MonetDBToJavaMapping(Class<?> javaClass) { this.javaClass = javaClass; }
 
     /**
      * Gets the corresponding Java class for the enum value.
--- a/src/main/java/nl/cwi/monetdb/embedded/resultset/QueryResultSetBooleanColumn.java
+++ b/src/main/java/nl/cwi/monetdb/embedded/resultset/QueryResultSetBooleanColumn.java
@@ -18,16 +18,20 @@ import nl.cwi.monetdb.embedded.env.Monet
 public class QueryResultSetBooleanColumn extends AbstractQueryResultSetColumn<boolean[]> {
 
     /**
-     * MonetDB's boolean null constant.
-     */
-    private static boolean BooleanNullConstant;
-
-    /**
      * Gets MonetDB's boolean null constant
      *
      * @return MonetDB's boolean null constant
      */
-    public static boolean GetBooleanNullConstant() { return BooleanNullConstant; }
+    public static native boolean GetBooleanNullConstant();
+
+    /**
+     * Due to restrictions on the representation of boolean values in the Java language, this method should be called
+     * to check if a boolean value is null or not.
+     *
+     * @param value The value to evaluate
+     * @return If the value is null or not
+     */
+    public static native boolean CheckBooleanIsNull(boolean value);
 
     /**
      * Array with the retrieved values.
@@ -58,17 +62,19 @@ public class QueryResultSetBooleanColumn
 
     @Override
     protected boolean[] checkIfIndexesAreNullImplementation(boolean[] values, boolean[] res) throws MonetDBEmbeddedException {
+        boolean nil = GetBooleanNullConstant();
         for(int i = 0 ; i < values.length ; i++) {
-            res[i] = (values[i] == BooleanNullConstant);
+            res[i] = (values[i] == nil);
         }
         return res;
     }
 
     @Override
     protected Boolean[] mapValuesToObjectArrayImplementation(boolean[] values) throws MonetDBEmbeddedException {
+        boolean nil = GetBooleanNullConstant();
         Boolean[] res = new Boolean[values.length];
         for(int i = 0 ; i < values.length ; i++) {
-            res[i] = (values[i] == BooleanNullConstant) ? null : values[i];
+            res[i] = (values[i] == nil) ? null : values[i];
         }
         return res;
     }
--- a/src/main/java/nl/cwi/monetdb/embedded/resultset/QueryResultSetByteColumn.java
+++ b/src/main/java/nl/cwi/monetdb/embedded/resultset/QueryResultSetByteColumn.java
@@ -18,16 +18,19 @@ import nl.cwi.monetdb.embedded.env.Monet
 public class QueryResultSetByteColumn extends AbstractQueryResultSetColumn<byte[]> {
 
     /**
-     * MonetDB's byte null constant.
-     */
-    private static byte ByteNullConstant;
-
-    /**
      * Gets MonetDB's byte null constant
      *
      * @return MonetDB's byte null constant
      */
-    public static byte GetByteNullConstant() { return ByteNullConstant; }
+    public static native byte GetByteNullConstant();
+
+    /**
+     * Checks if the short value is null or not.
+     *
+     * @param value The value to evaluate
+     * @return If the short value is null or not.
+     */
+    public static native boolean CheckByteIsNull(byte value);
 
     /**
      * Array with the retrieved values.
@@ -58,17 +61,19 @@ public class QueryResultSetByteColumn ex
 
     @Override
     protected boolean[] checkIfIndexesAreNullImplementation(byte[] values, boolean[] res) throws MonetDBEmbeddedException {
+        byte nil = GetByteNullConstant();
         for(int i = 0 ; i < values.length ; i++) {
-            res[i] = (values[i] == ByteNullConstant);
+            res[i] = (values[i] == nil);
         }
         return res;
     }
 
     @Override
     protected Byte[] mapValuesToObjectArrayImplementation(byte[] values) throws MonetDBEmbeddedException {
+        byte nil = GetByteNullConstant();
         Byte[] res = new Byte[values.length];
         for(int i = 0 ; i < values.length ; i++) {
-            res[i] = (values[i] == ByteNullConstant) ? null : values[i];
+            res[i] = (values[i] == nil) ? null : values[i];
         }
         return res;
     }
--- a/src/main/java/nl/cwi/monetdb/embedded/resultset/QueryResultSetDoubleColumn.java
+++ b/src/main/java/nl/cwi/monetdb/embedded/resultset/QueryResultSetDoubleColumn.java
@@ -18,16 +18,19 @@ import nl.cwi.monetdb.embedded.env.Monet
 public class QueryResultSetDoubleColumn extends AbstractQueryResultSetColumn<double[]> {
 
     /**
-     * MonetDB's double null constant.
-     */
-    private static double DoubleNullConstant;
-
-    /**
      * Gets MonetDB's double null constant
      *
      * @return MonetDB's double null constant
      */
-    public static double GetDoubleNullConstant() { return DoubleNullConstant; }
+    public static native double GetDoubleNullConstant();
+
+    /**
+     * Checks if the double value is null or not.
+     *
+     * @param value The value to evaluate
+     * @return If the double value is null or not.
+     */
+    public static native boolean CheckDoubleIsNull(double value);
 
     /**
      * Array with the retrieved values.
@@ -58,17 +61,19 @@ public class QueryResultSetDoubleColumn 
 
     @Override
     protected boolean[] checkIfIndexesAreNullImplementation(double[] values, boolean[] res) throws MonetDBEmbeddedException {
+        double nil = GetDoubleNullConstant();
         for(int i = 0 ; i < values.length ; i++) {
-            res[i] = (values[i] == DoubleNullConstant);
+            res[i] = (values[i] == nil);
         }
         return res;
     }
 
     @Override
     protected Double[] mapValuesToObjectArrayImplementation(double[] values) throws MonetDBEmbeddedException {
+        double nil = GetDoubleNullConstant();
         Double[] res = new Double[values.length];
         for(int i = 0 ; i < values.length ; i++) {
-            res[i] = (values[i] == DoubleNullConstant) ? null : values[i];
+            res[i] = (values[i] == nil) ? null : values[i];
         }
         return res;
     }
--- a/src/main/java/nl/cwi/monetdb/embedded/resultset/QueryResultSetFloatColumn.java
+++ b/src/main/java/nl/cwi/monetdb/embedded/resultset/QueryResultSetFloatColumn.java
@@ -18,16 +18,19 @@ import nl.cwi.monetdb.embedded.env.Monet
 public class QueryResultSetFloatColumn extends AbstractQueryResultSetColumn<float[]> {
 
     /**
-     * MonetDB's float null constant.
-     */
-    private static float FloatNullConstant;
-
-    /**
      * Gets MonetDB's float null constant
      *
      * @return MonetDB's float null constant
      */
-    public static float GetFloatNullConstant() { return FloatNullConstant; }
+    public static native float GetFloatNullConstant();
+
+    /**
+     * Checks if the float value is null or not.
+     *
+     * @param value The value to evaluate
+     * @return If the float value is null or not.
+     */
+    public static native boolean CheckFloatIsNull(float value);
 
     /**
      * Array with the retrieved values.
@@ -58,17 +61,19 @@ public class QueryResultSetFloatColumn e
 
     @Override
     protected boolean[] checkIfIndexesAreNullImplementation(float[] values, boolean[] res) throws MonetDBEmbeddedException {
+        float nil = GetFloatNullConstant();
         for(int i = 0 ; i < values.length ; i++) {
-            res[i] = (values[i] == FloatNullConstant);
+            res[i] = (values[i] == nil);
         }
         return res;
     }
 
     @Override
     protected Float[] mapValuesToObjectArrayImplementation(float[] values) throws MonetDBEmbeddedException {
+        float nil = GetFloatNullConstant();
         Float[] res = new Float[values.length];
         for(int i = 0 ; i < values.length ; i++) {
-            res[i] = (values[i] == FloatNullConstant) ? null : values[i];
+            res[i] = (values[i] == nil) ? null : values[i];
         }
         return res;
     }
--- a/src/main/java/nl/cwi/monetdb/embedded/resultset/QueryResultSetIntColumn.java
+++ b/src/main/java/nl/cwi/monetdb/embedded/resultset/QueryResultSetIntColumn.java
@@ -18,16 +18,19 @@ import nl.cwi.monetdb.embedded.env.Monet
 public class QueryResultSetIntColumn extends AbstractQueryResultSetColumn<int[]> {
 
     /**
-     * MonetDB's int null constant.
-     */
-    private static int IntNullConstant;
-
-    /**
      * Gets MonetDB's int null constant
      *
      * @return MonetDB's int null constant
      */
-    public static int GetIntNullConstant() { return IntNullConstant; }
+    public static native int GetIntNullConstant();
+
+    /**
+     * Checks if the int value is null or not.
+     *
+     * @param value The value to evaluate
+     * @return If the int value is null or not.
+     */
+    public static native boolean CheckIntIsNull(int value);
 
     /**
      * Array with the retrieved values.
@@ -58,17 +61,19 @@ public class QueryResultSetIntColumn ext
 
     @Override
     protected boolean[] checkIfIndexesAreNullImplementation(int[] values, boolean[] res) throws MonetDBEmbeddedException {
+        int nil = GetIntNullConstant();
         for(int i = 0 ; i < values.length ; i++) {
-            res[i] = (values[i] == IntNullConstant);
+            res[i] = (values[i] == nil);
         }
         return res;
     }
 
     @Override
     protected Integer[] mapValuesToObjectArrayImplementation(int[] values) throws MonetDBEmbeddedException {
+        int nil = GetIntNullConstant();
         Integer[] res = new Integer[values.length];
         for(int i = 0 ; i < values.length ; i++) {
-            res[i] = (values[i] == IntNullConstant) ? null : values[i];
+            res[i] = (values[i] == nil) ? null : values[i];
         }
         return res;
     }
--- a/src/main/java/nl/cwi/monetdb/embedded/resultset/QueryResultSetLongColumn.java
+++ b/src/main/java/nl/cwi/monetdb/embedded/resultset/QueryResultSetLongColumn.java
@@ -18,16 +18,19 @@ import nl.cwi.monetdb.embedded.env.Monet
 public class QueryResultSetLongColumn extends AbstractQueryResultSetColumn<long[]> {
 
     /**
-     * MonetDB's long null constant.
-     */
-    private static long LongNullConstant;
-
-    /**
      * Gets MonetDB's long null constant
      *
      * @return MonetDB's long null constant
      */
-    public static long GetIntegerNullConstant() { return LongNullConstant; }
+    public static native long GetLongNullConstant();
+
+    /**
+     * Checks if the long value is null or not.
+     *
+     * @param value The value to evaluate
+     * @return If the long value is null or not.
+     */
+    public static native boolean CheckLongIsNull(long value);
 
     /**
      * Array with the retrieved values.
@@ -58,17 +61,19 @@ public class QueryResultSetLongColumn ex
 
     @Override
     protected boolean[] checkIfIndexesAreNullImplementation(long[] values, boolean[] res) throws MonetDBEmbeddedException {
+        long nil = GetLongNullConstant();
         for(int i = 0 ; i < values.length ; i++) {
-            res[i] = (values[i] == LongNullConstant);
+            res[i] = (values[i] == nil);
         }
         return res;
     }
 
     @Override
     protected Long[] mapValuesToObjectArrayImplementation(long[] values) throws MonetDBEmbeddedException {
+        long nil = GetLongNullConstant();
         Long[] res = new Long[values.length];
         for(int i = 0 ; i < values.length ; i++) {
-            res[i] = (values[i] == LongNullConstant) ? null : values[i];
+            res[i] = (values[i] == nil) ? null : values[i];
         }
         return res;
     }
--- a/src/main/java/nl/cwi/monetdb/embedded/resultset/QueryResultSetObjectColumn.java
+++ b/src/main/java/nl/cwi/monetdb/embedded/resultset/QueryResultSetObjectColumn.java
@@ -23,6 +23,21 @@ import java.util.ListIterator;
 public class QueryResultSetObjectColumn<T> extends AbstractQueryResultSetColumn<T[]> implements Iterable<T> {
 
     /**
+     * A null pointer returning method.
+     *
+     * @return A null pointer
+     */
+    public static Object GetObjectNullConstant() { return null; }
+
+    /**
+     * Checks if the Object value is null or not.
+     *
+     * @param value The value to evaluate
+     * @return If the Object value is null or not.
+     */
+    public static boolean CheckObjectIsNull(Object value) { return value == null; }
+
+    /**
      * Array with the retrieved values.
      */
     private final T[] values;
--- a/src/main/java/nl/cwi/monetdb/embedded/resultset/QueryResultSetShortColumn.java
+++ b/src/main/java/nl/cwi/monetdb/embedded/resultset/QueryResultSetShortColumn.java
@@ -18,16 +18,19 @@ import nl.cwi.monetdb.embedded.env.Monet
 public class QueryResultSetShortColumn extends AbstractQueryResultSetColumn<short[]> {
 
     /**
-     * MonetDB's short null constant.
-     */
-    private static short ShortNullConstant;
-
-    /**
      * Gets MonetDB's short null constant
      *
      * @return MonetDB's short null constant
      */
-    public static short GetShortNullConstant() { return ShortNullConstant; }
+    public static native short GetShortNullConstant();
+
+    /**
+     * Checks if the short value is null or not.
+     *
+     * @param value The value to evaluate
+     * @return If the short value is null or not.
+     */
+    public static native boolean CheckShortIsNull(short value);
 
     /**
      * Array with the retrieved values.
@@ -38,7 +41,7 @@ public class QueryResultSetShortColumn e
                                         int columnDigits, int columnScale, int numberOfRows) {
         super(columnType, tablePointer, resultSetIndex, columnName, columnDigits, columnScale, numberOfRows);
         if(!this.getMapping().getJavaClass().equals(Short.class)) {
-            throw new ClassCastException("The parameter must be of boolean type!!");
+            throw new ClassCastException("The parameter must be of short type!!");
         }
         this.values = new short[numberOfRows];
     }
@@ -58,17 +61,19 @@ public class QueryResultSetShortColumn e
 
     @Override
     protected boolean[] checkIfIndexesAreNullImplementation(short[] values, boolean[] res) throws MonetDBEmbeddedException {
+        short nil = GetShortNullConstant();
         for(int i = 0 ; i < values.length ; i++) {
-            res[i] = (values[i] == ShortNullConstant);
+            res[i] = (values[i] == nil);
         }
         return res;
     }
 
     @Override
     protected Short[] mapValuesToObjectArrayImplementation(short[] values) throws MonetDBEmbeddedException {
+        short nil = GetShortNullConstant();
         Short[] res = new Short[values.length];
         for(int i = 0 ; i < values.length ; i++) {
-            res[i] = (values[i] == ShortNullConstant) ? null : values[i];
+            res[i] = (values[i] == nil) ? null : values[i];
         }
         return res;
     }
--- a/src/main/java/nl/cwi/monetdb/embedded/tables/MonetDBTable.java
+++ b/src/main/java/nl/cwi/monetdb/embedded/tables/MonetDBTable.java
@@ -176,72 +176,27 @@ public class MonetDBTable extends Abstra
     }
 
     /**
-     * Appends new rows to the table. As MonetDB's storage is column-wise, the method
-     * {@link nl.cwi.monetdb.embedded.tables.MonetDBTable#appendColumns(Object[][]) appendColumns} is preferable
-     * over this one.
-     *
-     * @param data An array of rows to append
-     * @return The number of rows appended
-     * @throws MonetDBEmbeddedException If an error in the database occurred
-     */
-    public int appendRows(Object[][] data) throws MonetDBEmbeddedException {
-        int numberOfRows = data.length, numberOfColumns = this.getNumberOfColumns();
-        if(numberOfRows == 0) {
-            throw new ArrayStoreException("Appending 0 rows?");
-        }
-        Object[][] transposed = new Object[numberOfColumns][numberOfRows];
-
-        for (int i = 0; i < numberOfRows; i++) {
-            if(data[i].length != numberOfColumns) {
-                throw new ArrayStoreException("The values array at row " + i + " differs from the number of columns!");
-            }
-            for (int j = 0; j < numberOfColumns; j++) {
-                transposed[j][i] = data[i][j];
-            }
-        }
-        return this.appendColumns(transposed);
-    }
-
-    /**
-     * Appends new rows to the table asynchronously.
-     *
-     * @param rows An array of rows to append
-     * @return The number of rows appended
-     * @throws MonetDBEmbeddedException If an error in the database occurred
-     */
-    /*public CompletableFuture<Integer> appendRowsAsync(Object[][] rows) throws MonetDBEmbeddedException {
-        return CompletableFuture.supplyAsync(() -> this.appendRows(schemaName, tableName));
-    }*/
-
-    /**
-     * Appends new rows to the table column-wise. As MonetDB's storage is column-wise, this method is preferable over
-     * {@link nl.cwi.monetdb.embedded.tables.MonetDBTable#appendRows(Object[][]) appendRows} method.
+     * Appends new rows to the table column-wise.
      *
      * @param data An array of columns to append
      * @return The number of rows appended
      * @throws MonetDBEmbeddedException If an error in the database occurred
      */
-    public int appendColumns(Object[][] data) throws MonetDBEmbeddedException {
+    public int appendColumns(Object[] data) throws MonetDBEmbeddedException {
         MonetDBToJavaMapping[] mappings = this.getMappings();
-        int numberOfRowsToInsert = data[0].length, numberOfColumns = mappings.length;
-        if (data.length != numberOfColumns) {
-            throw new ArrayStoreException("The number of columns differs from the table's number of columns!");
+        if (data.length != mappings.length) {
+            throw new ArrayStoreException("The number of columns between the data nad the classes is not consistent!");
         }
-        if(numberOfRowsToInsert == 0) {
-            throw new ArrayStoreException("Appending 0 rows?");
+        if (mappings.length != this.getNumberOfColumns()) {
+            throw new ArrayStoreException("The number of columns between data and the table is not consistent!");
         }
-        for (int i = 0; i < numberOfColumns; i++) {
-            if(data[i].length != numberOfRowsToInsert) {
-                throw new ArrayStoreException("The number of rows in each column is not consistent!");
-            }
+        int[] javaIndexes = new int[mappings.length];
+        Class<?>[] javaClasses = new Class<?>[mappings.length];
+        for (int i = 0; i < mappings.length; i++) {
+            javaIndexes[i] = mappings[i].ordinal();
+            javaClasses[i] = mappings[i].getJavaClass();
         }
-        Class[] jClasses = new Class[mappings.length];
-        int[] javaIndexes = new int[mappings.length];
-        for (int i = 0; i < mappings.length; i++) {
-            jClasses[i] = mappings[i].getJavaClass();
-            javaIndexes[i] = mappings[i].ordinal();
-        }
-        return this.appendColumnsInternal(jClasses, javaIndexes, data, numberOfRowsToInsert);
+        return this.appendColumnsInternal(data, javaIndexes, javaClasses);
     }
 
     /*
@@ -251,13 +206,13 @@ public class MonetDBTable extends Abstra
      * @return The number of rows appended
      * @throws MonetDBEmbeddedException If an error in the database occurred
      */
-    /*public CompletableFuture<Integer> appendColumnsAsync(Object[][] data) throws MonetDBEmbeddedException {
-        return CompletableFuture.supplyAsync(() -> this.appendColumns(schemaName, tableName));
+    /*public CompletableFuture<Integer> appendColumnsAsync(Object[] data) throws MonetDBEmbeddedException {
+        return CompletableFuture.supplyAsync(() -> this.appendColumns(data));
     }*/
 
     @Override
     protected void closeImplementation() {}
 
-    private native int appendColumnsInternal(Class[] jClasses, int[] javaIndexes, Object[][] data, int numberOfRows)
+    private native int appendColumnsInternal(Object[] data, int[] javaIndexes, Class<?>[] javaClasses)
             throws MonetDBEmbeddedException;
 }