日本熟妇hd丰满老熟妇,中文字幕一区二区三区在线不卡 ,亚洲成片在线观看,免费女同在线一区二区

文檔

并發導出數據

更新時間:

當使用場景中不關心整個結果集的順序時,您可以使用并發導出數據功能以更快的速度將命中的數據全部返回。

前提條件

參數

參數

說明

tableName

數據表名稱。

indexName

多元索引名稱。

scanQuery

query

多元索引的查詢語句。支持精確查詢、模糊查詢、范圍查詢、地理位置查詢、嵌套查詢等,功能和Search接口一致。

limit

掃描數據時一次能返回的數據行數。

maxParallel

最大并發數。請求支持的最大并發數由用戶數據量決定。數據量越大,支持的并發數越多,每次任務前可以通過ComputeSplits API進行獲取。

currentParallelId

當前并發ID。取值范圍為[0, maxParallel)。

token

用于翻頁功能。ParallelScan請求結果中有下一次進行翻頁的token,使用該token可以接著上一次的結果繼續讀取數據。

aliveTime

ParallelScan的當前任務有效時間,也是token的有效時間。默認值為60,建議使用默認值,單位為秒。如果在有效時間內沒有發起下一次請求,則不能繼續讀取數據。持續發起請求會刷新token有效時間。

說明

動態修改schema中的切換索引、服務端單臺機器故障、服務端負載均衡等均會導致Session提前過期,此時需要重新創建Session。

columnsToGet

指定分組結果中需要返回的列名,可以通過將列名加入Columns來實現。

如果需要返回多元索引中的所有列,則可以使用更簡潔的ReturnAllFromIndex實現。

重要

此處不能使用ReturnAll。

sessionId

本次并發掃描數據任務的sessionId。創建Session可以通過ComputeSplits API來創建,同時獲得本次任務支持的最大并發數。

示例

以下示例用于并發導出數據。

//1.獲取sessionId。
let computeSplits = await new Promise((resolve, reject) => {
    client.computeSplits({
        tableName: tableName,
        searchIndexSplitsOptions: {
            indexName: indexName,
        }
    }, function (err, data) {
        if (err) {
            console.log('computeSplits error:', err.toString());
            reject(err);
        } else {
            console.log('computeSplits success:', data);
            resolve(data)
        }
    })
})

//2.構造query。
const scanQuery = {
    query: {
        queryType: TableStore.QueryType.MATCH_ALL_QUERY,
    },
    limit: 1000,
    aliveTime: 30,
    token: undefined,
    currentParallelId: 0,
    maxParallel: 1,
}

//3.構造ParallelScan請求(該示例為了方便介紹使用同步請求進行展示,實際業務中可修改為異步)。
const parallelScanPromise = function () {
    return new Promise(function (resolve, reject) {
        client.parallelScan({
            tableName: tableName,
            indexName: indexName,
            columnToGet: {
                returnType: TableStore.ColumnReturnType.RETURN_ALL_FROM_INDEX,
            },
            sessionId: computeSplits.sessionId,
            scanQuery: scanQuery,
        }, function (err, data) {
            if (err) {
                console.log('parallelScan error:', err.toString());
                reject(err);
            } else {
                console.log("parallelScan, rows:", data.rows.length)
                resolve(data)
            }
        });
    })
}
let totalCount = 0 //示例代碼記錄總行數。
let parallelScanResponse = await parallelScanPromise()
totalCount = totalCount + parallelScanResponse.rows.length
//4.迭代拉取數據,直到拉取所有數據結束。
while (parallelScanResponse.nextToken !== null && parallelScanResponse.nextToken.length > 0) {
    scanQuery.token = parallelScanResponse.nextToken
    parallelScanResponse = await parallelScanPromise()
    totalCount += parallelScanResponse.rows.length
}
console.log("total rows:", totalCount)

常見問題

使用多元索引Search接口查不到數據

相關文檔