Skip to content

Commit 74a819a

Browse files
committed
Adress comment
1 parent 0f69197 commit 74a819a

File tree

1 file changed

+24
-27
lines changed
  • packages/itwin/tree-widget/src/tree-widget-react/components/trees/models-tree/internal

1 file changed

+24
-27
lines changed

packages/itwin/tree-widget/src/tree-widget-react/components/trees/models-tree/internal/ModelsTreeIdsCache.ts

Lines changed: 24 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -400,18 +400,17 @@ export class ModelsTreeIdsCache {
400400
}
401401
return acc;
402402
}, new Map<Id64String, Id64Set>()),
403-
mergeMap((modelCategoryMap) =>
404-
from(modelCategoryMap.entries()).pipe(
405-
map(([modelId, categoryIds]) => `Model.Id = ${modelId} AND Category.Id IN (${[...categoryIds].join(", ")})`),
406-
// Maximum Depth Of An Expression Tree is set to 3000:
407-
// https://github.com/iTwin/imodel-native/blob/f0f36d97fe10fd441b8bf760c331d299615a42b9/iModelCore/BeSQLite/SQLite/bentley-sqlite.c#L22
408-
// 2900 makes sure that this limit is not reached
409-
bufferCount(Math.ceil(modelCategoryMap.size / Math.ceil(modelCategoryMap.size / 2900))),
410-
mergeMap(async (whereClauses) => {
411-
const reader = this._queryExecutor.createQueryReader(
412-
{
413-
ctes: [
414-
`
403+
mergeMap((modelCategoryMap) => modelCategoryMap.entries()),
404+
map(([modelId, categoryIds]) => `Model.Id = ${modelId} AND Category.Id IN (${[...categoryIds].join(", ")})`),
405+
// Maximum Depth Of An Expression Tree is set to 3000:
406+
// https://github.com/iTwin/imodel-native/blob/f0f36d97fe10fd441b8bf760c331d299615a42b9/iModelCore/BeSQLite/SQLite/bentley-sqlite.c#L22
407+
// 2900 makes sure that this limit is not reached
408+
bufferCount(2900),
409+
mergeMap(async (whereClauses) => {
410+
const reader = this._queryExecutor.createQueryReader(
411+
{
412+
ctes: [
413+
`
415414
CategoryElements(id, modelId, categoryId) AS (
416415
SELECT ECInstanceId, Model.Id, Category.Id
417416
FROM ${this._hierarchyConfig.elementClassSpecification}
@@ -428,25 +427,23 @@ export class ModelsTreeIdsCache {
428427
JOIN CategoryElements p ON c.Parent.Id = p.id
429428
)
430429
`,
431-
],
432-
ecsql: `
430+
],
431+
ecsql: `
433432
SELECT modelId, categoryId, COUNT(id) elementsCount
434433
FROM CategoryElements
435434
GROUP BY modelId, categoryId
436435
`,
437-
},
438-
{ rowFormat: "ECSqlPropertyNames", limit: "unbounded" },
439-
);
440-
441-
const result = new Array<{ modelId: number; categoryId: number; elementsCount: number }>();
442-
for await (const row of reader) {
443-
result.push({ modelId: row.modelId, categoryId: row.categoryId, elementsCount: row.elementsCount });
444-
}
445-
return result;
446-
}),
447-
mergeAll(),
448-
),
449-
),
436+
},
437+
{ rowFormat: "ECSqlPropertyNames", limit: "unbounded" },
438+
);
439+
440+
const result = new Array<{ modelId: number; categoryId: number; elementsCount: number }>();
441+
for await (const row of reader) {
442+
result.push({ modelId: row.modelId, categoryId: row.categoryId, elementsCount: row.elementsCount });
443+
}
444+
return result;
445+
}),
446+
mergeAll(),
450447
),
451448
);
452449
}

0 commit comments

Comments
 (0)