1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
|
package de.lmu.ifi.dbs.elki.index.tree.spatial.rstarvariants.deliclu;
/*
This file is part of ELKI:
Environment for Developing KDD-Applications Supported by Index-Structures
Copyright (C) 2012
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 de.lmu.ifi.dbs.elki.index.tree.spatial.rstarvariants.AbstractRStarTreeNode;
/**
* Represents a node in a DeLiClu-Tree.
*
* @author Elke Achtert
*
* @apiviz.has DeLiCluEntry oneway - - contains
*/
public class DeLiCluNode extends AbstractRStarTreeNode<DeLiCluNode, DeLiCluEntry> {
private static final long serialVersionUID = 1;
/**
* Empty constructor for Externalizable interface.
*/
public DeLiCluNode() {
// empty constructor
}
/**
* Creates a new DeLiCluNode with the specified parameters.
*
* @param capacity the capacity (maximum number of entries plus 1 for
* overflow) of this node
* @param isLeaf indicates whether this node is a leaf node
*/
public DeLiCluNode(int capacity, boolean isLeaf) {
super(capacity, isLeaf, DeLiCluEntry.class);
}
/**
* Returns true, if the children of this node (or their child nodes) contain
* handled data objects.
*
* @return true, if the children of this node (or their child nodes) contain
* handled data objects
*/
public boolean hasHandled() {
for(int i = 1; i < getNumEntries(); i++) {
boolean handled = getEntry(i).hasHandled();
if(handled) {
return true;
}
}
return false;
}
/**
* Returns true, if the children of this node (or their child nodes) contain
* unhandled data objects.
*
* @return true, if the children of this node (or their child nodes) contain
* unhandled data objects
*/
public boolean hasUnhandled() {
for(int i = 1; i < getNumEntries(); i++) {
boolean handled = getEntry(i).hasUnhandled();
if(handled) {
return true;
}
}
return false;
}
@Override
public boolean adjustEntry(DeLiCluEntry entry) {
boolean changed = super.adjustEntry(entry);
// adjust hasHandled and hasUnhandled flag
boolean hasHandled = hasHandled();
boolean hasUnhandled = hasUnhandled();
entry.setHasHandled(hasHandled);
entry.setHasUnhandled(hasUnhandled);
return changed;
}
/**
* Tests, if the parameters of the entry representing this node, are correctly
* set. Subclasses may need to overwrite this method.
*
* @param parent the parent holding the entry representing this node
* @param index the index of the entry in the parents child array
*/
@Override
protected void integrityCheckParameters(DeLiCluNode parent, int index) {
super.integrityCheckParameters(parent, index);
// test if hasHandled and hasUnhandled flag are correctly set
DeLiCluEntry entry = parent.getEntry(index);
boolean hasHandled = hasHandled();
boolean hasUnhandled = hasUnhandled();
if(entry.hasHandled() != hasHandled) {
String soll = Boolean.toString(hasHandled);
String ist = Boolean.toString(entry.hasHandled());
throw new RuntimeException("Wrong hasHandled in node " + parent.getPageID() + " at index " + index + " (child " + entry + ")" + "\nsoll: " + soll + ",\n ist: " + ist);
}
if(entry.hasUnhandled() != hasUnhandled) {
String soll = Boolean.toString(hasUnhandled);
String ist = Boolean.toString(entry.hasUnhandled());
throw new RuntimeException("Wrong hasUnhandled in node " + parent.getPageID() + " at index " + index + " (child " + entry + ")" + "\nsoll: " + soll + ",\n ist: " + ist);
}
}
}
|