Package org.intermine.sql.writebatch
Class TableBatch
- java.lang.Object
-
- org.intermine.sql.writebatch.TableBatch
-
-
Constructor Summary
Constructors Constructor Description TableBatch()
Constructor for this class.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description 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.
-
-
-
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:- If there is no insertion data, then the row is inserted straight
- If there is only one insertion entry, it is converted into a List containing two entries
- If there is a List, then the new entry is added to it
- Parameters:
idValue
- the value of the ID field for this row, or null if there is no relevant idFieldcolNames
- an array of names of fields that are in the tablevalues
- 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:- If there is no previous information, a row is added to the list of rows to delete
- If there is only an entry for deletion, nothing happens
- If there is only an entry for insertion, that entry is removed, and an entry created for deletion
- If there is both an entry for insertion and deletion, the insertion entry is removed
- Parameters:
idField
- the name of the field that is the IDidValue
- 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
-
getSize
public int getSize()
Returns the current amount of data, in bytes, held in this object.
-
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
-
-