Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jt2594838 committed Feb 5, 2020
1 parent 2a842f0 commit 91e3dc1
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import org.apache.iotdb.cluster.log.logtypes.PhysicalPlanLog;
import org.apache.iotdb.cluster.rpc.thrift.Node;
import org.apache.iotdb.cluster.utils.PartitionUtils;
import org.apache.iotdb.db.conf.IoTDBDescriptor;
import org.apache.iotdb.db.engine.StorageEngine;
import org.apache.iotdb.db.exception.metadata.MetadataException;
import org.apache.iotdb.db.exception.metadata.StorageGroupNotSetException;
Expand All @@ -49,7 +50,6 @@
public interface PartitionTable {
// static final is not necessary, it is redundant for an interface
Logger logger = LoggerFactory.getLogger(SlotPartitionTable.class);
long PARTITION_INTERVAL = StorageEngine.getTimePartitionInterval();

/**
* Given the storageGroupName and the timestamp, return the list of nodes on which the storage
Expand Down Expand Up @@ -181,8 +181,9 @@ default MultiKeyMap<Long, PartitionGroup> partitionByPathRangeTime(String path,
long startTime, long endTime) throws StorageGroupNotSetException {
MultiKeyMap<Long, PartitionGroup> timeRangeMapRaftGroup = new MultiKeyMap<>();
String storageGroup = MManager.getInstance().getStorageGroupNameByPath(path);
long partitionInterval = IoTDBDescriptor.getInstance().getConfig().getPartitionInterval();
while (startTime <= endTime) {
long nextTime = (startTime / PARTITION_INTERVAL + 1) * PARTITION_INTERVAL; //FIXME considering the time unit
long nextTime = (startTime / partitionInterval + 1) * partitionInterval; //FIXME considering the time unit
timeRangeMapRaftGroup.put(startTime, Math.min(nextTime - 1, endTime),
this.route(storageGroup, startTime));
startTime = nextTime;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,8 @@ private boolean isFileAlreadyPulled(RemoteTsFileResource resource) {
// TODO-Cluster#352: The problem of duplicated data in remote files is partially resolved by
// tracking the merge history using the version numbers of the merged files. But a better
// solution still remains to be found.
String[] pathSegments = resource.getFile().getAbsolutePath().split(File.separator);
String separatorString = File.separator.equals("\\") ? "\\\\" : "/";
String[] pathSegments = resource.getFile().getAbsolutePath().split(separatorString);
int segSize = pathSegments.length;
// {storageGroupName}/{fileName}
String storageGroupName = pathSegments[segSize - 2];
Expand Down Expand Up @@ -341,7 +342,8 @@ private void loadRemoteFile(RemoteTsFileResource resource) {

private void loadRemoteResource(RemoteTsFileResource resource) {
// remote/{nodeIdentifier}/{storageGroupName}/{fileName}
String[] pathSegments = resource.getFile().getAbsolutePath().split(File.separator);
String separatorString = File.separator.equals("\\") ? "\\\\" : "/";
String[] pathSegments = resource.getFile().getAbsolutePath().split(separatorString);
int segSize = pathSegments.length;
String storageGroupName = pathSegments[segSize - 2];
File remoteModFile =
Expand All @@ -365,7 +367,8 @@ private void loadRemoteResource(RemoteTsFileResource resource) {
private File pullRemoteFile(RemoteTsFileResource resource, Node node) {
logger.debug("{}: pulling remote file {} from {}", name, resource, node);

String[] pathSegments = resource.getFile().getAbsolutePath().split(File.separator);
String separatorString = File.separator.equals("\\") ? "\\\\" : "/";
String[] pathSegments = resource.getFile().getAbsolutePath().split(separatorString);
int segSize = pathSegments.length;
// remote/{nodeIdentifier}/{storageGroupName}/{fileName}
String tempFileName =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public void getRemoteSnapshot() {
int startTime = 12345;
for (RemoteTsFileResource tsFileResource : remoteDataFiles) {
// fake a file for each resource
String[] splits = tsFileResource.getFile().getPath().split(File.separator);
String[] splits = tsFileResource.getFile().getPath().split("\\\\");
String storageGroup = splits[splits.length - 2];
InsertPlan insertPlan = new InsertPlan();
insertPlan.setDeviceId(storageGroup);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public static PartitionTable getPartitionTable(int nodeNum) {
for (int i = 0; i < nodeNum; i++) {
nodes.add(getNode(i));
}
return new SlotPartitionTable(nodes, getNode(0));
return new SlotPartitionTable(nodes, getNode(0), 100);
}

public static String getTestSg(int i) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public void testSnapshot() throws QueryProcessException, StorageGroupNotSetExcep
manager.commitLog(10);

// create files for sgs
for (int i = 0; i < 3; i++) {
for (int i = 1; i < 4; i++) {
String sg = TestUtils.getTestSg(i);
for (int j = 0; j < 4; j++) {
// closed files
Expand All @@ -73,7 +73,7 @@ public void testSnapshot() throws QueryProcessException, StorageGroupNotSetExcep

manager.takeSnapshot();
PartitionedSnapshot snapshot = (PartitionedSnapshot) manager.getSnapshot();
for (int i = 0; i < 3; i++) {
for (int i = 1; i < 4; i++) {
FileSnapshot fileSnapshot =
(FileSnapshot) snapshot.getSnapshot(PartitionUtils.calculateStorageGroupSlot(
TestUtils.getTestSg(i), 0, 100));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public void testSnapshot() throws QueryProcessException, StorageGroupNotSetExcep
manager.commitLog(10);

// create files for sgs
for (int i = 0; i < 3; i++) {
for (int i = 1; i < 4; i++) {
String sg = TestUtils.getTestSg(i);
for (int j = 0; j < 4; j++) {
// closed files
Expand All @@ -72,7 +72,7 @@ public void testSnapshot() throws QueryProcessException, StorageGroupNotSetExcep

manager.takeSnapshot();
PartitionedSnapshot snapshot = (PartitionedSnapshot) manager.getSnapshot();
for (int i = 0; i < 3; i++) {
for (int i = 1; i < 4; i++) {
FileSnapshot fileSnapshot =
(FileSnapshot) snapshot.getSnapshot(PartitionUtils.calculateStorageGroupSlot(
TestUtils.getTestSg(i), 0, 100));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,19 +47,17 @@ public void setUp() throws MetadataException {
@Test
public void test() throws QueryProcessException {
QueryOperator operator = new QueryOperator(SQLConstant.TOK_QUERY);
operator.setGroupByDevice(true);

SelectOperator selectOperator = new SelectOperator(SQLConstant.TOK_SELECT);
selectOperator.setSuffixPathList(Collections.singletonList(new Path("*")));
selectOperator.setSuffixPathList(pathList);
FromOperator fromOperator = new FromOperator(SQLConstant.TOK_FROM);
fromOperator.addPrefixTablePath(new Path(TestUtils.getTestSg(0)));

operator.setSelectOperator(selectOperator);
operator.setFromOperator(fromOperator);
QueryPlan plan = (QueryPlan) physicalGenerator.transformToPhysicalPlan(operator);

// TODO: Enable this when IOTDB-412 is fixed
//assertEquals(pathList, plan.getDeduplicatedPaths());
assertEquals(pathList, plan.getDeduplicatedPaths());
assertEquals(dataTypes, plan.getDeduplicatedDataTypes());
}
}

0 comments on commit 91e3dc1

Please sign in to comment.