org.knime.core.data.vector.bytevector
Class DenseByteVectorCellFactory

java.lang.Object
  extended by org.knime.core.data.vector.bytevector.DenseByteVectorCellFactory

public class DenseByteVectorCellFactory
extends Object

Used to created DataCells holding a DenseByteVector. As data cells are read only this factory can be used to initialize the byte vector accordingly and then create a data cell from it.
This factory also provides methods for performing basic operations (min(ByteVectorValue, ByteVectorValue), max(ByteVectorValue, ByteVectorValue), etc.) on two data cells holding byte vectors.

Author:
ohl, University of Konstanz

Constructor Summary
DenseByteVectorCellFactory(DenseByteVector vector)
          A copy of the specified vector is stored in the created byte vector cell.
DenseByteVectorCellFactory(DenseByteVectorCell cell, int startIdx, int endIdx)
          Initializes the vector from a subsequence of the specified cell.
DenseByteVectorCellFactory(int length)
          Initializes the factory to the specified length, all counts set to zero.
 
Method Summary
 void concatenate(DenseByteVectorCell bvCell)
          Appends the argument at the end of the vector currently stored in the factory.
 DenseByteVectorCell createDataCell()
          Creates a DataCell from the currently stored byte vector.
 void insert(DenseByteVectorCell bvCell)
          Inserts the bytes at the lower positions of the current vector.
static DenseByteVectorCell max(ByteVectorValue bv1, ByteVectorValue bv2)
          Creates a dense byte vector cell containing the result of the max operation on the passed operands (that is each position holds the maximum of the values of the operands).
static DenseByteVectorCell min(ByteVectorValue bv1, ByteVectorValue bv2)
          Creates a dense byte vector cell containing the result of the min operation on the passed operands (that is each position holds the minimum of the values of the operands).
 void set(int byteIndex, byte byteVal)
          Sets the new count value at the specified index.
static DenseByteVectorCell sum(ByteVectorValue bv1, ByteVectorValue bv2)
          Creates a dense byte vector cell containing the sum of the passed operands (that is each position holds the sum of the values of the operands).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DenseByteVectorCellFactory

public DenseByteVectorCellFactory(int length)
Initializes the factory to the specified length, all counts set to zero.

Parameters:
length - the length of the count vector

DenseByteVectorCellFactory

public DenseByteVectorCellFactory(DenseByteVector vector)
A copy of the specified vector is stored in the created byte vector cell.

Parameters:
vector - used to initialize the counts.

DenseByteVectorCellFactory

public DenseByteVectorCellFactory(DenseByteVectorCell cell,
                                  int startIdx,
                                  int endIdx)
Initializes the vector from a subsequence of the specified cell. The bytes used are the ones from startIdx to endIdx - 1. The length of the resulting vector is startIdx - endIdx.

Parameters:
cell - the byte vector cell to take the subsequence from.
startIdx - the first byte to include in the created bit vector
endIdx - the first byte NOT to include in the result vector
Method Detail

concatenate

public void concatenate(DenseByteVectorCell bvCell)
Appends the argument at the end of the vector currently stored in the factory. The new length is the sum of the current and the argument vector. The bytes of the argument are inserted at the highest positions, beyond the current vector's length.

Parameters:
bvCell - the data cell containing the vector to concatenate with this.

insert

public void insert(DenseByteVectorCell bvCell)
Inserts the bytes at the lower positions of the current vector. The bytes currently stored are shifted to higher positions. The new length is the sum of the current and the argument vector.

Parameters:
bvCell - the data cell containing the vector to insert into this

set

public void set(int byteIndex,
                byte byteVal)
Sets the new count value at the specified index.

Parameters:
byteIndex - the index of the count value to change.
byteVal - the new value for the specified position.
Throws:
ArrayIndexOutOfBoundsException - if the index is negative or larger than or equal to the length of the vector.
IllegalArgumentException - if the count is negative or larger than 255

min

public static DenseByteVectorCell min(ByteVectorValue bv1,
                                      ByteVectorValue bv2)
Creates a dense byte vector cell containing the result of the min operation on the passed operands (that is each position holds the minimum of the values of the operands). The length of the result vector is the maximum of the lengths of the operands.
NOTE: This method performs best, if the two arguments are both DenseByteVectorCells. All other implementations need to access the byte counts through get/set methods and will probably perform poorly.
See also SparseByteVectorCellFactory.min(ByteVectorValue, ByteVectorValue) for calculating the minimum on sparce byte vector cells.

Parameters:
bv1 - the first operand to build the minimum with the second
bv2 - the second operand to build the minimum with the first one
Returns:
the result of the min operation

max

public static DenseByteVectorCell max(ByteVectorValue bv1,
                                      ByteVectorValue bv2)
Creates a dense byte vector cell containing the result of the max operation on the passed operands (that is each position holds the maximum of the values of the operands). The length of the result vector is the maximum of the length of the operands.
NOTE: This method performs best, if the two arguments are both DenseByteVectorCells. All other implementations need to access the byte counts through get/set methods and will probably perform poorly.
See also SparseByteVectorCellFactory.max(ByteVectorValue, ByteVectorValue) for calculating the maximum on sparce byte vector cells.

Parameters:
bv1 - the first operand to build the maximum with the second
bv2 - the second operand to build the maximum with the first one
Returns:
the result of the max operation

sum

public static DenseByteVectorCell sum(ByteVectorValue bv1,
                                      ByteVectorValue bv2)
Creates a dense byte vector cell containing the sum of the passed operands (that is each position holds the sum of the values of the operands). The length of the result vector is the maximum of the length of the operands. If the sum of both counts is larger than the maximum count (i.e. 255) the result is set to this maximum count (255)
NOTE: This method performs best, if the two arguments are both DenseByteVectorCells. All other implementations need to access the byte counts through get/set methods and will probably perform poorly.
See also SparseByteVectorCellFactory.sum(ByteVectorValue, ByteVectorValue) for calculating the sum on sparce byte vector cells.

Parameters:
bv1 - the first operand to build the sum with the second
bv2 - the second operand to build the sum with the first one
Returns:
the result of the add operation

createDataCell

public DenseByteVectorCell createDataCell()
Creates a DataCell from the currently stored byte vector.

Returns:
a DataCell containing the current value of the vector


Copyright, 2003 - 2010. All rights reserved.
University of Konstanz, Germany.
Chair for Bioinformatics and Information Mining, Prof. Dr. Michael R. Berthold.
You may not modify, publish, transmit, transfer or sell, reproduce, create derivative works from, distribute, perform, display, or in any way exploit any of the content, in whole or in part, except as otherwise expressly permitted in writing by the copyright owner or as specified in the license file distributed with this product.