From f57bcae70cd2aacd07840bc64ea0e2bb0c5061ef Mon Sep 17 00:00:00 2001 From: Zaid Abdulla Date: Thu, 12 Sep 2019 11:16:42 -0700 Subject: [PATCH] Fix regression in GPN heuristic --- lib/gpn-heuristic.ts | 13 +++++++++---- lib/session.ts | 2 +- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/lib/gpn-heuristic.ts b/lib/gpn-heuristic.ts index e4b9e89..de99b23 100644 --- a/lib/gpn-heuristic.ts +++ b/lib/gpn-heuristic.ts @@ -1,3 +1,5 @@ +import Path from "./common/path"; + /** * Copyright 2013-2019 GenieACS Inc. * @@ -27,9 +29,12 @@ const UNDISCOVERED_DEPTH = 7; // flags is an int where its bits mark the segments in the pattern that // need refreshing. Leading 0s indicate that the pattern up to that // point has been discovered. -export function estimateGpnCount(gpnPatterns, depth = 0): number { - const children = {}; - const wildcardChildren = []; +export function estimateGpnCount( + gpnPatterns: [Path, number][], + depth: number = 0 +): number { + const children: { [segment: string]: [Path, number][] } = {}; + const wildcardChildren: [Path, number][] = []; let wildcardDiscovered = false; let gpnCount = 0; @@ -37,7 +42,7 @@ export function estimateGpnCount(gpnPatterns, depth = 0): number { const path = pattern[0]; const flags = pattern[1] >> depth; - const k = path[depth]; + const k = path.segments[depth] as string; if (!k) { if (flags & 1) gpnCount = 1; diff --git a/lib/session.ts b/lib/session.ts index f3360b6..1e2c153 100644 --- a/lib/session.ts +++ b/lib/session.ts @@ -1525,7 +1525,7 @@ function generateGetRpcRequest(sessionContext: SessionContext): GetAcsRequest { let nextLevel; let est = 0; if (path.length >= GPN_NEXT_LEVEL) { - const patterns = [[path, 0]]; + const patterns: [Path, number][] = [[path, 0]]; for (const p of sessionContext.deviceData.paths.find( path, true,