Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix memory page offsets error
Browse files Browse the repository at this point in the history
shizy818 committed Dec 5, 2024
1 parent cfc9e74 commit cd3f7d9
Showing 2 changed files with 7 additions and 17 deletions.
Original file line number Diff line number Diff line change
@@ -159,17 +159,15 @@ private void updateChunkAndPageStatisticsFromTvLists() {
List<TVList> tvLists = new ArrayList<>(tvListQueryMap.keySet());
MergeSortTvListIterator timeValuePairIterator =
new MergeSortTvListIterator(dataType, encoding, floatPrecision, tvLists);
int[] tvListOffsets = timeValuePairIterator.getTVListOffsets();
while (timeValuePairIterator.hasNextTimeValuePair()) {
int[] tvListOffsetsBeforeNext = timeValuePairIterator.getLastTVListOffsets();
if (cnt % MAX_NUMBER_OF_POINTS_IN_PAGE == 0) {
Statistics stats = Statistics.getStatsByType(dataType);
pageStatisticsList.add(stats);
pageOffsetsList.add(Arrays.copyOf(tvListOffsets, tvListOffsets.length));
}
TimeValuePair tvPair = timeValuePairIterator.nextTimeValuePair();
if (!isPointDeleted(tvPair.getTimestamp(), deletionList, deleteCursor)) {
if (cnt % MAX_NUMBER_OF_POINTS_IN_PAGE == 0) {
Statistics stats = Statistics.getStatsByType(dataType);
pageStatisticsList.add(stats);
pageOffsetsList.add(
Arrays.copyOf(tvListOffsetsBeforeNext, tvListOffsetsBeforeNext.length));
}

Statistics pageStatistics = pageStatisticsList.get(pageStatisticsList.size() - 1);
switch (dataType) {
case BOOLEAN:
@@ -204,8 +202,8 @@ private void updateChunkAndPageStatisticsFromTvLists() {
// do nothing
}
pageStatistics.setEmpty(false);
cnt++;
}
cnt++;
}
chunkStatistics.setEmpty(cnt == 0);
}
Original file line number Diff line number Diff line change
@@ -40,7 +40,6 @@ public class MergeSortTvListIterator implements IPointReader {
private TimeValuePair currentTvPair;

private final int[] tvListOffsets;
private final int[] lastTvListOffsets;

public MergeSortTvListIterator(TSDataType tsDataType, List<TVList> tvLists) {
this.tsDataType = tsDataType;
@@ -49,7 +48,6 @@ public MergeSortTvListIterator(TSDataType tsDataType, List<TVList> tvLists) {
tvListIterators.add(tvList.iterator());
}
this.tvListOffsets = new int[tvLists.size()];
this.lastTvListOffsets = new int[tvLists.size()];
}

public MergeSortTvListIterator(
@@ -90,15 +88,13 @@ public TimeValuePair nextTimeValuePair() {
if (!hasNextTimeValuePair()) {
return null;
}
lastTvListOffsets[selectedTVListIndex] = tvListIterators.get(selectedTVListIndex).getIndex();
currentTvPair = tvListIterators.get(selectedTVListIndex).next();
tvListOffsets[selectedTVListIndex] = tvListIterators.get(selectedTVListIndex).getIndex();

// call next to skip identical timestamp in other iterators
for (int i = 0; i < tvListIterators.size(); i++) {
TimeValuePair tvPair = tvListIterators.get(i).current();
if (tvPair != null && tvPair.getTimestamp() == currentTvPair.getTimestamp()) {
lastTvListOffsets[i] = tvListIterators.get(i).getIndex();
tvListIterators.get(i).next();
tvListOffsets[i] = tvListIterators.get(i).getIndex();
}
@@ -143,10 +139,6 @@ public void close() throws IOException {
tvListIterators.clear();
}

public int[] getLastTVListOffsets() {
return lastTvListOffsets;
}

public int[] getTVListOffsets() {
return tvListOffsets;
}

0 comments on commit cd3f7d9

Please sign in to comment.