org.intermine.sql.writebatch
Class TableBatch

java.lang.Object
  extended by org.intermine.sql.writebatch.TableBatch
All Implemented Interfaces:
Table

public class TableBatch
extends java.lang.Object
implements Table

A class representing all changes to be made to an SQL table.


Constructor Summary
TableBatch()
          Constructor for this class.
 
Method Summary
 int addRow(java.lang.Object idValue, java.lang.String[] colNames, java.lang.Object[] values)
          Adds a row to the batch.
 void clear()
          Clears the batch.
 int deleteRow(java.lang.String idField, java.lang.Object idValue)
          Deletes a row from the batch.
 java.lang.String[] getColNames()
          Returns the column names.
 java.lang.String getIdField()
          Returns the idField.
 java.util.Set<java.lang.Object> getIdsToDelete()
          Returns the delete set.
 java.util.Map<java.lang.Object,java.lang.Object> getIdsToInsert()
          Returns the insert map.
 int getSize()
          Returns the current amount of data, in bytes, held in this object.
protected static int sizeOfArray(java.lang.Object[] array)
          Calculates the size of an array, in bytes.
protected static int sizeOfList(java.util.List<java.lang.Object[]> list)
          Calculates the size of a List of arrays, in bytes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TableBatch

public TableBatch()
Constructor for this class. Generates a table batch with no data to write.

Method Detail

addRow

public int addRow(java.lang.Object idValue,
                  java.lang.String[] colNames,
                  java.lang.Object[] values)
Adds a row to the batch. This action depends on any previous information on the given id value. If the id value is currently marked as deleted, then it will change to "delete, then insert". This system allows multiple rows to be inserted for the same id, so there are three insertion modes:

Parameters:
idValue - the value of the ID field for this row, or null if there is no relevant idField
colNames - an array of names of fields that are in the table
values - an array of Objects to be put in the row, in the same order as colNames
Returns:
the number of bytes by which the batch should be deemed to have expanded

deleteRow

public int deleteRow(java.lang.String idField,
                     java.lang.Object idValue)
Deletes a row from the batch. This action depends on any previous information on the given id value:

Parameters:
idField - the name of the field that is the ID
idValue - the value of the ID field for this row
Returns:
the number of bytes by which the batch should be deemed to have expanded

getColNames

public java.lang.String[] getColNames()
Returns the column names.

Returns:
an array of Strings

getIdField

public java.lang.String getIdField()
Returns the idField.

Returns:
a String

getIdsToInsert

public java.util.Map<java.lang.Object,java.lang.Object> getIdsToInsert()
Returns the insert map.

Returns:
a Map

getIdsToDelete

public java.util.Set<java.lang.Object> getIdsToDelete()
Returns the delete set.

Returns:
a Set

clear

public void clear()
Clears the batch.

Specified by:
clear in interface Table

getSize

public int getSize()
Returns the current amount of data, in bytes, held in this object.

Specified by:
getSize in interface Table
Returns:
an int

sizeOfArray

protected static int sizeOfArray(java.lang.Object[] array)
Calculates the size of an array, in bytes.

Parameters:
array - the array
Returns:
an int

sizeOfList

protected static int sizeOfList(java.util.List<java.lang.Object[]> list)
Calculates the size of a List of arrays, in bytes.

Parameters:
list - a List of arrays
Returns:
an int