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

java.lang.Object
  extended by org.knime.core.data.DataCell
      extended by org.knime.core.data.vector.bytevector.SparseByteVectorCell
All Implemented Interfaces:
Serializable, DataValue, ByteVectorValue

public class SparseByteVectorCell
extends DataCell
implements ByteVectorValue

Author:
ohl, University of Konstanz
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.knime.core.data.vector.bytevector.ByteVectorValue
ByteVectorValue.ByteVectorUtilityFactory
 
Nested classes/interfaces inherited from interface org.knime.core.data.DataValue
DataValue.UtilityFactory
 
Field Summary
static DataType TYPE
          Convenience access member for DataType.getType(SparseByteVectorCell.class).
 
Fields inherited from interface org.knime.core.data.vector.bytevector.ByteVectorValue
UTILITY
 
Constructor Summary
SparseByteVectorCell(SparseByteVector byteVector)
          Use the SparseBitVectorCellFactory to create instances of this cell.
 
Method Summary
 int cardinality()
          Returns the number of counts larger than zero stored in this vector.
protected  boolean equalsDataCell(DataCell dc)
          Derived classes implement their specific equals function here.
 int get(long index)
          Returns the count stored at the specified position.
 SparseByteVector getByteVectorCopy()
          Returns a clone of the internal sparse byte vector.
static DataCellSerializer<SparseByteVectorCell> getCellSerializer()
          Returns the factory to read/write DataCells of this class from/to a DataInput/DataOutput.
static Class<? extends DataValue> getPreferredValueClass()
          Returns the preferred value class of this cell implementation.
 int hashCode()
          This method must be implemented in order to ensure that two equal DataCell objects return the same hash code.
 boolean isEmpty()
          Checks all counts and returns true if they are all zero.
 long length()
          Returns the length of the byte vector.
 long nextCountIndex(long startIdx)
          Finds the next count not equal to zero on or after the specified index.
 long nextZeroIndex(long startIdx)
          Finds the next index whose value is zero on or after the specified index.
 long sumOfAllCounts()
          Calculates the checksum, the sum of all counts stored.
 String toString()
          Returns the String representation of this cell's value.
 
Methods inherited from class org.knime.core.data.DataCell
equals, getType, isMissing
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

TYPE

public static final DataType TYPE
Convenience access member for DataType.getType(SparseByteVectorCell.class).

See Also:
DataType.getType(Class)
Constructor Detail

SparseByteVectorCell

SparseByteVectorCell(SparseByteVector byteVector)
Use the SparseBitVectorCellFactory to create instances of this cell.

Parameters:
byteVector - the byte vector a copy of which is stored in this cell.
Method Detail

getPreferredValueClass

public static final Class<? extends DataValue> getPreferredValueClass()
Returns the preferred value class of this cell implementation. This method is called per reflection to determine which is the preferred renderer, comparator, etc.

Returns:
ByteVectorValue.class;

getCellSerializer

public static final DataCellSerializer<SparseByteVectorCell> getCellSerializer()
Returns the factory to read/write DataCells of this class from/to a DataInput/DataOutput. This method is called via reflection.

Returns:
A serializer for reading/writing cells of this kind.
See Also:
DataCell

equalsDataCell

protected boolean equalsDataCell(DataCell dc)
Derived classes implement their specific equals function here. The argument is guaranteed to be not null or a missing value, to be of the same class like this.

Specified by:
equalsDataCell in class DataCell
Parameters:
dc - the cell to compare this to
Returns:
true if this is equal to the argument, false if not

hashCode

public int hashCode()
This method must be implemented in order to ensure that two equal DataCell objects return the same hash code.

Specified by:
hashCode in class DataCell
Returns:
the hash code of your specific DataCell
See Also:
Object.hashCode(), DataCell.equals(java.lang.Object)

toString

public String toString()
Returns the String representation of this cell's value.

Specified by:
toString in class DataCell
Returns:
a String representation of this cell's value

cardinality

public int cardinality()
Returns the number of counts larger than zero stored in this vector.

Specified by:
cardinality in interface ByteVectorValue
Returns:
the number of elements not equal to zero in this vector.

get

public int get(long index)
Returns the count stored at the specified position.

Specified by:
get in interface ByteVectorValue
Parameters:
index - the index of the count to return
Returns:
the count stored at the specified index.

isEmpty

public boolean isEmpty()
Checks all counts and returns true if they are all zero.

Specified by:
isEmpty in interface ByteVectorValue
Returns:
true if all counts are zero.

length

public long length()
Returns the length of the byte vector. The number of stored counts.

Specified by:
length in interface ByteVectorValue
Returns:
the number of bytes stored in the vector

nextCountIndex

public long nextCountIndex(long startIdx)
Finds the next count not equal to zero on or after the specified index. Returns an index larger than or equal to the provided index, or -1 if no count larger than zero exists after the startIdx. It is okay to pass an index larger than the length of the vector.

Specified by:
nextCountIndex in interface ByteVectorValue
Parameters:
startIdx - the first index to look for non-zero counts. (It is allowed to pass an index larger then the vector's length.)
Returns:
the index of the next count larger than zero, which is on or after the provided startIdx, or -1 if there isn't any

nextZeroIndex

public long nextZeroIndex(long startIdx)
Finds the next index whose value is zero on or after the specified index. Returns an index larger than or equal to the provided index, or -1 if no such index exists. It is okay to pass an index larger than the length of the vector.

Specified by:
nextZeroIndex in interface ByteVectorValue
Parameters:
startIdx - the first index to look for zero values.
Returns:
the index of the next index with value zero, which is on or after the provided startIdx. Or -1 if the vector contains no zeros there after.

sumOfAllCounts

public long sumOfAllCounts()
Calculates the checksum, the sum of all counts stored.

Specified by:
sumOfAllCounts in interface ByteVectorValue
Returns:
the sum of all counts in this vector.

getByteVectorCopy

public SparseByteVector getByteVectorCopy()
Returns a clone of the internal sparse byte vector.

Returns:
a copy of the internal sparse byte 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.