public class MetaObjectArray extends MetaObject implements BinarySerializable
MetaObject
that stores a fixed array of encapsulated objects.
The metric distance function for this object is the absolute value of the
differences of locatorURI hash codes. For a more sophisticated distance function
use MetaObjectArrayWeightedSum
.
Note that the encapsulated object names are automatically generated by
getObjectName(int)
method. Normally, this method is overloaded
in a subclass to provide more appropriate names.
LocalAbstractObject.DataEqualObject, LocalAbstractObject.TextStreamFactory<T extends LocalAbstractObject>, LocalAbstractObject.TrivialDistanceFunction
Modifier and Type | Field and Description |
---|---|
protected LocalAbstractObject[] |
objects
List of objects
|
counterDistanceComputations, counterLowerBoundDistanceComputations, counterPrecomputedDistanceSavings, counterUpperBoundDistanceComputations, MAX_DISTANCE, MIN_DISTANCE, suppData, trivialDistanceFunction, UNKNOWN_DISTANCE
Modifier | Constructor and Description |
---|---|
|
MetaObjectArray(AbstractObjectKey objectKey,
LocalAbstractObject... objects)
Creates a new instance of MetaObjectArray.
|
protected |
MetaObjectArray(BinaryInput input,
BinarySerializator serializator)
Creates a new instance of MetaObjectFixed loaded from binary input.
|
|
MetaObjectArray(java.io.BufferedReader stream)
Creates a new instance of MetaObjectArray from the given text stream with array header.
|
|
MetaObjectArray(java.io.BufferedReader stream,
boolean readEmptyClassLine,
java.lang.Class<? extends LocalAbstractObject>[] classes)
Creates a new instance of MetaObjectArray from the given text stream.
|
|
MetaObjectArray(java.io.BufferedReader stream,
java.lang.Class<? extends LocalAbstractObject> objectClass)
Creates a new instance of MetaObjectArray from the given text stream with array header.
|
|
MetaObjectArray(java.io.BufferedReader stream,
java.lang.Class<? extends LocalAbstractObject>[] classes)
Creates a new instance of MetaObjectArray from the given text stream.
|
|
MetaObjectArray(java.io.BufferedReader stream,
int objectCount,
java.lang.Class<? extends LocalAbstractObject> objectClass)
Creates a new instance of MetaObjectArray from the given text stream.
|
|
MetaObjectArray(java.io.BufferedReader stream,
java.lang.String[] objectNames)
Creates a new instance of MetaObjectArray from the given text stream with header.
|
|
MetaObjectArray(LocalAbstractObject... objects)
Creates a new instance of MetaObjectArray.
|
|
MetaObjectArray(java.lang.String locatorURI,
java.util.Collection<? extends LocalAbstractObject> objects)
Creates a new instance of MetaObjectArray that takes the objects from the given collection.
|
|
MetaObjectArray(java.lang.String locatorURI,
LocalAbstractObject... objects)
Creates a new instance of MetaObjectArray.
|
|
MetaObjectArray(java.lang.String locatorURI,
java.util.Map<java.lang.String,? extends LocalAbstractObject> objects,
java.lang.String... objectNames)
Creates a new instance of MetaObjectArray that takes the objects from the given map.
|
|
MetaObjectArray(java.lang.String locatorURI,
MetaObject object,
java.lang.String... objectNames)
Creates a new instance of MetaObjectArray that takes the objects from the given
MetaObject . |
Modifier and Type | Method and Description |
---|---|
int |
binarySerialize(BinaryOutput output,
BinarySerializator serializator)
Binary-serialize this object into the
output . |
protected static java.lang.Class<? extends LocalAbstractObject>[] |
createClassArray(int count,
java.lang.Class<? extends LocalAbstractObject> clazz)
Creates an array of
count clazz elements. |
int |
getBinarySize(BinarySerializator serializator)
Returns the exact size of the binary-serialized version of this object in bytes.
|
protected float |
getDistanceImpl(LocalAbstractObject obj,
float[] metaDistances,
float distThreshold)
The actual implementation of the metric function.
|
LocalAbstractObject |
getObject(int index)
Returns the encapsulated object for given index.
|
LocalAbstractObject |
getObject(java.lang.String name)
Returns the encapsulated object for given symbolic name.
|
int |
getObjectCount()
Returns the number of encapsulated objects.
|
java.util.Map<java.lang.String,? extends LocalAbstractObject> |
getObjectMap()
Returns a collection of all the encapsulated objects associated with their symbolic names.
|
protected java.lang.String |
getObjectName(int index)
Returns the name of the fixed object with the given
index . |
java.util.Collection<java.lang.String> |
getObjectNames()
Returns a set of symbolic names of the encapsulated objects.
|
java.util.Collection<? extends LocalAbstractObject> |
getObjects()
Returns a collection of all the encapsulated objects.
|
protected static LocalAbstractObject[] |
readObjects(java.io.BufferedReader stream,
boolean readEmptyClassLine,
java.lang.Class<? extends LocalAbstractObject>[] classes)
Utility method for reading objects from a text stream.
|
protected void |
writeData(java.io.OutputStream stream)
Store this object's data to a text stream.
|
clearSurplusData, containsObject, createMetaDistancesHolder, createSearchMetaObject, dataEquals, dataHashCode, fillMetaDistances, fillMetaDistances, getDistanceImpl, getObjectFromMap, getSize, implementationGetDistance, readObject, readObject, readObjects, readObjects, readObjectsHeader, toString, writeObjects, writeObjectsHeader
clone, clone, cloneRandomlyModify, create, create, excludeUsingPrecompDist, getDistance, getDistance, getDistance, getDistanceFilter, getDistanceFilter, getDistanceFilter, getDistanceFilter, 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
protected final LocalAbstractObject[] objects
public MetaObjectArray(LocalAbstractObject... objects)
objects
- the encapsulated list of objectspublic MetaObjectArray(AbstractObjectKey objectKey, LocalAbstractObject... objects)
objectKey
- the key to be associated with this objectobjects
- the encapsulated list of objectspublic MetaObjectArray(java.lang.String locatorURI, LocalAbstractObject... objects)
AbstractObjectKey
is generated for
the specified locatorURI
.locatorURI
- the locator URI for the new objectobjects
- the encapsulated list of objectspublic MetaObjectArray(java.lang.String locatorURI, java.util.Collection<? extends LocalAbstractObject> objects)
AbstractObjectKey
is
generated for the specified locatorURI
.locatorURI
- the locator URI for the new objectobjects
- the collection with objects to encapsulatepublic MetaObjectArray(java.lang.String locatorURI, MetaObject object, java.lang.String... objectNames)
MetaObject
.
The array is initialized with objects from the MetaObject
in the order they
appear in the objectNames
array. Note that if the object of a given
name is not in the MetaObject
, null is inserted into the array.
A new unique object ID is generated and a new AbstractObjectKey
is
generated for the specified locatorURI
.locatorURI
- the locator URI for the new objectobject
- the MetaObject
with objects to encapsulateobjectNames
- the names of the objects to take from the given objects
mappublic MetaObjectArray(java.lang.String locatorURI, java.util.Map<java.lang.String,? extends LocalAbstractObject> objects, java.lang.String... objectNames)
objectNames
array. Note that if the object of a given
name is not in the map, null is inserted into the array.
A new unique object ID is generated and a new AbstractObjectKey
is
generated for the specified locatorURI
.locatorURI
- the locator URI for the new objectobjects
- the map with named objects to encapsulateobjectNames
- the names of the objects to take from the given objects
mappublic MetaObjectArray(java.io.BufferedReader stream, java.lang.Class<? extends LocalAbstractObject>[] classes) throws java.io.IOException
stream
- the text stream to read the objects fromclasses
- the classes of the objects to read from the streamjava.io.IOException
- when an error appears during reading from given stream,
EOFException is returned if end of the given stream is reached.public MetaObjectArray(java.io.BufferedReader stream, boolean readEmptyClassLine, java.lang.Class<? extends LocalAbstractObject>[] classes) throws java.io.IOException
stream
- the text stream to read the objects fromreadEmptyClassLine
- flag whether to read a single line (that is ignored)
for a null class inside the classes array
classes
- the classes of the objects to read from the streamjava.io.IOException
- when an error appears during reading from given stream,
EOFException is returned if end of the given stream is reached.public MetaObjectArray(java.io.BufferedReader stream, int objectCount, java.lang.Class<? extends LocalAbstractObject> objectClass) throws java.io.IOException
stream
- the text stream to read the objects fromobjectCount
- number of objects to readobjectClass
- the class of objects to read from the streamjava.io.IOException
- when an error appears during reading from given stream,
EOFException is returned if end of the given stream is reached.public MetaObjectArray(java.io.BufferedReader stream, java.lang.Class<? extends LocalAbstractObject> objectClass) throws java.io.IOException
stream
- the text stream to read the objects fromobjectClass
- if not null value provided, it will override the object class
in the header (note that this will be used only if read homogenous objects is true)java.io.IOException
- when an error appears during reading from given stream,
EOFException is returned if end of the given stream is reached.public MetaObjectArray(java.io.BufferedReader stream) throws java.io.IOException
stream
- the text stream to read the objects fromjava.io.IOException
- when an error appears during reading from given stream,
EOFException is returned if end of the given stream is reached.public MetaObjectArray(java.io.BufferedReader stream, java.lang.String[] objectNames) throws java.io.IOException
stream
- the text stream to read the objects fromobjectNames
- the names of the objects to load (according to the header);
if this parameter is null, all objects are taken using the order in the datafilejava.io.IOException
- when an error appears during reading from given stream,
EOFException is returned if end of the given stream is reached.MetaObject.readObjectsHeader(java.io.BufferedReader)
protected MetaObjectArray(BinaryInput input, BinarySerializator serializator) throws java.io.IOException
input
- the input to read the MetaObject fromserializator
- the serializator used to write objectsjava.io.IOException
- if there was an I/O error reading from the bufferprotected java.lang.String getObjectName(int index)
index
.
By default, this implementation returns "ObjectX" where X is the given
index
. However, this method should be overridden to give
the real name of the object if appropriate (e.g. from a static array of names).index
- the fixed index of the object the name of which to getindex
th objectpublic int getObjectCount()
MetaObject
getObjectCount
in class MetaObject
public LocalAbstractObject getObject(java.lang.String name)
MetaObject
getObject
in class MetaObject
name
- the symbolic name of the object to returnpublic LocalAbstractObject getObject(int index) throws java.lang.IndexOutOfBoundsException
index
- the index of the object to returnjava.lang.IndexOutOfBoundsException
- if the given index is not within [0;count
) intervalpublic java.util.Collection<java.lang.String> getObjectNames()
MetaObject
getObjectNames
in class MetaObject
public java.util.Collection<? extends LocalAbstractObject> getObjects()
MetaObject
getObjects
in class MetaObject
public java.util.Map<java.lang.String,? extends LocalAbstractObject> getObjectMap()
MetaObject
getObjectMap
in class MetaObject
protected static java.lang.Class<? extends LocalAbstractObject>[] createClassArray(int count, java.lang.Class<? extends LocalAbstractObject> clazz)
count
clazz
elements.count
- the number of array elements to createclazz
- the class to fill the array withcount
clazz
elementsprotected static LocalAbstractObject[] readObjects(java.io.BufferedReader stream, boolean readEmptyClassLine, java.lang.Class<? extends LocalAbstractObject>[] classes) throws java.io.IOException
BufferedReader
constructor.
Note that for each null item of the classes
array
a null is stored in the returned array without reading anything
from the stream
.
stream
- the text stream to read the objects fromreadEmptyClassLine
- flag whether to read a single line (that is ignored)
for a null class inside the classes array
classes
- the classes of the objects to read from the streamjava.io.IOException
- when an error appears during reading from given stream,
EOFException is returned if end of the given stream is reached.protected 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 streamprotected float getDistanceImpl(LocalAbstractObject obj, float[] metaDistances, float distThreshold)
obj
.
The array metaDistances
is ignored.getDistanceImpl
in class MetaObject
obj
- the object to compute distance tometaDistances
- the array that is filled with the distances of the respective encapsulated objects, if it is not nulldistThreshold
- the threshold value on the distanceLocalAbstractObject.getDistance
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