Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public class TestConstant {
public static final String DATA_TYPE_STR = ColumnHeaderConstant.DATATYPE;
public static final String FUNCTION_TYPE_NATIVE = "native";
public static final double DELTA = 1e-6;
public static final double NULL = Double.MIN_VALUE;
public static final double NULL = Double.NaN;

public static String[] createSql =
new String[] {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2012,7 +2012,7 @@ public void testMasterRepair() {
}

// test 4
double[] r4 = {1704.0, 1702.0, 1702.0, 1701.0, 1703.0, 1704.0, 1705.0, 1706.0};
double[] r4 = {1704.0, 1702.0, 1702.0, 1701.0, 1703.0, 1702.0, 1705.0, 1706.0};
try (ResultSet resultSet =
statement.executeQuery(
"select master_repair(s1,s2,s3,m1,m2,m3,'omega'='2','eta'='3.0','k'='5') from root.testMasterRepair.d1")) {
Expand All @@ -2032,7 +2032,7 @@ public void testMasterRepair() {
}

// test 5
double[] r5 = {1154.55, 1152.30, 1148.65, 1145.20, 1150.55, 1151.55, 1153.55, 1152.30};
double[] r5 = {1154.55, 1152.30, 1148.65, 1145.20, 1150.55, 1152.30, 1153.55, 1152.30};
try (ResultSet resultSet =
statement.executeQuery(
"select master_repair(s1,s2,s3,m1,m2,m3,'omega'='2','eta'='3.0','k'='5','output_column'='2') from root.testMasterRepair.d1")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ public SwingingDoorTrendingFilter(
}

private void init(final long firstTimestamp, final T firstValue) {
upperDoor = Double.MIN_VALUE;
lowerDoor = Double.MAX_VALUE;
upperDoor = Double.NEGATIVE_INFINITY;
lowerDoor = Double.POSITIVE_INFINITY;

lastReadTimestamp = firstTimestamp;
lastReadValue = firstValue;
Expand Down Expand Up @@ -158,8 +158,8 @@ private boolean isTimeDistanceGreaterThanOrEqual(
}

private void reset(final long timestamp, final T value) {
upperDoor = Double.MIN_VALUE;
lowerDoor = Double.MAX_VALUE;
upperDoor = Double.NEGATIVE_INFINITY;
lowerDoor = Double.POSITIVE_INFINITY;

lastStoredTimestamp = timestamp;
lastStoredValue = value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,23 @@ public void testExtremeTimestampDistanceReachesMaxInterval() throws Exception {
Assert.assertTrue(filter.filter(Long.MAX_VALUE, 0));
}

@Test
public void testDecreasingTrendIsCompressed() throws Exception {
final SwingingDoorTrendingFilter<Integer> filter =
new SwingingDoorTrendingFilter<>(createProcessor(0, Long.MAX_VALUE, 0), 0, 10);

Assert.assertFalse(filter.filter(1, 9));
}

@Test
public void testDecreasingTrendIsCompressedAfterReset() throws Exception {
final SwingingDoorTrendingFilter<Integer> filter =
new SwingingDoorTrendingFilter<>(createProcessor(0, 10, 0), 0, 20);

Assert.assertTrue(filter.filter(10, 10));
Assert.assertFalse(filter.filter(11, 9));
}

private SwingingDoorTrendingSamplingProcessor createProcessor(
final long compressionMinTimeInterval,
final long compressionMaxTimeInterval,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,13 +270,13 @@ static ArrayList<ArrayList<Double>> maxMin(ArrayList<ArrayList<Double>> data, in
ArrayList<Double> min_v = new ArrayList<>();
ArrayList<Double> max_v = new ArrayList<>();
for (int i = 0; i < dimensions; i++) {
double min_temp = Double.MAX_VALUE;
double max_temp = Double.MIN_VALUE;
for (int j = 1; j < data.size(); j++) {
ArrayList<Double> d = data.get(j);
double min_temp = Double.POSITIVE_INFINITY;
double max_temp = Double.NEGATIVE_INFINITY;
for (ArrayList<Double> d : data) {
if (d.get(i) < min_temp) {
min_temp = d.get(i);
} else if (d.get(i) > max_temp) {
}
if (d.get(i) > max_temp) {
max_temp = d.get(i);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

package org.apache.iotdb.commons.udf.utils;

import org.junit.Assert;
import org.junit.Test;

import java.util.ArrayList;
import java.util.Arrays;

public class KDTreeUtilTest {

@Test
public void testQueryUsesCompleteNodeBounds() {
ArrayList<ArrayList<Double>> data = new ArrayList<>();
data.add(point(4, 0));
data.add(point(-2, -2));
data.add(point(-5, 5));
data.add(point(1, -1));
data.add(point(-4, 5));
data.add(point(5, -5));
data.add(point(-5, 0));

KDTreeUtil tree = KDTreeUtil.build(data, 2);

Assert.assertEquals(point(5, -5), tree.query(point(0.25, -8.75), new double[] {1, 1}));
}

private ArrayList<Double> point(double first, double second) {
return new ArrayList<>(Arrays.asList(first, second));
}
}
Loading