diff options
author | Erich Schubert <erich@debian.org> | 2013-10-29 20:02:37 +0100 |
---|---|---|
committer | Andrej Shadura <andrewsh@debian.org> | 2019-03-09 22:30:37 +0000 |
commit | ec7f409f6e795bbcc6f3c005687954e9475c600c (patch) | |
tree | fbf36c0ab791c556198b487ca40ae56ae5ab1ee5 /src/de/lmu/ifi/dbs/elki/index/tree/metrical/mtreevariants/mktrees/mkapp/MkAppTreeIndex.java | |
parent | 974d4cf6d54cadc06258039f2cd0515cc34aeac6 (diff) | |
parent | 8300861dc4c62c5567a4e654976072f854217544 (diff) |
Import Debian changes 0.6.0~beta2-1
elki (0.6.0~beta2-1) unstable; urgency=low
* New upstream beta release.
* 3DPC extension is not yet included.
Diffstat (limited to 'src/de/lmu/ifi/dbs/elki/index/tree/metrical/mtreevariants/mktrees/mkapp/MkAppTreeIndex.java')
-rw-r--r-- | src/de/lmu/ifi/dbs/elki/index/tree/metrical/mtreevariants/mktrees/mkapp/MkAppTreeIndex.java | 111 |
1 files changed, 35 insertions, 76 deletions
diff --git a/src/de/lmu/ifi/dbs/elki/index/tree/metrical/mtreevariants/mktrees/mkapp/MkAppTreeIndex.java b/src/de/lmu/ifi/dbs/elki/index/tree/metrical/mtreevariants/mktrees/mkapp/MkAppTreeIndex.java index 9776de63..2a630bf0 100644 --- a/src/de/lmu/ifi/dbs/elki/index/tree/metrical/mtreevariants/mktrees/mkapp/MkAppTreeIndex.java +++ b/src/de/lmu/ifi/dbs/elki/index/tree/metrical/mtreevariants/mktrees/mkapp/MkAppTreeIndex.java @@ -4,7 +4,7 @@ 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) 2012 + Copyright (C) 2013 Ludwig-Maximilians-Universität München Lehr- und Forschungseinheit für Datenbanksysteme ELKI Development Team @@ -28,9 +28,7 @@ import java.util.List; import de.lmu.ifi.dbs.elki.database.ids.DBID; import de.lmu.ifi.dbs.elki.database.ids.DBIDIter; -import de.lmu.ifi.dbs.elki.database.ids.DBIDRef; import de.lmu.ifi.dbs.elki.database.ids.DBIDUtil; -import de.lmu.ifi.dbs.elki.database.ids.DBIDs; import de.lmu.ifi.dbs.elki.database.query.DatabaseQuery; import de.lmu.ifi.dbs.elki.database.query.distance.DistanceQuery; import de.lmu.ifi.dbs.elki.database.query.knn.KNNQuery; @@ -43,12 +41,9 @@ import de.lmu.ifi.dbs.elki.distance.distancevalue.NumberDistance; import de.lmu.ifi.dbs.elki.index.KNNIndex; import de.lmu.ifi.dbs.elki.index.RKNNIndex; import de.lmu.ifi.dbs.elki.index.RangeIndex; -import de.lmu.ifi.dbs.elki.index.tree.metrical.mtreevariants.AbstractMTree; -import de.lmu.ifi.dbs.elki.index.tree.metrical.mtreevariants.mktrees.AbstractMkTree; import de.lmu.ifi.dbs.elki.index.tree.metrical.mtreevariants.query.MTreeQueryUtil; import de.lmu.ifi.dbs.elki.index.tree.metrical.mtreevariants.query.MkTreeRKNNQuery; import de.lmu.ifi.dbs.elki.persistent.PageFile; -import de.lmu.ifi.dbs.elki.utilities.exceptions.ExceptionMessages; /** * MkAppTree used as database index. @@ -69,16 +64,11 @@ public class MkAppTreeIndex<O, D extends NumberDistance<D, ?>> extends MkAppTree * * @param relation Relation to index * @param pageFile Page file - * @param distanceQuery Distance query - * @param distanceFunction Distance function - * @param k_max Maximum value of k supported - * @param p Parameter p - * @param log Logspace flag + * @param settings Tree settings */ - public MkAppTreeIndex(Relation<O> relation, PageFile<MkAppTreeNode<O, D>> pageFile, DistanceQuery<O, D> distanceQuery, DistanceFunction<O, D> distanceFunction, int k_max, int p, boolean log) { - super(pageFile, distanceQuery, distanceFunction, k_max, p, log); + public MkAppTreeIndex(Relation<O> relation, PageFile<MkAppTreeNode<O, D>> pageFile, MkAppTreeSettings<O, D> settings) { + super(relation, pageFile, settings); this.relation = relation; - this.initialize(); } /** @@ -89,119 +79,88 @@ public class MkAppTreeIndex<O, D extends NumberDistance<D, ?>> extends MkAppTree * @param parentDistance the distance from the object to the routing object of * the parent node */ - protected MkAppEntry<D> createNewLeafEntry(DBID id, O object, D parentDistance) { - return new MkAppLeafEntry<D>(id, parentDistance, null); + protected MkAppEntry createNewLeafEntry(DBID id, O object, double parentDistance) { + return new MkAppLeafEntry(id, parentDistance, null); } @Override - public void insert(DBIDRef id) { - throw new UnsupportedOperationException("Insertion of single objects is not supported!"); - } - - @Override - public void insertAll(DBIDs ids) { - List<MkAppEntry<D>> objs = new ArrayList<MkAppEntry<D>>(ids.size()); - for (DBIDIter iter = ids.iter(); iter.valid(); iter.advance()) { + public void initialize() { + super.initialize(); + List<MkAppEntry> objs = new ArrayList<>(relation.size()); + for (DBIDIter iter = relation.iterDBIDs(); iter.valid(); iter.advance()) { DBID id = DBIDUtil.deref(iter); final O object = relation.get(id); - objs.add(createNewLeafEntry(id, object, getDistanceFactory().undefinedDistance())); + objs.add(createNewLeafEntry(id, object, Double.NaN)); } insertAll(objs); } - /** - * Throws an UnsupportedOperationException since deletion of objects is not - * yet supported by an M-Tree. - * - * @throws UnsupportedOperationException thrown, since deletions aren't - * implemented yet. - */ - @Override - public final boolean delete(DBIDRef id) { - throw new UnsupportedOperationException(ExceptionMessages.UNSUPPORTED_NOT_YET); - } - - /** - * Throws an UnsupportedOperationException since deletion of objects is not - * yet supported by an M-Tree. - * - * @throws UnsupportedOperationException thrown, since deletions aren't - * implemented yet. - */ - @Override - public void deleteAll(DBIDs ids) { - throw new UnsupportedOperationException(ExceptionMessages.UNSUPPORTED_NOT_YET); - } - @SuppressWarnings("unchecked") @Override public <S extends Distance<S>> KNNQuery<O, S> getKNNQuery(DistanceQuery<O, S> distanceQuery, Object... hints) { // Query on the relation we index - if(distanceQuery.getRelation() != relation) { + if (distanceQuery.getRelation() != relation) { return null; } - DistanceFunction<? super O, S> distanceFunction = distanceQuery.getDistanceFunction(); - if(!this.distanceFunction.equals(distanceFunction)) { - if(getLogger().isDebugging()) { + DistanceFunction<? super O, D> distanceFunction = (DistanceFunction<? super O, D>) distanceQuery.getDistanceFunction(); + if (!this.getDistanceFunction().equals(distanceFunction)) { + if (getLogger().isDebugging()) { getLogger().debug("Distance function not supported by index - or 'equals' not implemented right!"); } return null; } // Bulk is not yet supported - for(Object hint : hints) { - if(hint == DatabaseQuery.HINT_BULK) { + for (Object hint : hints) { + if (hint == DatabaseQuery.HINT_BULK) { return null; } } - AbstractMTree<O, S, ?, ?> idx = (AbstractMTree<O, S, ?, ?>) this; - DistanceQuery<O, S> dq = distanceFunction.instantiate(relation); - return MTreeQueryUtil.getKNNQuery(idx, dq, hints); + DistanceQuery<O, D> dq = distanceFunction.instantiate(relation); + return (KNNQuery<O, S>) MTreeQueryUtil.getKNNQuery(this, dq, hints); } @SuppressWarnings("unchecked") @Override public <S extends Distance<S>> RangeQuery<O, S> getRangeQuery(DistanceQuery<O, S> distanceQuery, Object... hints) { // Query on the relation we index - if(distanceQuery.getRelation() != relation) { + if (distanceQuery.getRelation() != relation) { return null; } - DistanceFunction<? super O, S> distanceFunction = distanceQuery.getDistanceFunction(); - if(!this.distanceFunction.equals(distanceFunction)) { - if(getLogger().isDebugging()) { + DistanceFunction<? super O, D> distanceFunction = (DistanceFunction<? super O, D>) distanceQuery.getDistanceFunction(); + if (!this.getDistanceFunction().equals(distanceFunction)) { + if (getLogger().isDebugging()) { getLogger().debug("Distance function not supported by index - or 'equals' not implemented right!"); } return null; } // Bulk is not yet supported - for(Object hint : hints) { - if(hint == DatabaseQuery.HINT_BULK) { + for (Object hint : hints) { + if (hint == DatabaseQuery.HINT_BULK) { return null; } } - AbstractMTree<O, S, ?, ?> idx = (AbstractMTree<O, S, ?, ?>) this; - DistanceQuery<O, S> dq = distanceFunction.instantiate(relation); - return MTreeQueryUtil.getRangeQuery(idx, dq, hints); + DistanceQuery<O, D> dq = distanceFunction.instantiate(relation); + return (RangeQuery<O, S>) MTreeQueryUtil.getRangeQuery(this, dq, hints); } @SuppressWarnings("unchecked") @Override public <S extends Distance<S>> RKNNQuery<O, S> getRKNNQuery(DistanceQuery<O, S> distanceQuery, Object... hints) { - DistanceFunction<? super O, S> distanceFunction = distanceQuery.getDistanceFunction(); - if(!this.getDistanceFunction().equals(distanceFunction)) { - if(getLogger().isDebugging()) { + DistanceFunction<? super O, D> distanceFunction = (DistanceFunction<? super O, D>) distanceQuery.getDistanceFunction(); + if (!this.getDistanceFunction().equals(distanceFunction)) { + if (getLogger().isDebugging()) { getLogger().debug("Distance function not supported by index - or 'equals' not implemented right!"); } return null; } // Bulk is not yet supported - for(Object hint : hints) { - if(hint == DatabaseQuery.HINT_BULK) { + for (Object hint : hints) { + if (hint == DatabaseQuery.HINT_BULK) { return null; } } - AbstractMkTree<O, S, ?, ?> idx = (AbstractMkTree<O, S, ?, ?>) this; - DistanceQuery<O, S> dq = distanceFunction.instantiate(relation); - return new MkTreeRKNNQuery<O, S>(idx, dq); + DistanceQuery<O, D> dq = distanceFunction.instantiate(relation); + return (RKNNQuery<O, S>) new MkTreeRKNNQuery<>(this, dq); } @Override @@ -213,4 +172,4 @@ public class MkAppTreeIndex<O, D extends NumberDistance<D, ?>> extends MkAppTree public String getShortName() { return "mkapptree"; } -}
\ No newline at end of file +} |