public abstract class ObjectByteVector extends LocalAbstractObject implements ObjectVector<java.lang.Byte>, BinarySerializable
ObjectByteVectorL1
.LocalAbstractObject.DataEqualObject, LocalAbstractObject.TextStreamFactory<T extends LocalAbstractObject>, LocalAbstractObject.TrivialDistanceFunction
Modifier and Type | Field and Description |
---|---|
protected byte[] |
data
Data array
|
counterDistanceComputations, counterLowerBoundDistanceComputations, counterPrecomputedDistanceSavings, counterUpperBoundDistanceComputations, MAX_DISTANCE, MIN_DISTANCE, suppData, trivialDistanceFunction, UNKNOWN_DISTANCE
Modifier | Constructor and Description |
---|---|
protected |
ObjectByteVector(BinaryInput input,
BinarySerializator serializator)
Creates a new instance of ObjectByteVector loaded from binary input buffer.
|
|
ObjectByteVector(java.io.BufferedReader stream)
Creates a new instance of ObjectByteVector from text stream.
|
|
ObjectByteVector(java.io.BufferedReader stream,
boolean asHexString)
Creates a new instance of ObjectByteVector from text stream.
|
|
ObjectByteVector(byte[] data)
Creates a new instance of ObjectByteVector.
|
|
ObjectByteVector(int dimension)
Creates a new instance of ObjectByteVector with randomly generated content data.
|
|
ObjectByteVector(int dimension,
byte min,
byte max)
Creates a new instance of ObjectByteVector with randomly generated content data.
|
Modifier and Type | Method and Description |
---|---|
int |
binarySerialize(BinaryOutput output,
BinarySerializator serializator)
Binary-serialize this object into the
output . |
LocalAbstractObject |
cloneRandomlyModify(java.lang.Object... args)
Creates and returns a randomly modified copy of this vector.
|
boolean |
dataEquals(java.lang.Object obj)
Indicates whether some other object has the same data as this one.
|
int |
dataHashCode()
Returns a hash code value for the data of this object.
|
int |
getBinarySize(BinarySerializator serializator)
Returns the exact size of the binary-serialized version of this object in bytes.
|
int |
getDimensionality()
Returns the number of dimensions of this vector.
|
static byte[][] |
getMinMaxForEveryCoord(AbstractObjectIterator<? extends ObjectByteVector> iterator)
Computes minimum and maximum values over every coordinate of vectors in the collection's
iterator.
|
static byte[] |
getMinMaxOverCoords(AbstractObjectIterator<? extends ObjectByteVector> iterator)
Computes minimum and maximum values over all coordinates of vectors in the collection's
iterator.
|
protected byte[] |
getMinMaxOverCoords(byte[] currRange)
Computes minimum and maximum values over all coordinates of the current vector.
|
int |
getSize()
Returns the size of this object in bytes.
|
byte[] |
getVectorData()
Returns the vector of byte integer values, which represents the contents of this object.
|
int |
getVectorDataDimension()
Number of dimensions of the vector data.
|
java.lang.Byte |
getVectorDataItem(int index)
Access to a single datum of vector data at the given zero-based index.
|
byte |
getVectorDataItemByte(int index) |
static byte[] |
parseByteHexString(java.lang.String line)
Parses a vector of bytes encoded using hexadecimal character encoding from the given line of text.
|
static byte[] |
parseByteVector(java.lang.String line)
Parses a vector of byte integers from the given line of text.
|
static byte[] |
randomData(int dimension,
byte min,
byte max)
Generate an array of random byte integers using normal distribution of numbers
from interval [min;max).
|
java.lang.String |
toString()
Converts this object to a string representation.
|
static void |
writeByteHexString(byte[] data,
java.io.OutputStream stream)
Writes the given vector of byte integers to the given output stream using hexadecimal character encoding.
|
static void |
writeByteVector(byte[] data,
java.io.OutputStream stream,
char separator,
char finalSeparator)
Writes the given vector of byte integers to the given output stream as text.
|
protected void |
writeData(java.io.OutputStream stream)
Store this object's data to a text stream.
|
clearSurplusData, clone, clone, create, create, createMetaDistancesHolder, excludeUsingPrecompDist, getDistance, getDistance, getDistance, getDistanceFilter, getDistanceFilter, getDistanceFilter, getDistanceFilter, getDistanceImpl, getDistanceLowerBound, getDistanceLowerBoundImpl, getDistanceStorePrecomputed, getDistanceStorePrecomputed, getDistanceStorePrecomputed, getDistanceUpperBound, getDistanceUpperBoundImpl, getFieldsForNames, getMaxDistance, getNormDistance, getPrecomputedDistance, getPrecomputedDistance, getRandomChar, getRandomNormal, chainDestroy, chainFilter, includeUsingPrecompDist, isDistanceCompatible, parseObjectComment, peekNextChar, readAttributesFromStream, readObjectComments, readObjectCommentsWithoutData, unchainFilter, write, write, writeAttributesToStream, writeObjectComment
clone, getLocatorURI, getNoDataObject, getObjectKey, getObjectKey, getObjectLocatorURI, setObjectKey
public ObjectByteVector(byte[] data)
data
- the data content of the new objectpublic ObjectByteVector(int dimension)
dimension
- number of dimensions to generatepublic ObjectByteVector(int dimension, byte min, byte max)
dimension
- number of dimensions to generatemin
- lower bound of the random generated values (inclusive)max
- upper bound of the random generated values (exclusive)public ObjectByteVector(java.io.BufferedReader stream, boolean asHexString) throws java.io.EOFException, java.io.IOException, java.lang.NumberFormatException
stream
- the stream from which to read lines of textasHexString
- if true, the data are read from a string of hexadecimal characters,
if false, the data should be comma (or space) separated integer numbers from 0 to 255java.io.EOFException
- if the end-of-file of the given stream is reachedjava.io.IOException
- if there was an I/O error during reading from the streamjava.lang.NumberFormatException
- if a line read from the stream does not consist of comma-separated or space-separated numberspublic ObjectByteVector(java.io.BufferedReader stream) throws java.io.EOFException, java.io.IOException, java.lang.NumberFormatException
stream
- the stream from which to read lines of textjava.io.EOFException
- if the end-of-file of the given stream is reachedjava.io.IOException
- if there was an I/O error during reading from the streamjava.lang.NumberFormatException
- if a line read from the stream does not consist of comma-separated or space-separated numbersprotected ObjectByteVector(BinaryInput input, BinarySerializator serializator) throws java.io.IOException
input
- the buffer to read the ObjectByteVector fromserializator
- the serializator used to write objectsjava.io.IOException
- if there was an I/O error reading from the bufferpublic static byte[] parseByteVector(java.lang.String line) throws java.lang.NumberFormatException, java.io.EOFException
line
- the text from which to parse vectorjava.lang.NumberFormatException
- if the given line
does not have comma-separated or space-separated integersjava.io.EOFException
- if a null line
is givenpublic static byte[] parseByteHexString(java.lang.String line) throws java.lang.NumberFormatException, java.io.EOFException
line
- the text from which to parse vectorjava.lang.NumberFormatException
- if the given line
contains an invalid hexadecimal characterjava.io.EOFException
- if a null line
is givenpublic static void writeByteVector(byte[] data, java.io.OutputStream stream, char separator, char finalSeparator) throws java.io.IOException
data
- the vector of byte integers to outputstream
- the output stream to write the text toseparator
- the char written between the vector numbersfinalSeparator
- the char written at the end of the vectorjava.io.IOException
- if there was an I/O error while writing to the streampublic static void writeByteHexString(byte[] data, java.io.OutputStream stream) throws java.io.IOException
data
- the vector of byte integers to outputstream
- the output stream to write the text tojava.io.IOException
- if there was an I/O error while writing to the streamprotected void writeData(java.io.OutputStream stream) throws java.io.IOException
LocalAbstractObject
writeData
in class LocalAbstractObject
stream
- the stream to store this object tojava.io.IOException
- if there was an error while writing to streampublic static byte[] randomData(int dimension, byte min, byte max)
dimension
- number of dimensions to generatemin
- lower bound of the random generated values (inclusive)max
- upper bound of the random generated values (exclusive)public boolean dataEquals(java.lang.Object obj)
LocalAbstractObject
dataEquals
in class LocalAbstractObject
obj
- the reference object with which to compare.true
if this object is the same as the obj
argument; false
otherwise.public int dataHashCode()
LocalAbstractObject
dataHashCode
in class LocalAbstractObject
public java.lang.Byte getVectorDataItem(int index)
ObjectVector
getVectorDataItem
in interface ObjectVector<java.lang.Byte>
index
- zero-base index of the datum to returnpublic int getVectorDataDimension()
ObjectVector
getVectorDataDimension
in interface ObjectVector<java.lang.Byte>
public byte getVectorDataItemByte(int index)
public byte[] getVectorData()
public int getSize()
LocalAbstractObject
getSize
in class LocalAbstractObject
public int getDimensionality()
protected byte[] getMinMaxOverCoords(byte[] currRange)
currRange
- An optional parameter containing current minimum and maximum values. If null is passed
a new range with minimum and maximum is created, otherwise the passed array is updated.public static byte[] getMinMaxOverCoords(AbstractObjectIterator<? extends ObjectByteVector> iterator)
iterator
- Iterator of a collection containing vectors to process.public static byte[][] getMinMaxForEveryCoord(AbstractObjectIterator<? extends ObjectByteVector> iterator)
iterator
- Iterator of a collection containing vectors to process.public LocalAbstractObject cloneRandomlyModify(java.lang.Object... args) throws java.lang.CloneNotSupportedException, java.lang.IllegalArgumentException
cloneRandomlyModify
in class LocalAbstractObject
args
- expected size of the array is 2: minVector vector with minimal values in all positions
maxVector vector with maximal values in all positionsjava.lang.IllegalArgumentException
- if the passed arguments are not two ObjectByteVector
sjava.lang.CloneNotSupportedException
- if the object's class does not support cloning or there was an errorpublic java.lang.String toString()
super.toString()
is appended.toString
in class AbstractObject
public int binarySerialize(BinaryOutput output, BinarySerializator serializator) throws java.io.IOException
LocalAbstractObject
output
.binarySerialize
in interface BinarySerializable
binarySerialize
in class LocalAbstractObject
output
- the output that this object is binary-serialized intoserializator
- the serializator used to write objectsjava.io.IOException
- if there was an I/O error during serializationpublic int getBinarySize(BinarySerializator serializator)
LocalAbstractObject
getBinarySize
in interface BinarySerializable
getBinarySize
in class LocalAbstractObject
serializator
- the serializator used to write objects