diff options
author | Andrej Shadura <andrewsh@debian.org> | 2019-03-09 22:30:28 +0000 |
---|---|---|
committer | Andrej Shadura <andrewsh@debian.org> | 2019-03-09 22:30:28 +0000 |
commit | cde76aeb42240f7270bc6605c606ae07d2dc5a7d (patch) | |
tree | c3ebf1d7745224f524da31dbabc5d76b9ea75916 /src/de/lmu/ifi/dbs/elki/index/tree/metrical/mtreevariants/mktrees/mkapp/MkAppDirectoryEntry.java |
Import Upstream version 0.4.0~beta1
Diffstat (limited to 'src/de/lmu/ifi/dbs/elki/index/tree/metrical/mtreevariants/mktrees/mkapp/MkAppDirectoryEntry.java')
-rw-r--r-- | src/de/lmu/ifi/dbs/elki/index/tree/metrical/mtreevariants/mktrees/mkapp/MkAppDirectoryEntry.java | 130 |
1 files changed, 130 insertions, 0 deletions
diff --git a/src/de/lmu/ifi/dbs/elki/index/tree/metrical/mtreevariants/mktrees/mkapp/MkAppDirectoryEntry.java b/src/de/lmu/ifi/dbs/elki/index/tree/metrical/mtreevariants/mktrees/mkapp/MkAppDirectoryEntry.java new file mode 100644 index 00000000..90d68bcf --- /dev/null +++ b/src/de/lmu/ifi/dbs/elki/index/tree/metrical/mtreevariants/mktrees/mkapp/MkAppDirectoryEntry.java @@ -0,0 +1,130 @@ +package de.lmu.ifi.dbs.elki.index.tree.metrical.mtreevariants.mktrees.mkapp; +/* +This file is part of ELKI: +Environment for Developing KDD-Applications Supported by Index-Structures + +Copyright (C) 2011 +Ludwig-Maximilians-Universität München +Lehr- und Forschungseinheit für Datenbanksysteme +ELKI Development Team + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU Affero General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Affero General Public License for more details. + +You should have received a copy of the GNU Affero General Public License +along with this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +import java.io.IOException; +import java.io.ObjectInput; +import java.io.ObjectOutput; + +import de.lmu.ifi.dbs.elki.database.ids.DBID; +import de.lmu.ifi.dbs.elki.distance.distancevalue.NumberDistance; +import de.lmu.ifi.dbs.elki.index.tree.metrical.mtreevariants.MTreeDirectoryEntry; + +/** + * Represents an entry in a directory node of a MkApp-Tree. Additionally to an + * MTreeDirectoryEntry an MkAppDirectoryEntry holds the polynomial approximation + * of its knn-distances. + * + * @author Elke Achtert + */ +class MkAppDirectoryEntry<D extends NumberDistance<D, ?>> extends MTreeDirectoryEntry<D> implements MkAppEntry<D> { + /** + * Serial version UID + */ + private static final long serialVersionUID = 1; + + /** + * The polynomial approximation. + */ + private PolynomialApproximation approximation; + + /** + * Empty constructor for serialization purposes. + */ + public MkAppDirectoryEntry() { + super(); + } + + /** + * Provides a new MkCoPDirectoryEntry with the given parameters. + * + * @param objectID the id of the routing object + * @param parentDistance the distance from the object to its parent + * @param nodeID the id of the underlying node + * @param coveringRadius the covering radius of the entry + * @param approximation the polynomial approximation of the knn distances + */ + public MkAppDirectoryEntry(DBID objectID, D parentDistance, Integer nodeID, D coveringRadius, PolynomialApproximation approximation) { + super(objectID, parentDistance, nodeID, coveringRadius); + this.approximation = approximation; + } + + /** + * Returns the approximated value at the specified k. + * + * @param k the parameter k of the knn distance + * @return the approximated value at the specified k + */ + @Override + public double approximatedValueAt(int k) { + return approximation.getValueAt(k); + } + + /** + * Returns the polynomial approximation. + * + * @return the polynomial approximation + */ + @Override + public PolynomialApproximation getKnnDistanceApproximation() { + return approximation; + } + + /** + * Sets the polynomial approximation. + * + * @param approximation the polynomial approximation to be set + */ + @Override + public void setKnnDistanceApproximation(PolynomialApproximation approximation) { + this.approximation = approximation; + } + + /** + * Calls the super method and writes the polynomial approximation of the knn + * distances of this entry to the specified stream. + * + * @param out the stream to write the object to + * @throws java.io.IOException Includes any I/O exceptions that may occur + */ + @Override + public void writeExternal(ObjectOutput out) throws IOException { + super.writeExternal(out); + out.writeObject(approximation); + } + + /** + * Calls the super method and reads the the polynomial approximation of the + * knn distances of this entry from the specified input stream. + * + * @param in the stream to read data from in order to restore the object + * @throws java.io.IOException if I/O errors occur + * @throws ClassNotFoundException If the class for an object being restored + * cannot be found. + */ + @Override + public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { + super.readExternal(in); + approximation = (PolynomialApproximation) in.readObject(); + } +} |