From 80cc7d51efd8efb5dad3c0fc49354aa0f65c6042 Mon Sep 17 00:00:00 2001 From: Michael Shanks Date: Sat, 9 Nov 2019 06:33:56 +0000 Subject: [PATCH] backup --- packages/core/src/indexing/allIds.js | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/packages/core/src/indexing/allIds.js b/packages/core/src/indexing/allIds.js index 46226a74d1..9f32985fa5 100644 --- a/packages/core/src/indexing/allIds.js +++ b/packages/core/src/indexing/allIds.js @@ -18,9 +18,32 @@ const allIdChars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWX const _new_getShardPath = (recordNode, key) => { const id = getFileFromKey(key); - const determineShardFactors = (currentRecordCount, factors=[]) => { - const thisFactor = currentRecordCount / 1000 + + /** + * folderStructureArray should return an array like + * - [1] = all records fit into one folder + * - [2] = all records fite into 2 folders + * - [64, 3] = all records fit into 64 * 3 folders + * - [64, 64, 10] = all records fit into 64 * 64 * 10 folder + * (there are 64 possible chars in allIsChars) + */ + const folderStructureArray = (currentArray=[], currentFolderPosition=0) => { + const maxRecords = currentFolderPosition === 0 + ? RECORDS_PER_FOLDER + : currentFolderPosition * 64 * RECORDS_PER_FOLDER; + + if(maxRecords < recordNode.estimatedRecordCount) { + return folderStructureArray( + [...currentArray, 64], + currentFolderPosition + 1); + } else { + const childFolderCount = Math.ceil(maxRecords / recordNode.estimatedRecordCount); + return [...currentArray, childFolderCount] + } } + + const folderStructure = folderStructureArray(); + } const allIdsStringsForFactor = (collectionNode) => {