Skip to content

Commit

Permalink
fix some typo&remove insertTabletsInternalV1
Browse files Browse the repository at this point in the history
  • Loading branch information
neuyilan committed Jan 11, 2021
1 parent 8a8c094 commit 0b51d8b
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 55 deletions.
Expand Up @@ -44,8 +44,8 @@ public class InsertMultiTabletPlan extends InsertPlan {
* InsertTabletPlan is split to multi sub InsertTabletPlans. if the InsertTabletPlan have no
* parent plan, the value is zero;
* <p>
* suppose we originally have three InsertTabletPlans in one InsertMultiTabletPlan, then the initial
* InsertMultiTabletPlan would have the following two attributes:
* suppose we originally have three InsertTabletPlans in one InsertMultiTabletPlan, then the
* initial InsertMultiTabletPlan would have the following two attributes:
* <p>
* insertTabletPlanList={InsertTabletPlan_1,InsertTabletPlan_2,InsertTabletPlan_3}
* <p>
Expand Down Expand Up @@ -84,7 +84,7 @@ public class InsertMultiTabletPlan extends InsertPlan {
* this is usually used to back-propagate exceptions to the parent plan without losing their
* proper positions.
*/
List<Integer> parentInsetTablePlanIndexList;
List<Integer> parentInsertTabletPlanIndexList;

/**
* the InsertTabletPlan list
Expand All @@ -100,33 +100,33 @@ public class InsertMultiTabletPlan extends InsertPlan {
public InsertMultiTabletPlan() {
super(OperatorType.MULTI_BATCH_INSERT);
this.insertTabletPlanList = new ArrayList<>();
this.parentInsetTablePlanIndexList = new ArrayList<>();
this.parentInsertTabletPlanIndexList = new ArrayList<>();
}

public InsertMultiTabletPlan(List<InsertTabletPlan> insertTabletPlanList) {
super(OperatorType.MULTI_BATCH_INSERT);
this.insertTabletPlanList = insertTabletPlanList;
this.parentInsetTablePlanIndexList = new ArrayList<>();
this.parentInsertTabletPlanIndexList = new ArrayList<>();
}

public InsertMultiTabletPlan(List<InsertTabletPlan> insertTabletPlanList,
List<Integer> parentInsetTablePlanIndexList) {
List<Integer> parentInsertTabletPlanIndexList) {
super(OperatorType.MULTI_BATCH_INSERT);
this.insertTabletPlanList = insertTabletPlanList;
this.parentInsetTablePlanIndexList = parentInsetTablePlanIndexList;
this.parentInsertTabletPlanIndexList = parentInsertTabletPlanIndexList;
}

public void addInsertTabletPlan(InsertTabletPlan plan, Integer parentIndex) {
insertTabletPlanList.add(plan);
parentInsetTablePlanIndexList.add(parentIndex);
parentInsertTabletPlanIndexList.add(parentIndex);
}

public List<InsertTabletPlan> getInsertTabletPlanList() {
return insertTabletPlanList;
}

public List<Integer> getParentInsetTablePlanIndexList() {
return parentInsetTablePlanIndexList;
public List<Integer> getParentInsertTabletPlanIndexList() {
return parentInsertTabletPlanIndexList;
}


Expand All @@ -153,8 +153,8 @@ public long getMinTime() {
public long getMaxTime() {
long maxTime = Long.MIN_VALUE;
for (InsertTabletPlan insertTabletPlan : insertTabletPlanList) {
if (maxTime < insertTabletPlan.getMinTime()) {
maxTime = insertTabletPlan.getMinTime();
if (maxTime < insertTabletPlan.getMaxTime()) {
maxTime = insertTabletPlan.getMaxTime();
}
}
return maxTime;
Expand All @@ -180,7 +180,8 @@ public int getTotalRowCount() {
}

/**
* Gets the number of rows in the InsertTabletPlan of the index
* Gets the number of rows in the InsertTabletPlan of the index, zero will be returned if the
* index is out of bound.
*
* @param index the index of the insertTabletPlanList
* @return the total row count of the insertTabletPlanList.get(i)
Expand Down Expand Up @@ -208,10 +209,10 @@ public InsertTabletPlan getInsertTabletPlan(int index) {
* @return the parent's index in the parent InsertMultiTabletPlan
*/
public int getParentIndex(int index) {
if (index >= parentInsetTablePlanIndexList.size() || index < 0) {
if (index >= parentInsertTabletPlanIndexList.size() || index < 0) {
return -1;
}
return parentInsetTablePlanIndexList.get(index);
return parentInsertTabletPlanIndexList.get(index);
}

@Override
Expand All @@ -221,8 +222,8 @@ public void checkIntegrity() throws QueryProcessException {
}
}

public void setParentInsetTablePlanIndexList(List<Integer> parentInsetTablePlanIndexList) {
this.parentInsetTablePlanIndexList = parentInsetTablePlanIndexList;
public void setParentInsertTabletPlanIndexList(List<Integer> parentInsertTabletPlanIndexList) {
this.parentInsertTabletPlanIndexList = parentInsertTabletPlanIndexList;
}

public void setInsertTabletPlanList(List<InsertTabletPlan> insertTabletPlanList) {
Expand Down Expand Up @@ -250,8 +251,8 @@ public void serialize(ByteBuffer buffer) {
insertTabletPlan.subSerialize(buffer);
}

buffer.putInt(parentInsetTablePlanIndexList.size());
for (Integer index : parentInsetTablePlanIndexList) {
buffer.putInt(parentInsertTabletPlanIndexList.size());
for (Integer index : parentInsertTabletPlanIndexList) {
buffer.putInt(index);
}
}
Expand All @@ -265,8 +266,8 @@ public void serialize(DataOutputStream stream) throws IOException {
insertTabletPlan.subSerialize(stream);
}

stream.writeInt(parentInsetTablePlanIndexList.size());
for (Integer index : parentInsetTablePlanIndexList) {
stream.writeInt(parentInsertTabletPlanIndexList.size());
for (Integer index : parentInsertTabletPlanIndexList) {
stream.writeInt(index);
}
}
Expand All @@ -282,17 +283,17 @@ public void deserialize(ByteBuffer buffer) throws IllegalPathException {
}

int tmpParentInsetTablePlanIndexListSize = buffer.getInt();
this.parentInsetTablePlanIndexList = new ArrayList<>(tmpParentInsetTablePlanIndexListSize);
this.parentInsertTabletPlanIndexList = new ArrayList<>(tmpParentInsetTablePlanIndexListSize);
for (int i = 0; i < tmpParentInsetTablePlanIndexListSize; i++) {
this.parentInsetTablePlanIndexList.add(buffer.getInt());
this.parentInsertTabletPlanIndexList.add(buffer.getInt());
}
}

@Override
public String toString() {
return "InsertMultiTabletPlan{"
+ " insertTabletPlanList=" + insertTabletPlanList
+ ", parentInsetTablePlanIndexList=" + parentInsetTablePlanIndexList
+ ", parentInsetTablePlanIndexList=" + parentInsertTabletPlanIndexList
+ "}";
}

Expand All @@ -310,13 +311,13 @@ public boolean equals(Object o) {
if (!Objects.equals(insertTabletPlanList, that.insertTabletPlanList)) {
return false;
}
return Objects.equals(parentInsetTablePlanIndexList, that.parentInsetTablePlanIndexList);
return Objects.equals(parentInsertTabletPlanIndexList, that.parentInsertTabletPlanIndexList);
}

@Override
public int hashCode() {
int result = insertTabletPlanList != null ? insertTabletPlanList.hashCode() : 0;
result = 31 * result + (parentInsetTablePlanIndexList != null ? parentInsetTablePlanIndexList
result = 31 * result + (parentInsertTabletPlanIndexList != null ? parentInsertTabletPlanIndexList
.hashCode() : 0);
return result;
}
Expand Down
Expand Up @@ -1539,7 +1539,7 @@ public TSStatus insertTablets(TSInsertTabletsReq req) {
return RpcUtils.getStatus(TSStatusCode.NOT_LOGIN_ERROR);
}

return insertTabletsInternalV2(req);
return insertTabletsInternal(req);
} catch (NullPointerException e) {
logger.error("{}: error occurs when insertTablets", IoTDBConstant.GLOBAL_DB_NAME, e);
return RpcUtils.getStatus(TSStatusCode.EXECUTE_STATEMENT_ERROR);
Expand Down Expand Up @@ -1567,37 +1567,10 @@ private InsertTabletPlan constructInsertTabletPlan(TSInsertTabletsReq req, int i
return insertTabletPlan;
}

/**
* process the TSInsertTabletsReq by Split it into many InsertTabletPlan
*/
public TSStatus insertTabletsInternalV1(TSInsertTabletsReq req) throws IllegalPathException {
List<TSStatus> statusList = new ArrayList<>();
for (int i = 0; i < req.deviceIds.size(); i++) {
InsertTabletPlan insertTabletPlan = constructInsertTabletPlan(req, i);
TSStatus status = checkAuthority(insertTabletPlan, req.getSessionId());
if (status == null) {
status = executeNonQueryPlan(insertTabletPlan);
}
statusList.add(status);
}

boolean isAllSuccessful = true;
for (TSStatus subStatus : statusList) {
isAllSuccessful =
((subStatus.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode())
&& isAllSuccessful);
}

if (!isAllSuccessful) {
return RpcUtils.getStatus(statusList);
}
return RpcUtils.getStatus(TSStatusCode.SUCCESS_STATUS);
}

/**
* construct one InsertMultiTabletPlan and process it
*/
public TSStatus insertTabletsInternalV2(TSInsertTabletsReq req)
public TSStatus insertTabletsInternal(TSInsertTabletsReq req)
throws IllegalPathException {
List<InsertTabletPlan> insertTabletPlanList = new ArrayList<>();
InsertMultiTabletPlan insertMultiTabletPlan = new InsertMultiTabletPlan();
Expand Down

0 comments on commit 0b51d8b

Please sign in to comment.