Skip to content

Commit

Permalink
spotless
Browse files Browse the repository at this point in the history
  • Loading branch information
lancelly committed Jun 20, 2024
1 parent eed9976 commit 7c0ee09
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public MPPQueryContext(QueryId queryId) {
this.queryId = queryId;
this.endPointBlackList = new LinkedList<>();
this.memoryReservationContext =
new UnsynchronizedMemoryReservationContext(queryId, "MPPQueryContext");
new UnsynchronizedMemoryReservationContext(queryId, this.getClass().getName());
}

// TODO too many callers just pass a null SessionInfo which should be forbidden
Expand Down Expand Up @@ -318,7 +318,7 @@ public void releaseAllMemoryReservedForFrontEnd() {
this.memoryReservationContext.releaseAllReservedMemory();
}

public void releaseAllMemoryReservedForFrontEnd(final long bytes) {
public void releaseMemoryReservedForFrontEnd(final long bytes) {
this.memoryReservationContext.releaseMemoryAccumulatively(bytes);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import org.apache.iotdb.db.queryengine.metric.QueryRelatedResourceMetricSet;
import org.apache.iotdb.db.queryengine.metric.SeriesScanCostMetricSet;
import org.apache.iotdb.db.queryengine.plan.planner.memory.MemoryReservationContext;
import org.apache.iotdb.db.queryengine.plan.planner.memory.UnsynchronizedMemoryReservationContext;
import org.apache.iotdb.db.queryengine.plan.planner.memory.SynchronizedMemoryReservationContext;
import org.apache.iotdb.db.queryengine.plan.planner.plan.TimePredicate;
import org.apache.iotdb.db.storageengine.dataregion.IDataRegionForQuery;
import org.apache.iotdb.db.storageengine.dataregion.read.IQueryDataSource;
Expand Down Expand Up @@ -198,7 +198,7 @@ private FragmentInstanceContext(
this.dataNodeQueryContextMap = dataNodeQueryContextMap;
this.dataNodeQueryContext = dataNodeQueryContextMap.get(id.getQueryId());
this.memoryReservationContext =
new UnsynchronizedMemoryReservationContext(id.getQueryId(), "FragmentInstanceContext");
new SynchronizedMemoryReservationContext(id.getQueryId(), this.getClass().getName());
}

private FragmentInstanceContext(
Expand All @@ -210,7 +210,7 @@ private FragmentInstanceContext(
this.dataNodeQueryContextMap = null;
this.dataNodeQueryContext = null;
this.memoryReservationContext =
new UnsynchronizedMemoryReservationContext(id.getQueryId(), "FragmentInstanceContext");
new SynchronizedMemoryReservationContext(id.getQueryId(), this.getClass().getName());
}

private FragmentInstanceContext(
Expand All @@ -227,7 +227,7 @@ private FragmentInstanceContext(
this.globalTimeFilter = globalTimeFilter;
this.dataNodeQueryContextMap = null;
this.memoryReservationContext =
new UnsynchronizedMemoryReservationContext(id.getQueryId(), "FragmentInstanceContext");
new SynchronizedMemoryReservationContext(id.getQueryId(), this.getClass().getName());
}

@TestOnly
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -676,7 +676,7 @@ public Set<Expression> getAggregationExpressions() {
}

public void releaseMemoryForFrontEnd(final long bytes) {
this.context.releaseAllMemoryReservedForFrontEnd(bytes);
this.context.releaseMemoryReservedForFrontEnd(bytes);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ public UnsynchronizedMemoryReservationContext(final QueryId queryId, final Strin

@Override
public void reserveMemoryAccumulatively(final long size) {
this.bytesToBeReserved += size;
if (this.bytesToBeReserved >= MEMORY_BATCH_THRESHOLD) {
bytesToBeReserved += size;
if (bytesToBeReserved >= MEMORY_BATCH_THRESHOLD) {
reserveMemoryImmediately();
}
}
Expand All @@ -57,25 +57,25 @@ public void reserveMemoryImmediately() {
if (bytesToBeReserved != 0) {
LOCAL_EXECUTION_PLANNER.reserveFromFreeMemoryForOperators(
bytesToBeReserved, reservedBytesInTotal, queryId.getId(), contextHolder);
this.reservedBytesInTotal += bytesToBeReserved;
this.bytesToBeReserved = 0;
reservedBytesInTotal += bytesToBeReserved;
bytesToBeReserved = 0;
}
}

@Override
public void releaseMemoryAccumulatively(final long size) {
this.bytesToBeReleased += size;
bytesToBeReleased += size;
if (bytesToBeReleased >= MEMORY_BATCH_THRESHOLD) {
long bytesToRelease;
if (this.bytesToBeReleased <= bytesToBeReserved) {
bytesToBeReserved -= this.bytesToBeReleased;
if (bytesToBeReleased <= bytesToBeReserved) {
bytesToBeReserved -= bytesToBeReleased;
} else {
bytesToRelease = this.bytesToBeReleased - bytesToBeReserved;
bytesToRelease = bytesToBeReleased - bytesToBeReserved;
bytesToBeReserved = 0;
LOCAL_EXECUTION_PLANNER.releaseToFreeMemoryForOperators(bytesToRelease);
reservedBytesInTotal -= bytesToRelease;
}
this.bytesToBeReleased = 0;
bytesToBeReleased = 0;
}
}

Expand Down

0 comments on commit 7c0ee09

Please sign in to comment.