Skip to content

Commit 1616d2a

Browse files
committed
fix UT errors
1 parent caac815 commit 1616d2a

File tree

9 files changed

+53
-4
lines changed

9 files changed

+53
-4
lines changed

iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/planner/plan/node/write/RelationalInsertRowsNode.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ private void handleObjectValue(
226226
ByteBuffer valueBytes =
227227
ByteBuffer.allocate(relativePath.getSerializedSize() + Long.BYTES);
228228
valueBytes.putLong(offset + content.length);
229-
relativePath.serialize(valueBytes);
229+
relativePath.serializeToObjectValue(valueBytes);
230230
((Binary) values[j]).setValues(valueBytes.array());
231231
insertRowNode.setValues(values);
232232
} else {

iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/planner/plan/node/write/RelationalInsertTabletNode.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,7 @@ private void handleObjectValue(
477477
if (isEoF) {
478478
ByteBuffer valueBytes = ByteBuffer.allocate(relativePath.getSerializedSize() + Long.BYTES);
479479
valueBytes.putLong(offset + content.length);
480-
relativePath.serialize(valueBytes);
480+
relativePath.serializeToObjectValue(valueBytes);
481481
((Binary[]) columns[column])[j] = new Binary(valueBytes.array());
482482
} else {
483483
((Binary[]) columns[column])[j] = null;

iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/Base32ObjectPath.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@ public IObjectPath deserializeFrom(ByteBuffer byteBuffer) {
4848
public IObjectPath deserializeFrom(InputStream inputStream) throws IOException {
4949
return deserialize(inputStream);
5050
}
51+
52+
@Override
53+
public IObjectPath deserializeFromObjectValue(ByteBuffer byteBuffer) {
54+
return deserialize(byteBuffer);
55+
}
5156
};
5257

5358
private static final Factory FACTORY = Base32ObjectPath::new;
@@ -108,6 +113,11 @@ public int getSerializedSize() {
108113
return cnt;
109114
}
110115

116+
@Override
117+
public void serializeToObjectValue(ByteBuffer byteBuffer) {
118+
serialize(byteBuffer);
119+
}
120+
111121
public static Base32ObjectPath deserialize(ByteBuffer byteBuffer) {
112122
int cnt = ReadWriteForEncodingUtils.readUnsignedVarInt(byteBuffer);
113123
String first = ReadWriteIOUtils.readVarIntString(byteBuffer);

iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/IObjectPath.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ public interface IObjectPath {
3939

4040
int getSerializedSize();
4141

42+
void serializeToObjectValue(ByteBuffer byteBuffer);
43+
4244
interface Factory {
4345

4446
IObjectPath create(int regionId, long time, IDeviceID iDeviceID, String measurement);
@@ -55,6 +57,8 @@ interface Deserializer {
5557

5658
IObjectPath deserializeFrom(InputStream inputStream) throws IOException;
5759

60+
IObjectPath deserializeFromObjectValue(ByteBuffer byteBuffer);
61+
5862
Deserializer DESERIALIZER =
5963
CONFIG.getRestrictObjectLimit()
6064
? PlainObjectPath.getDESERIALIZER()

iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/PlainObjectPath.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import java.io.InputStream;
2828
import java.io.OutputStream;
2929
import java.nio.ByteBuffer;
30+
import java.nio.charset.StandardCharsets;
3031

3132
public class PlainObjectPath implements IObjectPath {
3233

@@ -43,6 +44,11 @@ public IObjectPath deserializeFrom(ByteBuffer byteBuffer) {
4344
public IObjectPath deserializeFrom(InputStream inputStream) throws IOException {
4445
return deserialize(inputStream);
4546
}
47+
48+
@Override
49+
public IObjectPath deserializeFromObjectValue(ByteBuffer byteBuffer) {
50+
return deserializeObjectValue(byteBuffer);
51+
}
4652
};
4753

4854
private static final Factory FACTORY = PlainObjectPath::new;
@@ -81,6 +87,11 @@ public int getSerializedSize() {
8187
return ReadWriteIOUtils.sizeToWrite(filePath);
8288
}
8389

90+
@Override
91+
public void serializeToObjectValue(ByteBuffer byteBuffer) {
92+
byteBuffer.put(filePath.getBytes(StandardCharsets.UTF_8));
93+
}
94+
8495
public static PlainObjectPath deserialize(ByteBuffer byteBuffer) {
8596
String filePath = ReadWriteIOUtils.readString(byteBuffer);
8697
return new PlainObjectPath(filePath);
@@ -91,6 +102,12 @@ public static PlainObjectPath deserialize(InputStream stream) throws IOException
91102
return new PlainObjectPath(filePath);
92103
}
93104

105+
public static PlainObjectPath deserializeObjectValue(ByteBuffer byteBuffer) {
106+
byte[] bytes = new byte[byteBuffer.remaining()];
107+
byteBuffer.get(bytes);
108+
return new PlainObjectPath(new String(bytes, StandardCharsets.UTF_8));
109+
}
110+
94111
@Override
95112
public String toString() {
96113
return filePath;

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ public static Pair<Long, String> parseObjectBinary(Binary binary) {
169169
ByteBuffer buffer = ByteBuffer.wrap(bytes);
170170
long length = buffer.getLong();
171171
String relativeObjectFilePath =
172-
IObjectPath.Deserializer.DESERIALIZER.deserializeFrom(buffer).toString();
172+
IObjectPath.Deserializer.DESERIALIZER.deserializeFromObjectValue(buffer).toString();
173173
return new Pair<>(length, relativeObjectFilePath);
174174
}
175175

@@ -184,7 +184,7 @@ public static Optional<File> getNullableObjectPathFromBinary(
184184
byte[] bytes = binary.getValues();
185185
ByteBuffer buffer = ByteBuffer.wrap(bytes, 8, bytes.length - 8);
186186
String relativeObjectFilePath =
187-
IObjectPath.Deserializer.DESERIALIZER.deserializeFrom(buffer).toString();
187+
IObjectPath.Deserializer.DESERIALIZER.deserializeFromObjectValue(buffer).toString();
188188
return TIER_MANAGER.getAbsoluteObjectFilePath(relativeObjectFilePath, needTempFile);
189189
}
190190

iotdb-core/datanode/src/test/java/org/apache/iotdb/db/queryengine/plan/function/RecordObjectTypeTest.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919

2020
package org.apache.iotdb.db.queryengine.plan.function;
2121

22+
import org.apache.iotdb.db.conf.IoTDBConfig;
23+
import org.apache.iotdb.db.conf.IoTDBDescriptor;
2224
import org.apache.iotdb.db.exception.DiskSpaceInsufficientException;
2325
import org.apache.iotdb.db.queryengine.execution.operator.process.function.partition.Slice;
2426
import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.RecordIterator;
@@ -50,10 +52,13 @@
5052

5153
public class RecordObjectTypeTest {
5254

55+
private final IoTDBConfig config = IoTDBDescriptor.getInstance().getConfig();
56+
5357
private File objectDir;
5458

5559
@Before
5660
public void setup() {
61+
config.setRestrictObjectLimit(true);
5762
try {
5863
objectDir = new File(TierManager.getInstance().getNextFolderForObjectFile());
5964
} catch (DiskSpaceInsufficientException e) {
@@ -69,6 +74,7 @@ public void tearDown() throws IOException {
6974
Files.delete(file.toPath());
7075
}
7176
}
77+
config.setRestrictObjectLimit(true);
7278
}
7379

7480
@Test

iotdb-core/datanode/src/test/java/org/apache/iotdb/db/queryengine/transformation/dag/column/unary/scalar/ObjectTypeFunctionTest.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919

2020
package org.apache.iotdb.db.queryengine.transformation.dag.column.unary.scalar;
2121

22+
import org.apache.iotdb.db.conf.IoTDBConfig;
23+
import org.apache.iotdb.db.conf.IoTDBDescriptor;
2224
import org.apache.iotdb.db.exception.DiskSpaceInsufficientException;
2325
import org.apache.iotdb.db.queryengine.transformation.dag.column.ColumnTransformer;
2426
import org.apache.iotdb.db.storageengine.rescon.disk.TierManager;
@@ -48,10 +50,13 @@
4850

4951
public class ObjectTypeFunctionTest {
5052

53+
private final IoTDBConfig config = IoTDBDescriptor.getInstance().getConfig();
54+
5155
private File objectDir;
5256

5357
@Before
5458
public void setup() {
59+
config.setRestrictObjectLimit(true);
5560
try {
5661
objectDir = new File(TierManager.getInstance().getNextFolderForObjectFile());
5762
} catch (DiskSpaceInsufficientException e) {
@@ -67,6 +72,7 @@ public void tearDown() throws IOException {
6772
Files.delete(file.toPath());
6873
}
6974
}
75+
config.setRestrictObjectLimit(false);
7076
}
7177

7278
@Test

iotdb-core/datanode/src/test/java/org/apache/iotdb/db/storageengine/dataregion/compaction/object/ObjectTypeCompactionTest.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
import org.apache.iotdb.commons.schema.table.TsTable;
2424
import org.apache.iotdb.commons.schema.table.column.FieldColumnSchema;
2525
import org.apache.iotdb.commons.schema.table.column.TagColumnSchema;
26+
import org.apache.iotdb.db.conf.IoTDBConfig;
27+
import org.apache.iotdb.db.conf.IoTDBDescriptor;
2628
import org.apache.iotdb.db.exception.DiskSpaceInsufficientException;
2729
import org.apache.iotdb.db.exception.StorageEngineException;
2830
import org.apache.iotdb.db.schemaengine.table.DataNodeTableCache;
@@ -77,10 +79,13 @@ public class ObjectTypeCompactionTest extends AbstractCompactionTest {
7779
private String threadName;
7880
private File objectDir;
7981

82+
private final IoTDBConfig config = IoTDBDescriptor.getInstance().getConfig();
83+
8084
@Before
8185
@Override
8286
public void setUp()
8387
throws IOException, WriteProcessException, MetadataException, InterruptedException {
88+
config.setRestrictObjectLimit(true);
8489
this.threadName = Thread.currentThread().getName();
8590
Thread.currentThread().setName("pool-1-IoTDB-Compaction-Worker-1");
8691
DataNodeTableCache.getInstance().invalid(this.COMPACTION_TEST_SG);
@@ -105,6 +110,7 @@ public void tearDown() throws IOException, StorageEngineException {
105110
Files.delete(file.toPath());
106111
}
107112
}
113+
config.setRestrictObjectLimit(false);
108114
}
109115

110116
public void createTable(String tableName, long ttl) {

0 commit comments

Comments
 (0)