Interface RowMetaInterface
- All Superinterfaces:
Cloneable
- All Known Implementing Classes:
RowMeta
Inside processRow() a step typically retrieves the structure of incoming rows by calling getInputRowMeta(), which is provided by the BaseStep class. The step would usually clone this object and pass it to getFields() of its meta class, to reflect any changes in row structure caused by the step itself. Now the step has RowMetaInterface objects describing both the input and output rows.
Usually a step would look for the indexes and types of relevant fields upon first execution of processRow(). The following methods of RowMetaInterface are particularly useful in that regard:
public int indexOfValue(...)
Given a field name, determine the index of the field in the row.
public String[] getFieldNames()
Returns an array of field names. The index of a field name matches the field index in the row array.
public void searchValueMeta(String valueName)
Given a field name, determine the meta data for the field.
public vValueMetaInterface getValueMeta(...)
Given a field index, determine the meta data for the field.
public List
Returns a list of all field descriptions. The index of the field description matches the field index in the row
array.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addRowMeta
(RowMetaInterface rowMeta) Add a number of fields from another row (append to the end).void
addValueMeta
(int index, ValueMetaInterface meta) Add a metadata value on a certain location in the row.void
Add a metadata value, extends the array if needed.void
clear()
Clear the row metadata.clone()
Clone this RowMetaInterface object.Object[]
Clone row.Object[]
Clone row.cloneToType
(int targetType) This method copies the row metadata and sets all values to the specified type (usually String)int
Compare 2 rows with each other using all values in the rows and also considering the specified ascending clauses of the value metadata.int
Compare 2 rows with each other using certain values in the rows and also considering the specified ascending clauses of the value metadata.int
Compare 2 rows with each other using certain values in the rows and also considering the specified ascending clauses of the value metadata.int
compare
(Object[] rowData1, RowMetaInterface rowMeta2, Object[] rowData2, int[] fieldnrs1, int[] fieldnrs2) Compare 2 rows with each other using certain values in the rows and also considering the specified ascending clauses of the value metadata.int
convertedValuesHashCode
(Object[] rowData) Calculates a hashcode of the converted value of all objects in the supplied row.boolean
Compare 2 rows with each other for equality using certain values in the rows and also considering the case sensitivity flag.boolean
exists
(ValueMetaInterface meta) Check if a value is already present in this row with the same name.getBigNumber
(Object[] dataRow, int index) Get a BigNumber value from a row of data.byte[]
Get a Binary value from a row of data.getBoolean
(Object[] dataRow, int index) Get a Boolean value from a row of data.getDataXML
(Object[] rowData) Gets the data xml.Get a Date value from a row of data.Gets the date.String[]
Get an array of the names of all the Values in the Row.String[]
getFieldNamesAndTypes
(int maxlen) Get an array of strings showing the name of the values in the row padded to a maximum length, followed by the types of the values.getInteger
(Object[] dataRow, int index) Get an Integer value from a row of data.getInteger
(Object[] dataRow, String valueName, Long defaultValue) Gets the integer.Gets the meta xml.Get a Number value from a row of data.Object[]
Convert an XML node into binary data using the row metadata supplied.Get the string representation of the data in a row of data.Get a String value from a row of data.Gets the string.getValueMeta
(int index) Get the value metadata on the specified index.Gets the value meta list.int
Calculates a simple hashCode of all the native data objects in the supplied row.int
indexOfValue
(String valueName) Searches the index of a value meta with a given name.boolean
isEmpty()
Returns true if there are no elements in the row metadata.boolean
Determines whether a value in a row is null.void
Deprecated.void
mergeRowMeta
(RowMetaInterface r, String originStepName) Merge the values of row r to this Row.int
oldXORHashCode
(Object[] rowData) Deprecated.Object[]
readData
(DataInputStream inputStream) De-serialize a row of data (no metadata is read) from an input stream.void
removeValueMeta
(int index) Remove a value metadata object on a certain index in the row.void
removeValueMeta
(String string) Remove a value with a certain name from the row metadata.searchValueMeta
(String valueName) Searches for a value with a certain name in the value meta list.void
setValueMeta
(int index, ValueMetaInterface valueMeta) Replaces a value meta entry in the row metadata with another one.void
setValueMetaList
(List<ValueMetaInterface> valueMetaList) Sets the value meta list.int
size()
Returns the size of the metadata row.To string meta.void
writeData
(DataOutputStream outputStream, Object[] data) Write a serialized version of the supplied data to the outputStream (based on the metadata but not the metadata itself).void
writeMeta
(DataOutputStream outputStream) Write a serialized version of this class (Row Metadata) to the specified outputStream.
-
Method Details
-
getValueMetaList
List<ValueMetaInterface> getValueMetaList()Gets the value meta list.- Returns:
- the list of value Metadata
-
setValueMetaList
Sets the value meta list.- Parameters:
valueMetaList
- the list of valueMeta to set
-
exists
Check if a value is already present in this row with the same name.- Parameters:
meta
- the value to check for existence- Returns:
- true if a value with the same name already exists in the row
-
addValueMeta
Add a metadata value, extends the array if needed. If a value with the same name already exists, it gets renamed.- Parameters:
meta
- The metadata value to add
-
addValueMeta
Add a metadata value on a certain location in the row. If a value with the same name already exists, it gets renamed. Remember to change the data row according to this.- Parameters:
index
- The index where the metadata value needs to be put in the rowmeta
- The metadata value to add to the row
-
getValueMeta
Get the value metadata on the specified index.- Parameters:
index
- The index to get the value metadata from- Returns:
- The value metadata specified by the index.
-
setValueMeta
Replaces a value meta entry in the row metadata with another one.- Parameters:
index
- The index in the row to replace atvalueMeta
- the metadata to replace with
-
getString
Get a String value from a row of data. Convert data if this needed.- Parameters:
dataRow
- the data rowindex
- the index- Returns:
- The string found on that position in the row
- Throws:
KettleValueException
- in case there was a problem converting the data.
-
getInteger
Get an Integer value from a row of data. Convert data if this needed.- Parameters:
dataRow
- the data rowindex
- the index- Returns:
- The integer found on that position in the row
- Throws:
KettleValueException
- in case there was a problem converting the data.
-
getNumber
Get a Number value from a row of data. Convert data if this needed.- Parameters:
dataRow
- the data rowindex
- the index- Returns:
- The number found on that position in the row
- Throws:
KettleValueException
- in case there was a problem converting the data.
-
getDate
Get a Date value from a row of data. Convert data if this needed.- Parameters:
dataRow
- the data rowindex
- the index- Returns:
- The date found on that position in the row
- Throws:
KettleValueException
- in case there was a problem converting the data.
-
getBigNumber
Get a BigNumber value from a row of data. Convert data if this needed.- Parameters:
dataRow
- the data rowindex
- the index- Returns:
- The bignumber found on that position in the row
- Throws:
KettleValueException
- in case there was a problem converting the data.
-
getBoolean
Get a Boolean value from a row of data. Convert data if this needed.- Parameters:
dataRow
- the data rowindex
- the index- Returns:
- The boolean found on that position in the row
- Throws:
KettleValueException
- in case there was a problem converting the data.
-
getBinary
Get a Binary value from a row of data. Convert data if this needed.- Parameters:
dataRow
- the data rowindex
- the index- Returns:
- The binary found on that position in the row
- Throws:
KettleValueException
- in case there was a problem converting the data.
-
cloneRow
Clone row.- Parameters:
objects
- objects to clonecloneTo
- objects to clone to- Returns:
- a cloned Object[] object.
- Throws:
KettleValueException
- in case something is not quite right with the expected data
-
cloneRow
Clone row.- Parameters:
objects
- object to clone- Returns:
- a cloned objects to clone to
- Throws:
KettleValueException
- in case something is not quite right with the expected data
-
size
int size()Returns the size of the metadata row.- Returns:
- the size of the metadata row
-
isEmpty
boolean isEmpty()Returns true if there are no elements in the row metadata.- Returns:
- true if there are no elements in the row metadata
-
isNull
Determines whether a value in a row is null. A value is null when the object is null. As such, you can just as good write dataRow[index]==null in your code.- Parameters:
dataRow
- The row of dataindex
- the index to reference- Returns:
- true if the value on the index is null.
- Throws:
KettleValueException
- in case there is a conversion error (only thrown in case of lazy conversion)
-
clone
RowMetaInterface clone()Clone this RowMetaInterface object.- Returns:
- a copy of this RowMetaInterface object
-
cloneToType
This method copies the row metadata and sets all values to the specified type (usually String)- Parameters:
targetType
- The target type- Returns:
- The cloned metadata
- Throws:
KettleValueException
-
getString
String getString(Object[] dataRow, String valueName, String defaultValue) throws KettleValueException Gets the string.- Parameters:
dataRow
- the data rowvalueName
- the value namedefaultValue
- the default value- Returns:
- the string
- Throws:
KettleValueException
- the kettle value exception
-
getInteger
Gets the integer.- Parameters:
dataRow
- the data rowvalueName
- the value namedefaultValue
- the default value- Returns:
- the integer
- Throws:
KettleValueException
- the kettle value exception
-
getDate
Gets the date.- Parameters:
dataRow
- the data rowvalueName
- the value namedefaultValue
- the default value- Returns:
- the date
- Throws:
KettleValueException
- the kettle value exception
-
searchValueMeta
Searches for a value with a certain name in the value meta list.- Parameters:
valueName
- The value name to search for- Returns:
- The value metadata or null if nothing was found
-
indexOfValue
Searches the index of a value meta with a given name.- Parameters:
valueName
- the name of the value metadata to look for- Returns:
- the index or -1 in case we didn't find the value
-
addRowMeta
Add a number of fields from another row (append to the end).- Parameters:
rowMeta
- The row of metadata values to add
-
mergeRowMeta
Deprecated.Merge the values of row r to this Row. The values that are not yet in the row are added unchanged. The values that are in the row are renamed to name[2], name[3], etc.- Parameters:
r
- The row to be merged with this row
-
mergeRowMeta
Merge the values of row r to this Row. The values that are not yet in the row are added unchanged. The values that are in the row are renamed to name[2], name[3], etc.- Parameters:
r
- The row to be merged with this row
-
getFieldNames
String[] getFieldNames()Get an array of the names of all the Values in the Row.- Returns:
- an array of Strings: the names of all the Values in the Row.
-
writeMeta
Write a serialized version of this class (Row Metadata) to the specified outputStream.- Parameters:
outputStream
- the outputstream to write to- Throws:
KettleFileException
- in case a I/O error occurs
-
writeData
Write a serialized version of the supplied data to the outputStream (based on the metadata but not the metadata itself).- Parameters:
outputStream
- the outputstream to write todata
- the data to write after the metadata- Throws:
KettleFileException
- in case a I/O error occurs
-
readData
De-serialize a row of data (no metadata is read) from an input stream.- Parameters:
inputStream
- the inputstream to read from- Returns:
- a new row of data
- Throws:
KettleFileException
- in case a I/O error occursSocketTimeoutException
- In case there is a timeout during reading.
-
clear
void clear()Clear the row metadata. -
removeValueMeta
Remove a value with a certain name from the row metadata.- Parameters:
string
- the name of the value metadata to remove- Throws:
KettleValueException
- in case the value couldn't be found in the row metadata
-
removeValueMeta
void removeValueMeta(int index) Remove a value metadata object on a certain index in the row.- Parameters:
index
- the index to remove the value metadata from
-
getString
Get the string representation of the data in a row of data.- Parameters:
row
- the row of data to convert to string- Returns:
- the row of data in string form
- Throws:
KettleValueException
- in case of a conversion error
-
getFieldNamesAndTypes
Get an array of strings showing the name of the values in the row padded to a maximum length, followed by the types of the values.- Parameters:
maxlen
- The length to which the name will be padded.- Returns:
- an array of strings: the names and the types of the fieldnames in the row.
-
compare
Compare 2 rows with each other using certain values in the rows and also considering the specified ascending clauses of the value metadata.- Parameters:
rowData1
- The first row of datarowData2
- The second row of datafieldnrs
- the fields to compare on (in that order)- Returns:
- 0 if the rows are considered equal, -1 is data1 is smaller, 1 if data2 is smaller.
- Throws:
KettleValueException
- the kettle value exception
-
equals
Compare 2 rows with each other for equality using certain values in the rows and also considering the case sensitivity flag.- Parameters:
rowData1
- The first row of datarowData2
- The second row of datafieldnrs
- the fields to compare on (in that order)- Returns:
- true if the rows are considered equal, false if they are not.
- Throws:
KettleValueException
- the kettle value exception
-
compare
int compare(Object[] rowData1, Object[] rowData2, int[] fieldnrs1, int[] fieldnrs2) throws KettleValueException Compare 2 rows with each other using certain values in the rows and also considering the specified ascending clauses of the value metadata.- Parameters:
rowData1
- The first row of datarowData2
- The second row of datafieldnrs1
- The indexes of the values to compare in the first rowfieldnrs2
- The indexes of the values to compare with in the second row- Returns:
- 0 if the rows are considered equal, -1 is data1 is smaller, 1 if data2 is smaller.
- Throws:
KettleValueException
- the kettle value exception
-
compare
int compare(Object[] rowData1, RowMetaInterface rowMeta2, Object[] rowData2, int[] fieldnrs1, int[] fieldnrs2) throws KettleValueException Compare 2 rows with each other using certain values in the rows and also considering the specified ascending clauses of the value metadata.- Parameters:
rowData1
- The first row of datarowMeta2
- the metadat of the second row of datarowData2
- The second row of datafieldnrs1
- The indexes of the values to compare in the first rowfieldnrs2
- The indexes of the values to compare with in the second row- Returns:
- 0 if the rows are considered equal, -1 is data1 is smaller, 1 if data2 is smaller.
- Throws:
KettleValueException
- the kettle value exception
-
compare
Compare 2 rows with each other using all values in the rows and also considering the specified ascending clauses of the value metadata.- Parameters:
rowData1
- The first row of datarowData2
- The second row of data- Returns:
- 0 if the rows are considered equal, -1 is data1 is smaller, 1 if data2 is smaller.
- Throws:
KettleValueException
- the kettle value exception
-
oldXORHashCode
Deprecated.Calculate a hashCode of the content (not the index) of the data specified NOTE: This method uses a simple XOR of the individual hashCodes which can result in a lot of collisions for similar types of data (e.g. [A,B] == [B,A] and is not suitable for normal use. It is kept to provide backward compatibility with CombinationLookup.lookupValues()- Parameters:
rowData
- The data to calculate a hashCode with- Returns:
- the calculated hashCode
- Throws:
KettleValueException
- in case there is a data conversion error
-
hashCode
Calculates a simple hashCode of all the native data objects in the supplied row. This method will return a better distribution of values for rows of numbers or rows with the same values in different positions. NOTE: This method performs against the native values, not the values returned by ValueMeta. This means that if you have two rows with different primitive values ['2008-01-01:12:30'] and ['2008-01-01:00:00'] that use a format object to change the value (as Date yyyy-MM-dd), the hashCodes will be different resulting in the two rows not being considered equal via the hashCode even though compare() or equals() might consider them to be.- Parameters:
rowData
- The data to calculate a hashCode with- Returns:
- the calculated hashCode
- Throws:
KettleValueException
- in case there is a data conversion error
-
convertedValuesHashCode
Calculates a hashcode of the converted value of all objects in the supplied row. This method returns distinct values for nulls of different data types and will return the same hashCode for different native values that have a ValueMeta converting them into the same value (e.g. ['2008-01-01:12:30'] and ['2008-01-01:00:00'] as Date yyyy-MM-dd)- Parameters:
rowData
- The data to calculate a hashCode with- Returns:
- the calculated hashCode
- Throws:
KettleValueException
- in case there is a data conversion error
-
toStringMeta
String toStringMeta()To string meta.- Returns:
- a string with a description of all the metadata values of the complete row of metadata
-
getMetaXML
Gets the meta xml.- Returns:
- an XML representation of the row metadata
- Throws:
IOException
- Thrown in case there is an (Base64/GZip) encoding problem
-
getDataXML
Gets the data xml.- Parameters:
rowData
- the row of data to serialize as XML- Returns:
- an XML representation of the row data
- Throws:
IOException
- Thrown in case there is an (Base64/GZip) encoding problem
-
getRow
Convert an XML node into binary data using the row metadata supplied.- Parameters:
node
- The data row node- Returns:
- a row of data de-serialized from XML
- Throws:
KettleException
- Thrown in case there is an (Base64/GZip) decoding problem
-