This is an automated email from the ASF dual-hosted git repository. leirui pushed a commit to branch research/LTS-visualization in repository https://gitbox.apache.org/repos/asf/iotdb.git
commit 9f8b0a375549a7e84ade6819418463c3b02acfb5 Author: Lei Rui <[email protected]> AuthorDate: Wed Oct 2 03:52:23 2024 +0800 add --- .../resources/conf/iotdb-engine.properties | 2 +- .../groupby/GroupByWithoutValueFilterDataSet.java | 3 + .../groupby/LocalGroupByExecutorTri_DWT.java | 159 +++++++++++++++++++++ .../org/apache/iotdb/db/query/simpiece/DFT.java | 18 ++- .../org/apache/iotdb/db/query/simpiece/DWT.java | 18 ++- .../db/query/simpiece/MySample_JWaveTest.java | 77 ++++++++++ .../iotdb/db/query/simpiece/SamplingTest.java | 50 ------- .../iotdb/db/query/simpiece/TimeSeriesReader.java | 46 ++++++ .../jwave/transforms/DiscreteFourierTransform.java | 20 +-- .../jwave/transforms/wavelets/Wavelet.java | 60 ++++---- .../wavelets/biorthogonal/BiOrthogonal.java | 13 +- 11 files changed, 370 insertions(+), 96 deletions(-) diff --git a/server/src/assembly/resources/conf/iotdb-engine.properties b/server/src/assembly/resources/conf/iotdb-engine.properties index 696856331b7..b88b4557743 100644 --- a/server/src/assembly/resources/conf/iotdb-engine.properties +++ b/server/src/assembly/resources/conf/iotdb-engine.properties @@ -19,7 +19,7 @@ #################### ### enable Tri #################### -# MinMax, MinMaxLTTB, M4, LTTB, ILTS, SimPiece, SC, FSW, Uniform, Visval +# MinMax, MinMaxLTTB, M4, LTTB, ILTS, SimPiece, SC, FSW, Uniform, DWT, Visval enable_Tri="" # segment error threshold for SimPiece, SC, FSW diff --git a/server/src/main/java/org/apache/iotdb/db/query/dataset/groupby/GroupByWithoutValueFilterDataSet.java b/server/src/main/java/org/apache/iotdb/db/query/dataset/groupby/GroupByWithoutValueFilterDataSet.java index b2d9e0d7473..0b4e54f8293 100644 --- a/server/src/main/java/org/apache/iotdb/db/query/dataset/groupby/GroupByWithoutValueFilterDataSet.java +++ b/server/src/main/java/org/apache/iotdb/db/query/dataset/groupby/GroupByWithoutValueFilterDataSet.java @@ -476,6 +476,9 @@ public class GroupByWithoutValueFilterDataSet extends GroupByEngineDataSet { } else if (CONFIG.getEnableTri().equals("Uniform")) { return new LocalGroupByExecutorTri_Uniform( path, allSensors, dataType, context, timeFilter, fileFilter, ascending); + } else if (CONFIG.getEnableTri().equals("DWT")) { + return new LocalGroupByExecutorTri_DWT( + path, allSensors, dataType, context, timeFilter, fileFilter, ascending); } else if (CONFIG.getEnableTri().equals("Visval")) { return new LocalGroupByExecutorTri_Visval( path, allSensors, dataType, context, timeFilter, fileFilter, ascending); diff --git a/server/src/main/java/org/apache/iotdb/db/query/dataset/groupby/LocalGroupByExecutorTri_DWT.java b/server/src/main/java/org/apache/iotdb/db/query/dataset/groupby/LocalGroupByExecutorTri_DWT.java new file mode 100644 index 00000000000..55cc695b8d2 --- /dev/null +++ b/server/src/main/java/org/apache/iotdb/db/query/dataset/groupby/LocalGroupByExecutorTri_DWT.java @@ -0,0 +1,159 @@ +/* + * 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.db.query.dataset.groupby; + +import org.apache.iotdb.db.conf.IoTDBConfig; +import org.apache.iotdb.db.conf.IoTDBDescriptor; +import org.apache.iotdb.db.engine.querycontext.QueryDataSource; +import org.apache.iotdb.db.exception.StorageEngineException; +import org.apache.iotdb.db.exception.query.QueryProcessException; +import org.apache.iotdb.db.metadata.PartialPath; +import org.apache.iotdb.db.query.aggregation.AggregateResult; +import org.apache.iotdb.db.query.aggregation.impl.MinValueAggrResult; +import org.apache.iotdb.db.query.context.QueryContext; +import org.apache.iotdb.db.query.control.QueryResourceManager; +import org.apache.iotdb.db.query.filter.TsFileFilter; +import org.apache.iotdb.db.query.reader.series.SeriesReader; +import org.apache.iotdb.db.query.simpiece.DWT; +import org.apache.iotdb.db.query.simpiece.Point; +import org.apache.iotdb.db.query.simpiece.TimeSeriesReader; +import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType; +import org.apache.iotdb.tsfile.file.metadata.statistics.MinMaxInfo; +import org.apache.iotdb.tsfile.read.common.ChunkSuit4Tri; +import org.apache.iotdb.tsfile.read.filter.GroupByFilter; +import org.apache.iotdb.tsfile.read.filter.basic.Filter; +import org.apache.iotdb.tsfile.utils.Pair; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.Comparator; +import java.util.List; +import java.util.Set; + +public class LocalGroupByExecutorTri_DWT implements GroupByExecutor { + + private static final IoTDBConfig CONFIG = IoTDBDescriptor.getInstance().getConfig(); + + // Aggregate result buffer of this path + private final List<AggregateResult> results = new ArrayList<>(); + + double[] timeSeries; + + double threshold = CONFIG.getEpsilon(); + + public LocalGroupByExecutorTri_DWT( + PartialPath path, + Set<String> allSensors, + TSDataType dataType, + QueryContext context, + Filter timeFilter, + TsFileFilter fileFilter, + boolean ascending) + throws StorageEngineException, QueryProcessException { + // long start = System.nanoTime(); + + // get all data sources + QueryDataSource queryDataSource = + QueryResourceManager.getInstance().getQueryDataSource(path, context, timeFilter); + + // update filter by TTL + // this.timeFilter = queryDataSource.updateFilterUsingTTL(timeFilter); + + SeriesReader seriesReader = + new SeriesReader( + path, + allSensors, + // fix bug: here use the aggregation type as the series data type, + // not using pageReader.getAllSatisfiedPageData is ok + dataType, + context, + queryDataSource, + timeFilter, + null, + fileFilter, + ascending); + + try { + // : this might be bad to load all chunk metadata at first + List<ChunkSuit4Tri> futureChunkList = new ArrayList<>(); + futureChunkList.addAll(seriesReader.getAllChunkMetadatas4Tri()); + // order futureChunkList by chunk startTime + futureChunkList.sort( + new Comparator<ChunkSuit4Tri>() { + public int compare(ChunkSuit4Tri o1, ChunkSuit4Tri o2) { + return ((Comparable) (o1.chunkMetadata.getStartTime())) + .compareTo(o2.chunkMetadata.getStartTime()); + } + }); + + GroupByFilter groupByFilter = (GroupByFilter) timeFilter; + long startTime = groupByFilter.getStartTime(); + long endTime = groupByFilter.getEndTime(); + + timeSeries = TimeSeriesReader.getTimeSeriesFromTsFilesDR(futureChunkList, startTime, endTime); + + } catch (IOException e) { + throw new QueryProcessException(e.getMessage()); + } + } + + @Override + public void addAggregateResult(AggregateResult aggrResult) { + results.add(aggrResult); + } + + @Override + public List<AggregateResult> calcResult( + long curStartTime, long curEndTime, long startTime, long endTime, long interval) + throws IOException { + // group by curStartTime and curEndTime are not used in Sim-Piece segmentation + + StringBuilder series = new StringBuilder(); + + // clear result cache + for (AggregateResult result : results) { + result.reset(); + } + + List<Point> reducedPoints = DWT.reducePoints(timeSeries, threshold); + + for (Point p : reducedPoints) { + series.append(p.getValue()).append("[").append(p.getTimestamp()).append("]").append(","); + } + + MinValueAggrResult minValueAggrResult = (MinValueAggrResult) results.get(0); + minValueAggrResult.updateResult(new MinMaxInfo<>(series.toString(), 0)); + + timeSeries = null; + return results; + } + + @Override + public Pair<Long, Object> peekNextNotNullValue(long nextStartTime, long nextEndTime) + throws IOException { + throw new IOException("no implemented"); + } + + @Override + public List<AggregateResult> calcResult(long curStartTime, long curEndTime) + throws IOException, QueryProcessException { + throw new IOException("no implemented"); + } +} diff --git a/server/src/main/java/org/apache/iotdb/db/query/simpiece/DFT.java b/server/src/main/java/org/apache/iotdb/db/query/simpiece/DFT.java index f6f6021125d..7ff6af6975c 100644 --- a/server/src/main/java/org/apache/iotdb/db/query/simpiece/DFT.java +++ b/server/src/main/java/org/apache/iotdb/db/query/simpiece/DFT.java @@ -19,17 +19,25 @@ package org.apache.iotdb.db.query.simpiece; +import org.apache.iotdb.db.query.simpiece.jwave.Transform; +import org.apache.iotdb.db.query.simpiece.jwave.TransformBuilder; + import java.util.ArrayList; import java.util.List; public class DFT { - public static List<Point> reducePoints(List<Point> points, double threshold) { - int length = points.size(); - - List<Point> result = new ArrayList<>(); - // IOMonitor2.DCP_D_getAllSatisfiedPageData_traversedPointNum++; + public static List<Point> reducePoints(double[] values, double threshold) { + Transform transform = TransformBuilder.create("Discrete Fourier Transform", "Haar"); + double[] arrHilb = transform.forward(values); + List<Point> result = new ArrayList<>(); + int n = arrHilb.length; + for (int i = 0; i < n; i++) { + if (Math.abs(arrHilb[i]) >= threshold) { + result.add(new Point(i, arrHilb[i])); + } + } return result; } } diff --git a/server/src/main/java/org/apache/iotdb/db/query/simpiece/DWT.java b/server/src/main/java/org/apache/iotdb/db/query/simpiece/DWT.java index bd6e8e9f2a2..9c50376892c 100644 --- a/server/src/main/java/org/apache/iotdb/db/query/simpiece/DWT.java +++ b/server/src/main/java/org/apache/iotdb/db/query/simpiece/DWT.java @@ -19,17 +19,25 @@ package org.apache.iotdb.db.query.simpiece; +import org.apache.iotdb.db.query.simpiece.jwave.Transform; +import org.apache.iotdb.db.query.simpiece.jwave.TransformBuilder; + import java.util.ArrayList; import java.util.List; public class DWT { - public static List<Point> reducePoints(List<Point> points, double threshold) { - int length = points.size(); - - List<Point> result = new ArrayList<>(); - // IOMonitor2.DCP_D_getAllSatisfiedPageData_traversedPointNum++; + public static List<Point> reducePoints(double[] values, double threshold) { + Transform transform = TransformBuilder.create("Fast Wavelet Transform", "Haar"); + double[] arrHilb = transform.forward(values); + List<Point> result = new ArrayList<>(); + int n = arrHilb.length; + for (int i = 0; i < n; i++) { + if (Math.abs(arrHilb[i]) >= threshold) { + result.add(new Point(i, arrHilb[i])); + } + } return result; } } diff --git a/server/src/main/java/org/apache/iotdb/db/query/simpiece/MySample_JWaveTest.java b/server/src/main/java/org/apache/iotdb/db/query/simpiece/MySample_JWaveTest.java new file mode 100644 index 00000000000..7c040c0d4d5 --- /dev/null +++ b/server/src/main/java/org/apache/iotdb/db/query/simpiece/MySample_JWaveTest.java @@ -0,0 +1,77 @@ +/** + * JWave is distributed under the MIT License (MIT); this file is part of. + * + * <p>Copyright (c) 2008-2024 Christian ([email protected]) + * + * <p>Permission is hereby granted, free of charge, to any person obtaining a copy of this software + * and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * <p>The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * <p>THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +package org.apache.iotdb.db.query.simpiece; + +import org.apache.iotdb.db.query.simpiece.jwave.Transform; +import org.apache.iotdb.db.query.simpiece.jwave.TransformBuilder; +import org.apache.iotdb.db.query.simpiece.jwave.compressions.Compressor; +import org.apache.iotdb.db.query.simpiece.jwave.compressions.CompressorMagnitude; +import org.apache.iotdb.db.query.simpiece.jwave.tools.MathToolKit; +import org.apache.iotdb.tsfile.read.common.IOMonitor2; + +import java.io.IOException; + +public class MySample_JWaveTest { + + public static void main(String[] args) throws IOException { + int samplingRate = 1024; // sampling rate + int noOfOscillations = 1024; + // generate sampled (discrete) sine over 2 pi + double[] arrTime = MathToolKit.createSineOscillation(samplingRate, noOfOscillations); + + // Transform transform = TransformBuilder.create("Fast Wavelet Transform", "Haar"); + Transform transform = TransformBuilder.create("Discrete Fourier Transform", "Haar"); + + double[] arrHilb = transform.forward(arrTime); + + Compressor compressor = new CompressorMagnitude(0.000005); + + double[] arrComp = compressor.compress(arrHilb); + + // PrintWriter printWriter = new PrintWriter("tmp.csv"); + // for (int i = 0; i < arrComp.length; i++) { + // printWriter.println(arrHilb[i] + "," + arrComp[i]); + // } + // printWriter.close(); + + double[] arrReco = transform.reverse(arrComp); + + // calculate and print the absolute difference + int pos = 0; + double maxDiff = 0.; + for (int i = 0; i < arrReco.length; i++) { + double diff = Math.abs(arrTime[i] - arrReco[i]); + if (diff > maxDiff) { + maxDiff = diff; + pos = i; + } // if + } // i + System.out.println("absolute max difference at position " + pos + " is: " + maxDiff); + + // calculate the compression rate + double compressionRate = compressor.calcCompressionRate(arrComp); + System.out.println("The achieved compression rate: " + compressionRate); + + System.out.println(); + + System.out.println(IOMonitor2.DCP_D_getAllSatisfiedPageData_traversedPointNum); + } +} diff --git a/server/src/main/java/org/apache/iotdb/db/query/simpiece/SamplingTest.java b/server/src/main/java/org/apache/iotdb/db/query/simpiece/SamplingTest.java deleted file mode 100644 index cbe66a17546..00000000000 --- a/server/src/main/java/org/apache/iotdb/db/query/simpiece/SamplingTest.java +++ /dev/null @@ -1,50 +0,0 @@ -package org.apache.iotdb.db.query.simpiece; - -import org.apache.iotdb.db.query.simpiece.jwave.Transform; -import org.apache.iotdb.db.query.simpiece.jwave.TransformBuilder; -import org.apache.iotdb.db.query.simpiece.jwave.tools.MathToolKit; - -public class SamplingTest { - - public static void main(String[] args) { - int samplingRate = 1024 * 1024; // sampling rate - int noOfOscillations = 1024; - - // generate sampled (discrete) sine over 2 pi - double[] arrTime = MathToolKit.createSineOscillation(samplingRate, noOfOscillations); - - Transform transform = TransformBuilder.create("Fast Wavelet Transform", "Haar"); - - double[] arrHilb = transform.forward(arrTime); - - double[] arrReco = transform.reverse(arrHilb); - - // assertArray(arrTime, arrReco, 1e-10); - - // generate sampled (discrete) sine over 2 pi - arrTime = MathToolKit.createCosineOscillation(samplingRate, noOfOscillations); - - arrHilb = transform.forward(arrTime); - - arrReco = transform.reverse(arrHilb); - - // assertArray(arrTime, arrReco, 1e-10); - - transform = TransformBuilder.create("Wavelet Packet Transform", "Haar"); - - arrHilb = transform.forward(arrTime); - - arrReco = transform.reverse(arrHilb); - - // assertArray(arrTime, arrReco, 1e-10); - - // generate sampled (discrete) sine over 2 pi - arrTime = MathToolKit.createCosineOscillation(samplingRate, noOfOscillations); - - arrHilb = transform.forward(arrTime); - - arrReco = transform.reverse(arrHilb); - - // assertArray(arrTime, arrReco, 1e-10); - } -} diff --git a/server/src/main/java/org/apache/iotdb/db/query/simpiece/TimeSeriesReader.java b/server/src/main/java/org/apache/iotdb/db/query/simpiece/TimeSeriesReader.java index 57476066243..f43b9189f0c 100644 --- a/server/src/main/java/org/apache/iotdb/db/query/simpiece/TimeSeriesReader.java +++ b/server/src/main/java/org/apache/iotdb/db/query/simpiece/TimeSeriesReader.java @@ -90,6 +90,52 @@ public class TimeSeriesReader { return new TimeSeries(ts, max - min); } + public static double[] getTimeSeriesFromTsFilesDR( + List<ChunkSuit4Tri> chunkSuit4TriList, long startTime, long endTime) throws IOException { + // assume chunkSuit4TriList already sorted in increasing time order + List<Double> ts = new ArrayList<>(); + + int start = 0; + + for (ChunkSuit4Tri chunkSuit4Tri : chunkSuit4TriList) { + TSDataType dataType = chunkSuit4Tri.chunkMetadata.getDataType(); + if (dataType != TSDataType.DOUBLE) { + throw new UnSupportedDataTypeException(String.valueOf(dataType)); + } + ChunkMetadata chunkMetadata = chunkSuit4Tri.chunkMetadata; + long chunkMinTime = chunkMetadata.getStartTime(); + long chunkMaxTime = chunkMetadata.getEndTime(); + if (chunkMaxTime < startTime) { + continue; + } else if (chunkMinTime >= endTime) { + break; + } else { + chunkSuit4Tri.globalStartInList = start; // pointer start + chunkSuit4Tri.lastReadPos = start; // note this means global pos in the list + PageReader pageReader = // note this pageReader and its buffer is not maintained in memory + FileLoaderUtils.loadPageReaderList4CPV( + chunkSuit4Tri.chunkMetadata, + null); // note do not assign to chunkSuit4Tri.pageReader + for (int j = 0; j < chunkSuit4Tri.chunkMetadata.getStatistics().getCount(); j++) { + long timestamp = pageReader.timeBuffer.getLong(j * 8); + if (timestamp < startTime) { + continue; + } else if (timestamp >= endTime) { + break; + } else { // rightStartTime<=t<rightEndTime + ByteBuffer valueBuffer = pageReader.valueBuffer; + double value = valueBuffer.getDouble(pageReader.timeBufferLength + j * 8); + ts.add(value); + start++; + } + } + chunkSuit4Tri.globalEndInList = start; // pointer end + } + } + + return ts.stream().mapToDouble(Double::doubleValue).toArray(); + } + public static List<VisvalPoint> getTimeSeriesFromTsFilesVisval( List<ChunkSuit4Tri> chunkSuit4TriList, long startTime, long endTime) throws IOException { // assume chunkSuit4TriList already sorted in increasing time order diff --git a/server/src/main/java/org/apache/iotdb/db/query/simpiece/jwave/transforms/DiscreteFourierTransform.java b/server/src/main/java/org/apache/iotdb/db/query/simpiece/jwave/transforms/DiscreteFourierTransform.java index ab9012dab4b..3e82ebb0290 100644 --- a/server/src/main/java/org/apache/iotdb/db/query/simpiece/jwave/transforms/DiscreteFourierTransform.java +++ b/server/src/main/java/org/apache/iotdb/db/query/simpiece/jwave/transforms/DiscreteFourierTransform.java @@ -33,6 +33,7 @@ package org.apache.iotdb.db.query.simpiece.jwave.transforms; import org.apache.iotdb.db.query.simpiece.jwave.datatypes.natives.Complex; import org.apache.iotdb.db.query.simpiece.jwave.exceptions.JWaveException; import org.apache.iotdb.db.query.simpiece.jwave.exceptions.JWaveFailure; +import org.apache.iotdb.tsfile.read.common.IOMonitor2; /** * Discrete Fast Fourier Transform (dFFT) @@ -59,21 +60,22 @@ public class DiscreteFourierTransform extends BasicTransform { * index. For example: arrTime[ 0 ] = real1, arrTime[ 1 ] = imag1, arrTime[ 2 ] = real2, arrTime[ * 3 ] = imag2, ... The output arrFreq is organized by the same scheme. * + * @throws JWaveException * @date 25.03.2010 19:56:29 * @author Christian ([email protected]) - * @throws JWaveException * @see jwave.transforms.BasicTransform#forward(double[]) */ @Override public double[] forward(double[] arrTime) throws JWaveException { - if (!isBinary(arrTime.length)) + if (!isBinary(arrTime.length)) { throw new JWaveFailure( "DiscreteFourierTransform#forward - " + "given array length is not 2^p | p E N " + "... = 1, 2, 4, 8, 16, 32, .. " + "please use the Ancient Egyptian " + "Decomposition for any other array length!"); + } int m = arrTime.length; double[] arrFreq = new double[m]; // result @@ -91,6 +93,7 @@ public class DiscreteFourierTransform extends BasicTransform { double arg = -2. * Math.PI * (double) i / (double) n; for (int k = 0; k < n; k++) { + IOMonitor2.DCP_D_getAllSatisfiedPageData_traversedPointNum++; int kR = k * 2; int kC = k * 2 + 1; @@ -115,21 +118,22 @@ public class DiscreteFourierTransform extends BasicTransform { * index. For example: arrTime[ 0 ] = real1, arrTime[ 1 ] = imag1, arrTime[ 2 ] = real2, arrTime[ * 3 ] = imag2, ... The output arrTime is organized by the same scheme. * + * @throws JWaveException * @date 25.03.2010 19:56:29 * @author Christian ([email protected]) - * @throws JWaveException * @see jwave.transforms.BasicTransform#reverse(double[]) */ @Override public double[] reverse(double[] arrFreq) throws JWaveException { - if (!isBinary(arrFreq.length)) + if (!isBinary(arrFreq.length)) { throw new JWaveFailure( "DiscreteFourierTransform#reverse - " + "given array length is not 2^p | p E N " + "... = 1, 2, 4, 8, 16, 32, .. " + "please use the Ancient Egyptian " + "Decomposition for any other array length!"); + } int m = arrFreq.length; double[] arrTime = new double[m]; // result @@ -191,10 +195,10 @@ public class DiscreteFourierTransform extends BasicTransform { * organized by a class called Complex keeping real and imaginary part of a complex number. The * output arrFreq is organized by the same scheme. * - * @date 23.11.2010 18:57:34 - * @author Christian ([email protected]) * @param arrTime array of type Complex keeping coefficients of complex numbers * @return array of type Complex keeping the discrete fourier transform coefficients + * @date 23.11.2010 18:57:34 + * @author Christian ([email protected]) */ public Complex[] forward(Complex[] arrTime) { @@ -232,10 +236,10 @@ public class DiscreteFourierTransform extends BasicTransform { * organized by a class called Complex keeping real and imaginary part of a complex number. The * output arrTime is organized by the same scheme. * - * @date 23.11.2010 19:02:12 - * @author Christian ([email protected]) * @param arrFreq array of type Complex keeping the discrete fourier transform coefficients * @return array of type Complex keeping coefficients of tiem domain + * @date 23.11.2010 19:02:12 + * @author Christian ([email protected]) */ public Complex[] reverse(Complex[] arrFreq) { diff --git a/server/src/main/java/org/apache/iotdb/db/query/simpiece/jwave/transforms/wavelets/Wavelet.java b/server/src/main/java/org/apache/iotdb/db/query/simpiece/jwave/transforms/wavelets/Wavelet.java index d3c24f7a803..95820f8b24c 100644 --- a/server/src/main/java/org/apache/iotdb/db/query/simpiece/jwave/transforms/wavelets/Wavelet.java +++ b/server/src/main/java/org/apache/iotdb/db/query/simpiece/jwave/transforms/wavelets/Wavelet.java @@ -20,14 +20,16 @@ */ package org.apache.iotdb.db.query.simpiece.jwave.transforms.wavelets; +import org.apache.iotdb.tsfile.read.common.IOMonitor2; + import java.util.Arrays; /** * Basic class for one wavelet keeping coefficients of the wavelet function, the scaling function, * the base wavelength, the forward transform method, and the reverse transform method. * - * @date 10.02.2010 08:54:48 * @author Christian ([email protected]) + * @date 10.02.2010 08:54:48 */ public abstract class Wavelet { @@ -84,9 +86,13 @@ public abstract class Wavelet { // Alfred Haar's wavelet or the Daubechies Wavelet with 2 // vanishing moments for understanding what is done here. ;-) _waveletDeCom = new double[_motherWavelength]; - for (int i = 0; i < _motherWavelength; i++) - if (i % 2 == 0) _waveletDeCom[i] = _scalingDeCom[(_motherWavelength - 1) - i]; - else _waveletDeCom[i] = -_scalingDeCom[(_motherWavelength - 1) - i]; + for (int i = 0; i < _motherWavelength; i++) { + if (i % 2 == 0) { + _waveletDeCom[i] = _scalingDeCom[(_motherWavelength - 1) - i]; + } else { + _waveletDeCom[i] = -_scalingDeCom[(_motherWavelength - 1) - i]; + } + } // Copy to reconstruction filters due to orthogonality (orthonormality)! _scalingReCon = new double[_motherWavelength]; _waveletReCon = new double[_motherWavelength]; @@ -99,9 +105,9 @@ public abstract class Wavelet { /** * Returns a String keeping the name of the current Wavelet. * + * @return String keeping the name of the wavelet * @author Christian ([email protected]) * @date 17.08.2014 11:02:31 - * @return String keeping the name of the wavelet */ public String getName() { return _name; @@ -111,9 +117,9 @@ public abstract class Wavelet { * Returns a String keeping the name of the current Wavelet. Used to override Object's toString * method * + * @return String with the name of the wavelet * @author Dakota Williams * @date 11.06.2015 10:12:15 - * @return String with the name of the wavelet */ public String toString() { return getName(); @@ -122,9 +128,9 @@ public abstract class Wavelet { /** * Returns the wavelength of the so called mother wavelet or scaling function. * + * @return the minimal wavelength for the mother wavelet * @author Christian ([email protected]) * @date 15.02.2014 22:06:12 - * @return the minimal wavelength for the mother wavelet */ public int getMotherWavelength() { return _motherWavelength; @@ -133,10 +139,10 @@ public abstract class Wavelet { /** * Returns the minimal necessary wavelength for a signal that can be transformed by this wavelet. * - * @author Christian ([email protected]) - * @date 15.02.2014 22:08:43 * @return integer representing minimal wavelength of the input signal that should be transformed * by this wavelet. + * @author Christian ([email protected]) + * @date 15.02.2014 22:08:43 */ public int getTransformWavelength() { return _transformWavelength; @@ -145,10 +151,10 @@ public abstract class Wavelet { /** * Returns a copy of the scaling (low pass filter) coefficients of decomposition. * - * @author Christian ([email protected]) - * @date 15.02.2010 22:11:42 * @return array of length of the mother wavelet wavelength keeping the decomposition low pass * filter coefficients + * @author Christian ([email protected]) + * @date 15.02.2010 22:11:42 */ public final double[] getScalingDeComposition() { return Arrays.copyOf(_scalingDeCom, _scalingDeCom.length); @@ -157,10 +163,10 @@ public abstract class Wavelet { /** * Returns a copy of the wavelet (high pass filter) coefficients of decomposition. * - * @author Christian ([email protected]) - * @date 15.02.2014 22:11:25 * @return array of length of the mother wavelet wavelength keeping the decomposition high pass * filter coefficients + * @author Christian ([email protected]) + * @date 15.02.2014 22:11:25 */ public final double[] getWaveletDeComposition() { return Arrays.copyOf(_waveletDeCom, _waveletDeCom.length); @@ -169,10 +175,10 @@ public abstract class Wavelet { /** * Returns a copy of the scaling (low pass filter) coefficients of reconstruction. * - * @author Christian ([email protected]) - * @date 16.02.2014 10:35:11 * @return array of length of the mother wavelet wavelength keeping the reconstruction low pass * filter coefficients + * @author Christian ([email protected]) + * @date 16.02.2014 10:35:11 */ public final double[] getScalingReConstruction() { return Arrays.copyOf(_scalingReCon, _scalingReCon.length); @@ -181,10 +187,10 @@ public abstract class Wavelet { /** * Returns a copy of the wavelet (high pass filter) coefficients of reconstruction. * - * @author Christian ([email protected]) - * @date 16.02.2014 10:35:09 * @return array of length of the mother wavelet wavelength keeping the reconstruction high pass * filter coefficients + * @author Christian ([email protected]) + * @date 16.02.2014 10:35:09 */ public final double[] getWaveletReConstruction() { return Arrays.copyOf(_waveletReCon, _waveletReCon.length); @@ -195,12 +201,12 @@ public abstract class Wavelet { * returns a new array of the same size keeping coefficients of Hilbert domain and should be of * length 2 to the power of p -- length = 2^p where p is a positive integer. * - * @date 10.02.2010 08:18:02 - * @author Christian ([email protected]) * @param arrTime array keeping time domain coefficients * @param arrTimeLength is necessary, due to working only on a part of arrTime not on the full * length of arrTime! * @return coefficients represented by frequency domain + * @date 10.02.2010 08:18:02 + * @author Christian ([email protected]) */ public double[] forward(double[] arrTime, int arrTimeLength) { @@ -213,9 +219,12 @@ public abstract class Wavelet { for (int j = 0; j < _motherWavelength; j++) { + IOMonitor2.DCP_D_getAllSatisfiedPageData_traversedPointNum++; + int k = (i << 1) + j; // k = ( i * 2 ) + j; - while (k >= arrHilb.length) + while (k >= arrHilb.length) { k -= arrHilb.length; // circulate over arrays if scaling and wavelet are are larger + } arrHilb[i] += arrTime[k] * _scalingDeCom[j]; // low pass filter for the energy (approximation) @@ -231,17 +240,19 @@ public abstract class Wavelet { * returns a new array of the same size keeping coefficients of time domain and should be of * length 2 to the power of p -- length = 2^p where p is a positive integer. * - * @date 10.02.2010 08:19:24 - * @author Christian ([email protected]) * @param arrHilb array keeping frequency domain coefficients * @param arrHilbLength is necessary, due to working only on a part of arrHilb not on the full * length of arrHilb! * @return coefficients represented by time domain + * @date 10.02.2010 08:19:24 + * @author Christian ([email protected]) */ public double[] reverse(double[] arrHilb, int arrHilbLength) { double[] arrTime = new double[arrHilbLength]; - for (int i = 0; i < arrTime.length; i++) arrTime[i] = 0.; // set to zero before sum up + for (int i = 0; i < arrTime.length; i++) { + arrTime[i] = 0.; // set to zero before sum up + } int h = arrTime.length >> 1; // .. -> 8 -> 4 -> 2 .. shrinks in each step by half wavelength for (int i = 0; i < h; i++) { @@ -249,8 +260,9 @@ public abstract class Wavelet { for (int j = 0; j < _motherWavelength; j++) { int k = (i << 1) + j; // k = ( i * 2 ) + j; - while (k >= arrTime.length) + while (k >= arrTime.length) { k -= arrTime.length; // circulate over arrays if scaling and wavelet are larger + } // adding up energy from low pass (approximation) and details from high pass filter arrTime[k] += diff --git a/server/src/main/java/org/apache/iotdb/db/query/simpiece/jwave/transforms/wavelets/biorthogonal/BiOrthogonal.java b/server/src/main/java/org/apache/iotdb/db/query/simpiece/jwave/transforms/wavelets/biorthogonal/BiOrthogonal.java index 88cd63442c4..09120a56838 100644 --- a/server/src/main/java/org/apache/iotdb/db/query/simpiece/jwave/transforms/wavelets/biorthogonal/BiOrthogonal.java +++ b/server/src/main/java/org/apache/iotdb/db/query/simpiece/jwave/transforms/wavelets/biorthogonal/BiOrthogonal.java @@ -9,6 +9,7 @@ package org.apache.iotdb.db.query.simpiece.jwave.transforms.wavelets.biorthogonal; import org.apache.iotdb.db.query.simpiece.jwave.transforms.wavelets.Wavelet; +import org.apache.iotdb.tsfile.read.common.IOMonitor2; /** * Base class for BiOrthogonal wavelets. @@ -80,9 +81,12 @@ public class BiOrthogonal extends Wavelet { for (int j = 0; j < _motherWavelength; j++) { + IOMonitor2.DCP_D_getAllSatisfiedPageData_traversedPointNum++; + int k = (i << 1) + j; // k = ( i * 2 ) + j; - while (k >= arrHilb.length) + while (k >= arrHilb.length) { k -= arrHilb.length; // circulate over arrays if scaling and wavelet are are larger + } arrHilb[i] += arrTime[k] * _scalingDeCom[j]; // low pass filter for the energy (approximation) @@ -104,7 +108,9 @@ public class BiOrthogonal extends Wavelet { public double[] reverse(double[] arrHilb, int arrHilbLength) { double[] arrTime = new double[arrHilbLength]; - for (int i = 0; i < arrTime.length; i++) arrTime[i] = 0.; + for (int i = 0; i < arrTime.length; i++) { + arrTime[i] = 0.; + } int h = arrTime.length >> 1; // .. -> 8 -> 4 -> 2 .. shrinks in each step by half wavelength for (int i = 0; i < h; i++) { @@ -112,8 +118,9 @@ public class BiOrthogonal extends Wavelet { for (int j = 0; j < _motherWavelength; j++) { int k = (i << 1) + j; // k = ( i * 2 ) + j; - while (k >= arrTime.length) + while (k >= arrTime.length) { k -= arrTime.length; // circulate over arrays if scaling and wavelet are larger + } // adding up energy from low pass (approximation) and details from high pass filter arrTime[k] +=
