Skip to content

Commit 7800de6

Browse files
authored
Correct the memroy calculation of BinaryColumnBuilder
1 parent a184469 commit 7800de6

5 files changed

Lines changed: 26 additions & 13 deletions

File tree

integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/IoTDBMultiTAGsWithAttributesTableIT.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -390,12 +390,12 @@ public void sortTAGWithExpressionTest() {
390390
"l3,217,null,d2,1971-01-01T00:00:00.500Z,",
391391
"l3,245,t,d1,1971-04-26T17:46:40.020Z,",
392392
"l3,245,null,d2,1971-04-26T17:46:40.020Z,",
393-
"l4,52,null,d2,1970-01-01T00:00:00.080Z,",
394393
"l4,52,null,d1,1970-01-01T00:00:00.080Z,",
395-
"l4,61,null,d2,1971-01-01T00:00:01.000Z,",
394+
"l4,52,null,d2,1970-01-01T00:00:00.080Z,",
396395
"l4,61,null,d1,1971-01-01T00:00:01.000Z,",
397-
"l4,67,null,d2,1971-04-26T18:01:40.000Z,",
396+
"l4,61,null,d2,1971-01-01T00:00:01.000Z,",
398397
"l4,67,null,d1,1971-04-26T18:01:40.000Z,",
398+
"l4,67,null,d2,1971-04-26T18:01:40.000Z,",
399399
"l5,220,null,d1,1971-01-01T00:00:10.000Z,",
400400
"l5,220,null,d2,1971-01-01T00:00:10.000Z,",
401401
"l5,250,null,d1,1971-08-20T11:33:20.000Z,",
@@ -404,7 +404,7 @@ public void sortTAGWithExpressionTest() {
404404
"l5,4662,null,d2,1970-01-01T00:00:00.100Z,",
405405
};
406406
tableResultSetEqualTest(
407-
"select level,cast(num+floatNum as int32) as sum,attr1,device,time from table0 order by level asc, cast(num+floatNum as int32) asc, attr1 desc",
407+
"select level,cast(num+floatNum as int32) as sum,attr1,device,time from table0 order by level asc, cast(num+floatNum as int32) asc, attr1 desc, device asc",
408408
expectedHeader,
409409
retArray,
410410
DATABASE_NAME);

iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/AbstractMergeSortJoinOperator.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,20 @@ protected void gotCandidateBlocks() throws Exception {
325325
} else {
326326
if (cachedNextRightBlock == null) {
327327
tryCacheNextRightTsBlock();
328+
} else {
329+
// if first value of block equals to last value of rightBlockList.get(0), append this block
330+
// to
331+
// rightBlockList
332+
if (equalsTo(
333+
cachedNextRightBlock,
334+
rightJoinKeyPositions,
335+
0,
336+
rightBlockList.get(0),
337+
rightJoinKeyPositions,
338+
rightBlockList.get(0).getPositionCount() - 1)) {
339+
addRightBlockWithMemoryReservation(cachedNextRightBlock);
340+
cachedNextRightBlock = null;
341+
}
328342
}
329343
}
330344
}

iotdb-core/datanode/src/main/java/org/apache/iotdb/db/utils/sort/FileSpillerReader.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public class FileSpillerReader implements SortReader {
4747
private int rowIndex;
4848
private boolean isEnd = false;
4949

50-
private static final int DEFAULT_MAX_TSBLOCK_SIZE_IN_BYTES =
50+
private final int maxTsBlockSizeInBytes =
5151
TSFileDescriptor.getInstance().getConfig().getMaxTsBlockSizeInBytes();
5252

5353
public FileSpillerReader(String fileName, SortBufferManager sortBufferManager, TsBlockSerde serde)
@@ -70,7 +70,7 @@ public MergeSortKey next() {
7070
private boolean readTsBlockFromFile() throws IoTDBException {
7171
long bufferSize = sortBufferManager.getReaderBufferAvailable();
7272
cacheBlocks.clear();
73-
while (bufferSize >= DEFAULT_MAX_TSBLOCK_SIZE_IN_BYTES) {
73+
while (bufferSize >= maxTsBlockSizeInBytes) {
7474
long size = read();
7575
if (size == -1) {
7676
break;

iotdb-core/datanode/src/test/java/org/apache/iotdb/db/queryengine/execution/operator/process/TableStreamSortOperatorTest.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363

6464
public class TableStreamSortOperatorTest {
6565

66-
private static final String sortTmpPrefixPath =
66+
private static final String SORT_TMP_PREFIX_PATH =
6767
"target" + File.separator + "sort" + File.separator + "tmp";
6868

6969
private static final ExecutorService instanceNotificationExecutor =
@@ -143,7 +143,7 @@ public class TableStreamSortOperatorTest {
143143

144144
@After
145145
public void cleanUp() throws IOException {
146-
cleanDir(sortTmpPrefixPath);
146+
cleanDir(SORT_TMP_PREFIX_PATH);
147147
}
148148

149149
@AfterClass
@@ -292,8 +292,8 @@ public void someInDiskTest2() {
292292
int maxTsBlockSizeInBytes =
293293
TSFileDescriptor.getInstance().getConfig().getMaxTsBlockSizeInBytes();
294294
int maxTsBlockLineNumber = TSFileDescriptor.getInstance().getConfig().getMaxTsBlockLineNumber();
295-
IoTDBDescriptor.getInstance().getConfig().setSortBufferSize(500);
296-
TSFileDescriptor.getInstance().getConfig().setMaxTsBlockSizeInBytes(50);
295+
IoTDBDescriptor.getInstance().getConfig().setSortBufferSize(1000);
296+
TSFileDescriptor.getInstance().getConfig().setMaxTsBlockSizeInBytes(100);
297297
TSFileDescriptor.getInstance().getConfig().setMaxTsBlockLineNumber(2);
298298
try (TableStreamSortOperator tableStreamSortOperator = genStreamSortOperator(2)) {
299299

@@ -303,7 +303,6 @@ public void someInDiskTest2() {
303303
while (!tableStreamSortOperator.isFinished() && tableStreamSortOperator.hasNext()) {
304304
TsBlock tsBlock = tableStreamSortOperator.next();
305305
if (tsBlock != null && !tsBlock.isEmpty()) {
306-
assertEquals(2, tsBlock.getPositionCount());
307306
for (int i = 0, size = tsBlock.getPositionCount(); i < size; i++, count++) {
308307
assertFalse(tsBlock.getColumn(0).isNull(i));
309308
assertEquals(timeArray[count], tsBlock.getColumn(0).getLong(i));
@@ -560,7 +559,7 @@ public long ramBytesUsed() {
560559

561560
OperatorContext operatorContext = driverContext.getOperatorContexts().get(1);
562561
String filePrefix =
563-
sortTmpPrefixPath
562+
SORT_TMP_PREFIX_PATH
564563
+ File.separator
565564
+ operatorContext
566565
.getDriverContext()

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@
175175
<thrift.version>0.14.1</thrift.version>
176176
<xz.version>1.9</xz.version>
177177
<zstd-jni.version>1.5.6-3</zstd-jni.version>
178-
<tsfile.version>2.1.0-250616-SNAPSHOT</tsfile.version>
178+
<tsfile.version>2.1.0-250707-SNAPSHOT</tsfile.version>
179179
</properties>
180180
<!--
181181
if we claim dependencies in dependencyManagement, then we do not claim

0 commit comments

Comments
 (0)