Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 @@ -118,7 +118,15 @@ public void sortTvLists() {
AlignedTVList alignedTvList = (AlignedTVList) entry.getKey();
int queryRowCount = entry.getValue();
if (!alignedTvList.isSorted() && queryRowCount > alignedTvList.seqRowCount()) {
alignedTvList.sort();
// sort() returns the current row count
// TVList may grow between prepareTvListMapForQuery and actual query execution(now).
// The queryRowCount recorded here is only a snapshot taken during prepareTvListMapForQuery
// phase.
// Additional written rows that are not covered by the original queryRowCount can be
// involved in current sort operation.
// We must update queryRowCount here, otherwise, it may be used later to build
// BitMaps, causing bitmap array size mismatch and possible out of bound.
entry.setValue(alignedTvList.sort());
long alignedTvListRamSize = alignedTvList.calculateRamSize();
alignedTvList.lockQueryList();
try {
Expand Down Expand Up @@ -375,7 +383,7 @@ public IPointReader getPointReader() {
AlignedTVList alignedTvList = (AlignedTVList) entry.getKey();
int queryLength = entry.getValue();
if (!alignedTvList.isSorted() && queryLength > alignedTvList.seqRowCount()) {
alignedTvList.sort();
entry.setValue(alignedTvList.sort());
long alignedTvListRamSize = alignedTvList.calculateRamSize();
alignedTvList.lockQueryList();
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public void sortTvLists() {
TVList tvList = entry.getKey();
int queryRowCount = entry.getValue();
if (!tvList.isSorted() && queryRowCount > tvList.seqRowCount()) {
tvList.sort();
entry.setValue(tvList.sort());
long tvListRamSize = tvList.calculateRamSize();
tvList.lockQueryList();
try {
Expand Down Expand Up @@ -289,7 +289,7 @@ public IPointReader getPointReader() {
TVList tvList = entry.getKey();
int queryLength = entry.getValue();
if (!tvList.isSorted() && queryLength > tvList.seqRowCount()) {
tvList.sort();
entry.setValue(tvList.sort());
long tvListRamSize = tvList.calculateRamSize();
tvList.lockQueryList();
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1599,6 +1599,10 @@ public boolean isTimeDeleted(int index, boolean needConvertIndex) {
}

public BitMap getAllValueColDeletedMap() {
return getAllValueColDeletedMap(rowCount);
}

public BitMap getAllValueColDeletedMap(int rowCount) {
// row exists when any column value exists
if (bitMaps == null) {
return null;
Expand Down Expand Up @@ -1768,7 +1772,7 @@ public AlignedTVListIterator(
(columnIndexList == null)
? IntStream.range(0, dataTypes.size()).boxed().collect(Collectors.toList())
: columnIndexList;
this.allValueColDeletedMap = ignoreAllNullRows ? getAllValueColDeletedMap() : null;
this.allValueColDeletedMap = ignoreAllNullRows ? getAllValueColDeletedMap(this.rows) : null;
this.floatPrecision = floatPrecision != null ? floatPrecision : 0;
this.encodingList = encodingList;
this.timeColumnDeletion = timeColumnDeletion;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,13 @@ public class BackAlignedTVList extends QuickAlignedTVList {
}

@Override
public synchronized void sort() {
public synchronized int sort() {
if (!sorted) {
policy.backwardSort(timestamps, rowCount);
policy.clearTmp();
}
sorted = true;
seqRowCount = rowCount;
return rowCount;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,13 @@ public class BackBinaryTVList extends QuickBinaryTVList {
}

@Override
public synchronized void sort() {
public synchronized int sort() {
if (!sorted) {
policy.backwardSort(timestamps, rowCount);
policy.clearTmp();
}
sorted = true;
seqRowCount = rowCount;
return rowCount;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,13 @@ public class BackBooleanTVList extends QuickBooleanTVList {
}

@Override
public synchronized void sort() {
public synchronized int sort() {
if (!sorted) {
policy.backwardSort(timestamps, rowCount);
policy.clearTmp();
}
sorted = true;
seqRowCount = rowCount;
return rowCount;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,13 @@ public class BackDoubleTVList extends QuickDoubleTVList {
}

@Override
public synchronized void sort() {
public synchronized int sort() {
if (!sorted) {
policy.backwardSort(timestamps, rowCount);
policy.clearTmp();
}
sorted = true;
seqRowCount = rowCount;
return rowCount;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,13 @@ public class BackFloatTVList extends QuickFloatTVList {
}

@Override
public synchronized void sort() {
public synchronized int sort() {
if (!sorted) {
policy.backwardSort(timestamps, rowCount);
policy.clearTmp();
}
sorted = true;
seqRowCount = rowCount;
return rowCount;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,13 @@ public class BackIntTVList extends QuickIntTVList {
}

@Override
public synchronized void sort() {
public synchronized int sort() {
if (!sorted) {
policy.backwardSort(timestamps, rowCount);
policy.clearTmp();
}
sorted = true;
seqRowCount = rowCount;
return rowCount;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,13 @@ public class BackLongTVList extends QuickLongTVList {
}

@Override
public synchronized void sort() {
public synchronized int sort() {
if (!sorted) {
policy.backwardSort(timestamps, rowCount);
policy.clearTmp();
}
sorted = true;
seqRowCount = rowCount;
return rowCount;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,12 @@ public class QuickAlignedTVList extends AlignedTVList {
}

@Override
public synchronized void sort() {
public synchronized int sort() {
if (!sorted) {
policy.qsort(0, rowCount - 1);
}
sorted = true;
seqRowCount = rowCount;
return rowCount;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,12 @@ public class QuickBinaryTVList extends BinaryTVList {
}

@Override
public synchronized void sort() {
public synchronized int sort() {
if (!sorted) {
policy.qsort(0, rowCount - 1);
}
sorted = true;
seqRowCount = rowCount;
return rowCount;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,12 @@ public class QuickBooleanTVList extends BooleanTVList {
}

@Override
public synchronized void sort() {
public synchronized int sort() {
if (!sorted) {
policy.qsort(0, rowCount - 1);
}
sorted = true;
seqRowCount = rowCount;
return rowCount;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,12 @@ public class QuickDoubleTVList extends DoubleTVList {
}

@Override
public synchronized void sort() {
public synchronized int sort() {
if (!sorted) {
policy.qsort(0, rowCount - 1);
}
sorted = true;
seqRowCount = rowCount;
return rowCount;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,12 @@ public class QuickFloatTVList extends FloatTVList {
}

@Override
public synchronized void sort() {
public synchronized int sort() {
if (!sorted) {
policy.qsort(0, rowCount - 1);
}
sorted = true;
seqRowCount = rowCount;
return rowCount;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,12 @@ public class QuickIntTVList extends IntTVList {
}

@Override
public synchronized void sort() {
public synchronized int sort() {
if (!sorted) {
policy.qsort(0, rowCount - 1);
}
sorted = true;
seqRowCount = rowCount;
return rowCount;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,12 @@ public class QuickLongTVList extends LongTVList {
}

@Override
public synchronized void sort() {
public synchronized int sort() {
if (!sorted) {
policy.qsort(0, rowCount - 1);
}
sorted = true;
seqRowCount = rowCount;
return rowCount;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ public long getReservedMemoryBytes() {
return reservedMemoryBytes;
}

public abstract void sort();
public abstract int sort();

public void increaseReferenceCount() {
referenceCount.incrementAndGet();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public class TimAlignedTVList extends AlignedTVList {
}

@Override
public synchronized void sort() {
public synchronized int sort() {
policy.checkSortedTimestampsAndIndices();
if (!sorted) {
policy.sort(0, rowCount);
Expand All @@ -40,6 +40,7 @@ public synchronized void sort() {
policy.clearSortedTime();
sorted = true;
seqRowCount = rowCount;
return rowCount;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class TimBinaryTVList extends BinaryTVList {
}

@Override
public synchronized void sort() {
public synchronized int sort() {
policy.checkSortedTimestampsAndIndices();
if (!sorted) {
policy.sort(0, rowCount);
Expand All @@ -35,6 +35,7 @@ public synchronized void sort() {
policy.clearSortedTime();
sorted = true;
seqRowCount = rowCount;
return rowCount;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class TimBooleanTVList extends BooleanTVList {
}

@Override
public synchronized void sort() {
public synchronized int sort() {
policy.checkSortedTimestampsAndIndices();
if (!sorted) {
policy.sort(0, rowCount);
Expand All @@ -35,6 +35,7 @@ public synchronized void sort() {
policy.clearSortedTime();
sorted = true;
seqRowCount = rowCount;
return rowCount;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class TimDoubleTVList extends DoubleTVList {
}

@Override
public synchronized void sort() {
public synchronized int sort() {
policy.checkSortedTimestampsAndIndices();
if (!sorted) {
policy.sort(0, rowCount);
Expand All @@ -35,6 +35,7 @@ public synchronized void sort() {
policy.clearSortedTime();
sorted = true;
seqRowCount = rowCount;
return rowCount;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class TimFloatTVList extends FloatTVList {
}

@Override
public synchronized void sort() {
public synchronized int sort() {
policy.checkSortedTimestampsAndIndices();
if (!sorted) {
policy.sort(0, rowCount);
Expand All @@ -35,6 +35,7 @@ public synchronized void sort() {
policy.clearSortedTime();
sorted = true;
seqRowCount = rowCount;
return rowCount;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public class TimIntTVList extends IntTVList {
}

@Override
public synchronized void sort() {
public synchronized int sort() {
policy.checkSortedTimestampsAndIndices();
if (!sorted) {
policy.sort(0, rowCount);
Expand All @@ -42,6 +42,7 @@ public synchronized void sort() {
policy.clearSortedTime();
sorted = true;
seqRowCount = rowCount;
return rowCount;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class TimLongTVList extends LongTVList {
}

@Override
public synchronized void sort() {
public synchronized int sort() {
policy.checkSortedTimestampsAndIndices();
if (!sorted) {
policy.sort(0, rowCount);
Expand All @@ -35,6 +35,7 @@ public synchronized void sort() {
policy.clearSortedTime();
sorted = true;
seqRowCount = rowCount;
return rowCount;
}

@Override
Expand Down
Loading
Loading