Skip to content
Merged
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 @@ -145,6 +145,10 @@ public String getSystemPropertiesPath() {
return workDirFilePath("data/datanode/system/schema", IoTDBStartCheck.PROPERTIES_FILE_NAME);
}

public String getDataDir() {
return getNodePath() + File.separator + "data";
}

@Override
protected MppJVMConfig initVMConfig() {
return MppJVMConfig.builder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.apache.iotdb.isession.ISession;
import org.apache.iotdb.isession.SessionDataSet;
import org.apache.iotdb.it.env.EnvFactory;
import org.apache.iotdb.it.env.cluster.node.DataNodeWrapper;
import org.apache.iotdb.it.framework.IoTDBTestRunner;
import org.apache.iotdb.itbase.category.ClusterIT;
import org.apache.iotdb.itbase.category.LocalStandaloneIT;
Expand All @@ -43,11 +44,13 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.fail;

@RunWith(IoTDBTestRunner.class)
Expand Down Expand Up @@ -359,6 +362,99 @@ public void insertAlignedRecordsOfOneDeviceNullTest() {
}
}

@Test
public void insertTabletNullTest() {
try (ISession session = EnvFactory.getEnv().getSessionConnection()) {
prepareData(session);

String deviceId = "root.sg1.clsu.d1";
Tablet tablet =
new Tablet(
deviceId,
Arrays.asList(
new MeasurementSchema("s1", TSDataType.BOOLEAN),
new MeasurementSchema("s2", TSDataType.INT32)),
3);
tablet.addTimestamp(0, 300);
tablet.addValue("s1", 0, null);
tablet.addValue("s2", 0, null);
tablet.addTimestamp(1, 400);
tablet.addValue("s1", 1, null);
tablet.addValue("s2", 1, null);
tablet.addTimestamp(2, 500);
tablet.addValue("s1", 2, null);
tablet.addValue("s2", 2, null);
session.insertTablet(tablet);
long nums = queryCountRecords(session, "select count(s1) from " + deviceId);
assertEquals(0, nums);
session.executeNonQueryStatement("flush");
nums = queryCountRecords(session, "select count(s1) from " + deviceId);
assertEquals(0, nums);
} catch (Exception e) {
e.printStackTrace();
fail(e.getMessage());
}
}

@Test
public void insertAlignedTabletNullTest() {
try (ISession session = EnvFactory.getEnv().getSessionConnection()) {
prepareData(session);

String deviceId = "root.sg1.clsu.aligned_d1";
Tablet tablet =
new Tablet(
deviceId,
Arrays.asList(
new MeasurementSchema("s1", TSDataType.BOOLEAN),
new MeasurementSchema("s2", TSDataType.INT32)),
3);
tablet.addTimestamp(0, 300);
tablet.addValue("s1", 0, null);
tablet.addValue("s2", 0, null);
tablet.addTimestamp(1, 400);
tablet.addValue("s1", 1, null);
tablet.addValue("s2", 1, null);
tablet.addTimestamp(2, 500);
tablet.addValue("s1", 2, null);
tablet.addValue("s2", 2, null);
session.insertAlignedTablet(tablet);
long nums = queryCountRecords(session, "select count(s1) from " + deviceId);
assertEquals(0, nums);
session.executeNonQueryStatement("flush");
nums = queryCountRecords(session, "select count(s1) from " + deviceId);
assertEquals(0, nums);
for (DataNodeWrapper dn : EnvFactory.getEnv().getDataNodeWrapperList()) {
File dir =
new File(
dn.getDataDir()
+ File.separator
+ "datanode"
+ File.separator
+ "data"
+ File.separator
+ "sequence"
+ File.separator
+ "root.sg1"
+ File.separator
+ "1"
+ File.separator
+ "0");
if (dir.exists() && dir.isDirectory()) {
File[] files = dir.listFiles();
if (files != null) {
for (File file : files) {
assertFalse(file.getName().endsWith("broken"));
}
}
}
}
} catch (Exception e) {
e.printStackTrace();
fail(e.getMessage());
}
}

@Test
public void insertTabletNullMeasurementTest() {
try (ISession session = EnvFactory.getEnv().getSessionConnection()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ public void syncFlushMemTable() throws ExecutionException, InterruptedException
for (IDeviceID deviceID : deviceIDList) {
final Map<String, IWritableMemChunk> value = memTableMap.get(deviceID).getMemChunkMap();
// skip the empty device/chunk group
if (memTableMap.get(deviceID).count() == 0 || value.isEmpty()) {
if (memTableMap.get(deviceID).isEmpty() || value.isEmpty()) {
continue;
}
encodingTaskQueue.put(new StartFlushGroupIOTask(deviceID));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -972,9 +972,8 @@ protected void deserialize(DataInputStream stream, boolean multiTvListMemChunk)
public Map<IDeviceID, Long> getMaxTime() {
Map<IDeviceID, Long> latestTimeForEachDevice = new HashMap<>();
for (Entry<IDeviceID, IWritableMemChunkGroup> entry : memTableMap.entrySet()) {
long maxTime = entry.getValue().getMaxTime();
if (entry.getValue().count() > 0) {
latestTimeForEachDevice.put(entry.getKey(), maxTime);
if (entry.getValue().count() > 0 && !entry.getValue().isEmpty()) {
latestTimeForEachDevice.put(entry.getKey(), entry.getValue().getMaxTime());
}
}
return latestTimeForEachDevice;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,28 @@ public long getLastPoint() {

@Override
public boolean isEmpty() {
return rowCount() == 0;
if (rowCount() == 0) {
return true;
}
if (measurementIndexMap.isEmpty()) {
return true;
}

if (list.rowCount() > 0) {
BitMap allValueColDeletedMap = list.getAllValueColDeletedMap();
if (allValueColDeletedMap == null || !allValueColDeletedMap.isAllMarked()) {
return false;
}
}
for (AlignedTVList alignedTvList : sortedList) {
if (alignedTvList.rowCount() > 0) {
BitMap allValueColDeletedMap = alignedTvList.getAllValueColDeletedMap();
if (allValueColDeletedMap == null || !allValueColDeletedMap.isAllMarked()) {
return false;
}
}
}
return true;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,11 @@ public Map<String, IWritableMemChunk> getMemChunkMap() {
return Collections.singletonMap("", memChunk);
}

@Override
public boolean isEmpty() {
return memChunk.isEmpty();
}

@SuppressWarnings("squid:S3776")
@Override
public int delete(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ void writeTablet(

Map<String, IWritableMemChunk> getMemChunkMap();

boolean isEmpty();

int delete(
PartialPath originalPath, PartialPath devicePath, long startTimestamp, long endTimestamp);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,11 @@ public Map<String, IWritableMemChunk> getMemChunkMap() {
return memChunkMap;
}

@Override
public boolean isEmpty() {
return memChunkMap.isEmpty() || count() == 0;
}

@SuppressWarnings("squid:S3776")
@Override
public int delete(
Expand Down
Loading