Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unaligned tvlist feat #14265

Closed
wants to merge 30 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
ef5de53
null bitmap for int tvlist
shizy818 Nov 27, 2024
7a15073
update min/max timestamp and sequential part of tvlist during insert
shizy818 Nov 30, 2024
c28fe3f
mutable & immutable tvlists in writable memchunk
shizy818 Dec 1, 2024
6df2e10
copy-on-write array list
shizy818 Dec 1, 2024
435d5da
review comments part 1
shizy818 Dec 3, 2024
d5fad22
fix unit test errors
shizy818 Dec 3, 2024
402c869
review comments part 2
shizy818 Dec 4, 2024
5aaa59b
push down global time filter
shizy818 Dec 5, 2024
cfc9e74
fix MemPageReaderTest case
shizy818 Dec 5, 2024
cd3f7d9
fix memory page offsets error
shizy818 Dec 5, 2024
e3d2d5e
synchronized sort & MergeSortTvListIterator bug
shizy818 Dec 6, 2024
73e9f83
tvlist_sort_threshold config property
shizy818 Dec 7, 2024
0545ff1
bug fix:
shizy818 Dec 11, 2024
2fcdcdb
optimize TVListIterator & MergeSortTvListIterator
shizy818 Dec 11, 2024
45db409
retrofit encode when tvlist_sort_threshold is zero
shizy818 Dec 13, 2024
9411fea
delay sort & statistic generation to query execution
shizy818 Dec 11, 2024
e3346d3
fix: skip deleted data during encode
shizy818 Dec 13, 2024
8e0f8e5
aligned time series part
shizy818 Dec 16, 2024
6eedcf6
fix: MemAlignedChunkReader page offset
shizy818 Dec 18, 2024
0a9c4ed
performance issue:
shizy818 Dec 17, 2024
9b0a6f8
fix: memory chunk reader may read more points than expected in one page
shizy818 Dec 23, 2024
23bf1f7
update chunk & page statistic for aligend memchunk by column
shizy818 Dec 21, 2024
298e16c
revert: getAlignedValueForQuery
shizy818 Dec 24, 2024
359929d
fix: * CopyOnWriteArrayList for AlignedTVList bitmaps
shizy818 Dec 25, 2024
6817370
refactor: Tim/Quick/Backward TVList
shizy818 Dec 25, 2024
a8beea5
refactor: synchronized tvlist method: sort, putXXX
shizy818 Dec 25, 2024
6369293
refactor: change list to array in AlignedTVList iterator
shizy818 Dec 25, 2024
a80bcc0
revert: remove CopyOnWriteArrayList
shizy818 Dec 26, 2024
3e0b904
refactor: clone MergeSort iterator from ReadOnlyChunk
shizy818 Dec 27, 2024
ca08605
fix: clone working tvlist during flush if there is query on it
shizy818 Dec 28, 2024
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 @@ -430,6 +430,9 @@ public class IoTDBConfig {
/** The sort algorithm used in TVList */
private TVListSortAlgorithm tvListSortAlgorithm = TVListSortAlgorithm.TIM;

/** the threshold when working TVList is sorted and handover in writable memtable */
private int tvListSortThreshold = 0;

/** When average series point number reaches this, flush the memtable to disk */
private int avgSeriesPointNumberThreshold = 100000;

Expand Down Expand Up @@ -2309,6 +2312,14 @@ public void setTvListSortAlgorithm(TVListSortAlgorithm tvListSortAlgorithm) {
this.tvListSortAlgorithm = tvListSortAlgorithm;
}

public int getTvListSortThreshold() {
return tvListSortThreshold;
}

public void setTVListSortThreshold(int tvListSortThreshold) {
this.tvListSortThreshold = tvListSortThreshold;
}

public int getAvgSeriesPointNumberThreshold() {
return avgSeriesPointNumberThreshold;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,14 @@ public void loadProperties(TrimProperties properties) throws BadNodeUrlException
.map(String::trim)
.orElse(conf.getTvListSortAlgorithm().toString())));

conf.setTVListSortThreshold(
Integer.parseInt(
Optional.ofNullable(
properties.getProperty(
"tvlist_sort_threshold", Integer.toString(conf.getTvListSortThreshold())))
.map(String::trim)
.orElse(Integer.toString(conf.getTvListSortThreshold()))));

conf.setAvgSeriesPointNumberThreshold(
Integer.parseInt(
Optional.ofNullable(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import org.apache.iotdb.db.storageengine.dataregion.read.QueryDataSourceType;
import org.apache.iotdb.db.storageengine.dataregion.read.control.FileReaderManager;
import org.apache.iotdb.db.storageengine.dataregion.tsfile.TsFileResource;
import org.apache.iotdb.db.utils.datastructure.TVList;
import org.apache.iotdb.mpp.rpc.thrift.TFetchFragmentInstanceStatisticsResp;

import org.apache.tsfile.file.metadata.IDeviceID;
Expand Down Expand Up @@ -649,6 +650,35 @@ public void releaseResourceWhenAllDriversAreClosed() {
releaseResource();
}

private void releaseTVListOwnedByQuery() {
for (TVList tvList : tvListSet) {
tvList.lockQueryList();
List<QueryContext> queryContextList = tvList.getQueryContextList();
try {
queryContextList.remove(this);
if (tvList.getOwnerQuery() == this) {
tvList.setOwnerQuery(null);
if (queryContextList.isEmpty()) {
LOGGER.debug(
"TVList {} is released by the query, FragmentInstance Id is {}",
tvList,
this.getId());
tvList.clear();
shizy818 marked this conversation as resolved.
Show resolved Hide resolved
memoryReservationManager.releaseMemoryCumulatively(tvList.calculateRamSize());
} else {
LOGGER.debug(
"TVList {} is owned by another query, FragmentInstance Id is {}",
tvList,
((FragmentInstanceContext) queryContextList.get(0)).getId());
tvList.setOwnerQuery(queryContextList.get(0));
}
}
} finally {
tvList.unlockQueryList();
}
}
}

/**
* All file paths used by this fragment instance must be cleared and thus the usage reference must
* be decreased.
Expand All @@ -669,6 +699,9 @@ public synchronized void releaseResource() {
unClosedFilePaths = null;
}

// release TVList/AlignedTVList owned by current query
releaseTVListOwnedByQuery();

dataRegion = null;
globalTimeFilter = null;
sharedQueryDataSource = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,18 @@
import org.apache.iotdb.db.storageengine.dataregion.tsfile.TsFileID;
import org.apache.iotdb.db.storageengine.dataregion.tsfile.TsFileResource;
import org.apache.iotdb.db.utils.ModificationUtils;
import org.apache.iotdb.db.utils.datastructure.AlignedTVList;
import org.apache.iotdb.db.utils.datastructure.PatternTreeMapFactory;
import org.apache.iotdb.db.utils.datastructure.PatternTreeMapFactory.ModsSerializer;
import org.apache.iotdb.db.utils.datastructure.TVList;

import org.apache.tsfile.file.metadata.IDeviceID;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
Expand Down Expand Up @@ -71,6 +74,9 @@ public class QueryContext {

private final Set<TsFileID> nonExistentModFiles = new CopyOnWriteArraySet<>();

// accessed tvlists for the query
protected final Set<TVList> tvListSet = new HashSet<>();

public QueryContext() {}

public QueryContext(long queryId) {
Expand Down Expand Up @@ -206,4 +212,12 @@ public boolean isIgnoreAllNullRows() {
public void setIgnoreAllNullRows(boolean ignoreAllNullRows) {
this.ignoreAllNullRows = ignoreAllNullRows;
}

public void addTVListToSet(Map<TVList, Integer> tvListMap) {
tvListSet.addAll(tvListMap.keySet());
}

public void addAlignedTVListToSet(Map<AlignedTVList, Integer> alignedTvListMap) {
tvListSet.addAll(alignedTvListMap.keySet());
}
}
Loading
Loading