Skip to content

Commit

Permalink
Today's mvn spotless::apply.
Browse files Browse the repository at this point in the history
  • Loading branch information
Sh-Zh-7 committed Dec 23, 2024
1 parent 0f1912d commit 46c525f
Showing 1 changed file with 47 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

package org.apache.iotdb.db.queryengine.execution.operator.process.window;

import com.google.common.util.concurrent.ListenableFuture;
import org.apache.iotdb.commons.concurrent.IoTDBThreadPoolFactory;
import org.apache.iotdb.db.queryengine.common.FragmentInstanceId;
import org.apache.iotdb.db.queryengine.common.PlanFragmentId;
Expand All @@ -32,10 +31,10 @@
import org.apache.iotdb.db.queryengine.execution.operator.process.TreeLinearFillOperator;
import org.apache.iotdb.db.queryengine.execution.operator.process.window.function.WindowFunction;
import org.apache.iotdb.db.queryengine.execution.operator.process.window.function.rank.RankFunction;
import org.apache.iotdb.db.queryengine.execution.operator.process.window.function.value.FirstValueFunction;
import org.apache.iotdb.db.queryengine.execution.operator.process.window.partition.frame.FrameInfo;
import org.apache.iotdb.db.queryengine.plan.planner.plan.node.PlanNodeId;

import com.google.common.util.concurrent.ListenableFuture;
import org.apache.tsfile.common.conf.TSFileConfig;
import org.apache.tsfile.enums.TSDataType;
import org.apache.tsfile.read.common.block.TsBlock;
Expand Down Expand Up @@ -67,33 +66,36 @@ public class TableWindowOperatorTest {
public void testOneTsBlockWithMultiPartition() {
long[][] timeArray =
new long[][] {
{1, 2, 3, 4, 5, 6, 7},
{1, 2, 3, 4, 5, 6, 7},
};
String[][] deviceIdArray =
new String[][] {
{"d1", "d1", "d2", "d2", "d2", "d2", "d2"},
{"d1", "d1", "d2", "d2", "d2", "d2", "d2"},
};
int[][] valueArray =
new int[][] {
{1, 2, 3, 4, 5, 6, 7},
{1, 2, 3, 4, 5, 6, 7},
};

int count = 0;
try (TableWindowOperator windowOperator = genWindowOperator(timeArray, deviceIdArray, valueArray)) {
try (TableWindowOperator windowOperator =
genWindowOperator(timeArray, deviceIdArray, valueArray)) {
ListenableFuture<?> listenableFuture = windowOperator.isBlocked();
listenableFuture.get();
while (!windowOperator.isFinished() && windowOperator.hasNext()) {
TsBlock tsBlock = windowOperator.next();
if (tsBlock != null && !tsBlock.isEmpty()) {
for (int i = 0, size = tsBlock.getPositionCount(); i < size; i++, count++) {
assertEquals(column1[count], tsBlock.getColumn(0).getLong(i));
assertEquals(column2[count], tsBlock.getColumn(1).getBinary(i).getStringValue(TSFileConfig.STRING_CHARSET));
assertEquals(
column2[count],
tsBlock.getColumn(1).getBinary(i).getStringValue(TSFileConfig.STRING_CHARSET));
assertEquals(column3[count], tsBlock.getColumn(2).getInt(i));
assertEquals(column4[count], tsBlock.getColumn(3).getLong(i));
}
}
}
} catch (Exception e) {
} catch (Exception e) {
e.printStackTrace();
fail(e.getMessage());
}
Expand All @@ -103,42 +105,45 @@ public void testOneTsBlockWithMultiPartition() {
public void testPartitionCrossMultiTsBlock() {
long[][] timeArray =
new long[][] {
{1, 2},
{3, 4},
{5},
{6, 7},
{1, 2},
{3, 4},
{5},
{6, 7},
};
String[][] deviceIdArray =
new String[][] {
{"d1", "d1"},
{"d2", "d2"},
{"d2"},
{"d2", "d2"},
{"d1", "d1"},
{"d2", "d2"},
{"d2"},
{"d2", "d2"},
};
int[][] valueArray =
new int[][] {
{1, 2},
{3, 4},
{5},
{6, 7},
{1, 2},
{3, 4},
{5},
{6, 7},
};

int count = 0;
try (TableWindowOperator windowOperator = genWindowOperator(timeArray, deviceIdArray, valueArray)) {
try (TableWindowOperator windowOperator =
genWindowOperator(timeArray, deviceIdArray, valueArray)) {
ListenableFuture<?> listenableFuture = windowOperator.isBlocked();
listenableFuture.get();
while (!windowOperator.isFinished() && windowOperator.hasNext()) {
TsBlock tsBlock = windowOperator.next();
if (tsBlock != null && !tsBlock.isEmpty()) {
for (int i = 0, size = tsBlock.getPositionCount(); i < size; i++, count++) {
assertEquals(column1[count], tsBlock.getColumn(0).getLong(i));
assertEquals(column2[count], tsBlock.getColumn(1).getBinary(i).getStringValue(TSFileConfig.STRING_CHARSET));
assertEquals(
column2[count],
tsBlock.getColumn(1).getBinary(i).getStringValue(TSFileConfig.STRING_CHARSET));
assertEquals(column3[count], tsBlock.getColumn(2).getInt(i));
assertEquals(column4[count], tsBlock.getColumn(3).getLong(i));
}
}
}
} catch (Exception e) {
} catch (Exception e) {
e.printStackTrace();
fail(e.getMessage());
}
Expand All @@ -148,36 +153,39 @@ public void testPartitionCrossMultiTsBlock() {
public void testMixedPartition() {
long[][] timeArray =
new long[][] {
{1, 2, 3, 4},
{5, 6, 7},
{1, 2, 3, 4},
{5, 6, 7},
};
String[][] deviceIdArray =
new String[][] {
{"d1", "d1", "d2", "d2"},
{"d2", "d2", "d2"},
{"d1", "d1", "d2", "d2"},
{"d2", "d2", "d2"},
};
int[][] valueArray =
new int[][] {
{1, 2, 3, 4},
{5, 6, 7},
{1, 2, 3, 4},
{5, 6, 7},
};

int count = 0;
try (TableWindowOperator windowOperator = genWindowOperator(timeArray, deviceIdArray, valueArray)) {
try (TableWindowOperator windowOperator =
genWindowOperator(timeArray, deviceIdArray, valueArray)) {
ListenableFuture<?> listenableFuture = windowOperator.isBlocked();
listenableFuture.get();
while (!windowOperator.isFinished() && windowOperator.hasNext()) {
TsBlock tsBlock = windowOperator.next();
if (tsBlock != null && !tsBlock.isEmpty()) {
for (int i = 0, size = tsBlock.getPositionCount(); i < size; i++, count++) {
assertEquals(column1[count], tsBlock.getColumn(0).getLong(i));
assertEquals(column2[count], tsBlock.getColumn(1).getBinary(i).getStringValue(TSFileConfig.STRING_CHARSET));
assertEquals(
column2[count],
tsBlock.getColumn(1).getBinary(i).getStringValue(TSFileConfig.STRING_CHARSET));
assertEquals(column3[count], tsBlock.getColumn(2).getInt(i));
assertEquals(column4[count], tsBlock.getColumn(3).getLong(i));
}
}
}
} catch (Exception e) {
} catch (Exception e) {
e.printStackTrace();
fail(e.getMessage());
}
Expand All @@ -191,7 +199,11 @@ static class ChildOperator implements Operator {
private final int[][] valueArray;
private final DriverContext driverContext;

ChildOperator(long[][] timeArray, String[][] deviceIdArray, int[][] valueArray, DriverContext driverContext) {
ChildOperator(
long[][] timeArray,
String[][] deviceIdArray,
int[][] valueArray,
DriverContext driverContext) {
this.timeArray = timeArray;
this.deviceIdArray = deviceIdArray;
this.valueArray = valueArray;
Expand Down Expand Up @@ -264,7 +276,8 @@ public long ramBytesUsed() {
}
}

private TableWindowOperator genWindowOperator(long[][] timeArray, String[][] deviceIdArray, int[][] valueArray) {
private TableWindowOperator genWindowOperator(
long[][] timeArray, String[][] deviceIdArray, int[][] valueArray) {
QueryId queryId = new QueryId("stub_query");
FragmentInstanceId instanceId =
new FragmentInstanceId(new PlanFragmentId(queryId, 0), "stub-instance");
Expand Down

0 comments on commit 46c525f

Please sign in to comment.