chore: revert the code change
This commit is contained in:
parent
b8b91eb124
commit
834c9edad8
|
@ -758,24 +758,28 @@ static int doBinarySearchKey(TSKEY* keyList, int num, int pos, TSKEY key, int or
|
||||||
s = pos;
|
s = pos;
|
||||||
|
|
||||||
// check
|
// check
|
||||||
assert(pos >= 0 && pos < num);
|
assert(pos >=0 && pos < num);
|
||||||
assert(num > 0);
|
assert(num > 0);
|
||||||
|
|
||||||
if (order == TSDB_ORDER_ASC) {
|
if (order == TSDB_ORDER_ASC) {
|
||||||
// find the first position which is smaller than the key
|
// find the first position which is smaller than the key
|
||||||
e = num - 1;
|
e = num - 1;
|
||||||
if (key < keyList[pos]) return -1;
|
if (key < keyList[pos])
|
||||||
|
return -1;
|
||||||
while (1) {
|
while (1) {
|
||||||
// check can return
|
// check can return
|
||||||
if (key >= keyList[e]) return e;
|
if (key >= keyList[e])
|
||||||
if (key <= keyList[s]) return s;
|
return e;
|
||||||
if (e - s <= 1) return s;
|
if (key <= keyList[s])
|
||||||
|
return s;
|
||||||
|
if (e - s <= 1)
|
||||||
|
return s;
|
||||||
|
|
||||||
// change start or end position
|
// change start or end position
|
||||||
int mid = s + (e - s + 1) / 2;
|
int mid = s + (e - s + 1)/2;
|
||||||
if (keyList[mid] > key)
|
if (keyList[mid] > key)
|
||||||
e = mid;
|
e = mid;
|
||||||
else if (keyList[mid] < key)
|
else if(keyList[mid] < key)
|
||||||
s = mid;
|
s = mid;
|
||||||
else
|
else
|
||||||
return mid;
|
return mid;
|
||||||
|
@ -783,18 +787,22 @@ static int doBinarySearchKey(TSKEY* keyList, int num, int pos, TSKEY key, int or
|
||||||
} else { // DESC
|
} else { // DESC
|
||||||
// find the first position which is bigger than the key
|
// find the first position which is bigger than the key
|
||||||
e = 0;
|
e = 0;
|
||||||
if (key > keyList[pos]) return -1;
|
if (key > keyList[pos])
|
||||||
|
return -1;
|
||||||
while (1) {
|
while (1) {
|
||||||
// check can return
|
// check can return
|
||||||
if (key <= keyList[e]) return e;
|
if (key <= keyList[e])
|
||||||
if (key >= keyList[s]) return s;
|
return e;
|
||||||
if (s - e <= 1) return s;
|
if (key >= keyList[s])
|
||||||
|
return s;
|
||||||
|
if (s - e <= 1)
|
||||||
|
return s;
|
||||||
|
|
||||||
// change start or end position
|
// change start or end position
|
||||||
int mid = s - (s - e + 1) / 2;
|
int mid = s - (s - e + 1)/2;
|
||||||
if (keyList[mid] < key)
|
if (keyList[mid] < key)
|
||||||
e = mid;
|
e = mid;
|
||||||
else if (keyList[mid] > key)
|
else if(keyList[mid] > key)
|
||||||
s = mid;
|
s = mid;
|
||||||
else
|
else
|
||||||
return mid;
|
return mid;
|
||||||
|
@ -841,8 +849,8 @@ static int32_t copyBlockDataToSDataBlock(STsdbReader* pReader, STableBlockScanIn
|
||||||
} else if (!asc && pReader->window.ekey >= pBlock->maxKey.ts) {
|
} else if (!asc && pReader->window.ekey >= pBlock->maxKey.ts) {
|
||||||
pDumpInfo->rowIndex = pBlock->nRow - 1;
|
pDumpInfo->rowIndex = pBlock->nRow - 1;
|
||||||
} else {
|
} else {
|
||||||
int32_t pos = asc ? pBlock->nRow - 1 : 0;
|
int32_t pos = asc? pBlock->nRow-1:0;
|
||||||
int32_t order = (pReader->order == TSDB_ORDER_ASC) ? TSDB_ORDER_DESC : TSDB_ORDER_ASC;
|
int32_t order = (pReader->order == TSDB_ORDER_ASC)? TSDB_ORDER_DESC:TSDB_ORDER_ASC;
|
||||||
pDumpInfo->rowIndex = doBinarySearchKey(pBlockData->aTSKEY, pBlock->nRow, pos, pReader->window.skey, order);
|
pDumpInfo->rowIndex = doBinarySearchKey(pBlockData->aTSKEY, pBlock->nRow, pos, pReader->window.skey, order);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -930,7 +938,7 @@ static int32_t copyBlockDataToSDataBlock(STsdbReader* pReader, STableBlockScanIn
|
||||||
int64_t ts = pBlockData->aTSKEY[pDumpInfo->rowIndex];
|
int64_t ts = pBlockData->aTSKEY[pDumpInfo->rowIndex];
|
||||||
setBlockAllDumped(pDumpInfo, ts, pReader->order);
|
setBlockAllDumped(pDumpInfo, ts, pReader->order);
|
||||||
} else {
|
} else {
|
||||||
int64_t k = asc ? pBlock->maxKey.ts : pBlock->minKey.ts;
|
int64_t k = asc? pBlock->maxKey.ts:pBlock->minKey.ts;
|
||||||
setBlockAllDumped(pDumpInfo, k, pReader->order);
|
setBlockAllDumped(pDumpInfo, k, pReader->order);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -940,8 +948,8 @@ static int32_t copyBlockDataToSDataBlock(STsdbReader* pReader, STableBlockScanIn
|
||||||
int32_t unDumpedRows = asc ? pBlock->nRow - pDumpInfo->rowIndex : pDumpInfo->rowIndex + 1;
|
int32_t unDumpedRows = asc ? pBlock->nRow - pDumpInfo->rowIndex : pDumpInfo->rowIndex + 1;
|
||||||
tsdbDebug("%p copy file block to sdatablock, global index:%d, table index:%d, brange:%" PRId64 "-%" PRId64
|
tsdbDebug("%p copy file block to sdatablock, global index:%d, table index:%d, brange:%" PRId64 "-%" PRId64
|
||||||
", rows:%d, remain:%d, minVer:%" PRId64 ", maxVer:%" PRId64 ", elapsed time:%.2f ms, %s",
|
", rows:%d, remain:%d, minVer:%" PRId64 ", maxVer:%" PRId64 ", elapsed time:%.2f ms, %s",
|
||||||
pReader, pBlockIter->index, pBlockInfo->tbBlockIdx, pBlock->minKey.ts, pBlock->maxKey.ts, remain,
|
pReader, pBlockIter->index, pBlockInfo->tbBlockIdx, pBlock->minKey.ts, pBlock->maxKey.ts, remain, unDumpedRows,
|
||||||
unDumpedRows, pBlock->minVer, pBlock->maxVer, elapsedTime, pReader->idStr);
|
pBlock->minVer, pBlock->maxVer, elapsedTime, pReader->idStr);
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -2249,6 +2257,7 @@ static int32_t buildComposedDataBlock(STsdbReader* pReader) {
|
||||||
SBlockData* pBlockData = &pReader->status.fileBlockData;
|
SBlockData* pBlockData = &pReader->status.fileBlockData;
|
||||||
int32_t step = ASCENDING_TRAVERSE(pReader->order) ? 1 : -1;
|
int32_t step = ASCENDING_TRAVERSE(pReader->order) ? 1 : -1;
|
||||||
|
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
// todo check the validate of row in file block
|
// todo check the validate of row in file block
|
||||||
bool hasBlockData = false;
|
bool hasBlockData = false;
|
||||||
|
@ -2290,7 +2299,7 @@ static int32_t buildComposedDataBlock(STsdbReader* pReader) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_end:
|
_end:
|
||||||
pResBlock->info.uid = pBlockScanInfo->uid;
|
pResBlock->info.uid = pBlockScanInfo->uid;
|
||||||
blockDataUpdateTsWindow(pResBlock, 0);
|
blockDataUpdateTsWindow(pResBlock, 0);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue