Package org.pentaho.di.core.row
Class RowDataUtil
java.lang.Object
org.pentaho.di.core.row.RowDataUtil
This class of static methods can be used to manipulate rows: add, delete, resize, etc... That way, when we want to go
for a metadata driven system with hiding deletes, over sized arrays etc, we can change these methods to find
occurrences.
For example, a step adding a field to the row should always call
public static Object[] resizeArray(Object[] objects, int newSize)which will either physically resize the array or return the original row, in case it was over-allocated and has enough slots. If a step needs to create new rows from scratch, it should use allocateRowData() which will return a somewhat over-allocated object array to fit the desired number of fields.
- Author:
- Matt
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic Object[]
addRowData
(Object[] one, int sourceLength, Object[] two) Add two arrays and make one new one.static Object[]
addValueData
(Object[] rowData, int length, Object extra) Add a single value to a row of datastatic Object[]
allocateRowData
(int size) Allocate a new Object array.static Object[]
createResizedCopy
(Object[][] objects, int[] lengths) This method concatenates data from an array of rows, each with their own specific length.static Object[]
createResizedCopy
(Object[] objects, int newSize) Resize an object array making it bigger, over allocate, always create a copy of the original array, even if there's enough room in the old one.static Object[]
removeItem
(Object[] objects, int index) Remove an item from an Object array.static Object[]
removeItems
(Object[] rowData, int[] index) Remove a number of items in a row of data.static Object[]
resizeArray
(Object[] objects, int newSize) Resize an object array making it bigger, over allocate, return the original array if there's enough room.
-
Field Details
-
OVER_ALLOCATE_SIZE
public static int OVER_ALLOCATE_SIZE
-
-
Constructor Details
-
RowDataUtil
public RowDataUtil()
-
-
Method Details
-
allocateRowData
Allocate a new Object array. However, over allocate by a constant factor to make adding values faster.- Parameters:
size
- the minimum size to allocate.- Returns:
- the newly allocated object array
-
resizeArray
Resize an object array making it bigger, over allocate, return the original array if there's enough room.- Parameters:
objects
-newSize
-- Returns:
- A new object array, resized.
-
createResizedCopy
Resize an object array making it bigger, over allocate, always create a copy of the original array, even if there's enough room in the old one.- Parameters:
objects
- the original rownewSize
- the new size- Returns:
- A new object array, resized.
-
createResizedCopy
This method concatenates data from an array of rows, each with their own specific length.- Parameters:
objects
-lengths
-- Returns:
- The concatenated array of objects.
-
removeItem
Remove an item from an Object array. This is a slow operation, later we want to just flag this object and discard it at the next resize. The question is of-course if it makes that much of a difference in the end.- Parameters:
objects
-index
-- Returns:
-
addRowData
Add two arrays and make one new one.- Parameters:
one
- The first arraythe
- length of the row data or of it's longer, the location of the new extra value in the returned data rowtwo
- The second array- Returns:
- a new Array containing all elements from one and two after one another
-
addValueData
Add a single value to a row of data- Parameters:
rowData
- The original row of datathe
- length of the row data or of it's longer, the location of the new extra value in the returned data rowextra
- The extra value to add- Returns:
- a new Array containing all elements, including the extra one
-
removeItems
Remove a number of items in a row of data.- Parameters:
rowData
- the row of data to remove fromindex
- the index of all the items in the source table to remove. We don't check if the same index gets deleted twice!
-