Skip to content

Founding a bug about Mtree #2

@zongleiZhang

Description

@zongleiZhang

DistanceFunction used by Mtree in this project returns a double-precision number. However, double-precision numbers will lose precision when calculated, which will cause some bugs. For example, some index items will not be deleted, as shown below.

public static void main(String[] args) throws Exception {
MTree tree = new MTree<>(4, Point::distancePoint, null);
Queue queue = new LinkedList<>();
File f = new File("test.txt");
BufferedReader br = new BufferedReader(new FileReader(f));
String line;
int count = 0;
while ((line = br.readLine()) != null){
String[] split = line.split("\t");
TrackPoint point = new TrackPoint(new double[]{Double.parseDouble(split[1]), Double.parseDouble(split[2])},
Long.parseLong(split[3]),
Integer.parseInt(split[0]));
tree.insert(point);
queue.add(point);
count++;
if (count % 40 == 0){
if (count > 20000){
for (int i = 0; i < 40; i++) {
TrackPoint trackPoint = queue.remove();
if (count == 36480 && i == 17)
tree.search(trackPoint, 1.0);
if (!tree.delete(trackPoint))
System.out.print("");

			}

		}
	}
}

}

class TrackPoint {
public double[] data;
public long timestamp;
public int TID;

public TrackPoint(double[] data, long timestamp, int TID) {
	super(data);
	this.timestamp = timestamp;
	this.TID = TID;
}

}

test.txt

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions