-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat(lineage-query): impl of lineage query * doc(lineage-query): basic message documentation and deprectation
- Loading branch information
1 parent
d377ecf
commit 22b5993
Showing
9 changed files
with
273 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
src/queries/catalog/lineage-query/lineage-query-executor.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import type { BasicQueryData } from '../../query'; | ||
import type { | ||
LineageQuery, | ||
LineageQueryResult | ||
} from './lineage-query-format'; | ||
import { log } from '../../../util/log'; | ||
import { getLineage } from '../../../cli/repl/commands/repl-lineage'; | ||
|
||
export function executeLineageQuery({ graph, ast }: BasicQueryData, queries: readonly LineageQuery[]): LineageQueryResult { | ||
const start = Date.now(); | ||
const result: LineageQueryResult['lineages'] = {}; | ||
for(const { criterion } of queries) { | ||
if(result[criterion]) { | ||
log.warn('Duplicate criterion in lineage query:', criterion); | ||
} | ||
result[criterion] = getLineage(criterion, graph, ast.idMap); | ||
} | ||
|
||
return { | ||
'.meta': { | ||
timing: Date.now() - start | ||
}, | ||
lineages: result | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import type { BaseQueryFormat, BaseQueryResult } from '../../base-query-format'; | ||
import type { SingleSlicingCriterion } from '../../../slicing/criterion/parse'; | ||
import type { NodeId } from '../../../r-bridge/lang-4.x/ast/model/processing/node-id'; | ||
|
||
/** | ||
* Calculates the lineage of the given criterion. | ||
*/ | ||
export interface LineageQuery extends BaseQueryFormat { | ||
readonly type: 'lineage'; | ||
readonly criterion: SingleSlicingCriterion; | ||
} | ||
|
||
export interface LineageQueryResult extends BaseQueryResult { | ||
/** Maps each criterion to the found lineage, duplicates are ignored. */ | ||
readonly lineages: Record<SingleSlicingCriterion, Set<NodeId>>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { assertQuery } from '../../_helper/query'; | ||
import { label } from '../../_helper/label'; | ||
import { withShell } from '../../_helper/shell'; | ||
import type { | ||
LineageQuery, | ||
LineageQueryResult | ||
} from '../../../../src/queries/catalog/lineage-query/lineage-query-format'; | ||
import { getLineage } from '../../../../src/cli/repl/commands/repl-lineage'; | ||
|
||
describe('Lineage Query', withShell(shell => { | ||
function testQuery(name: string, code: string, query: readonly LineageQuery[]) { | ||
assertQuery(label(name), shell, code, query, ({ dataflow }) => ({ | ||
'lineage': { | ||
lineages: query.reduce((acc, { criterion }) => { | ||
acc[criterion] = getLineage(criterion, dataflow.graph); | ||
return acc; | ||
}, {} as LineageQueryResult['lineages']) | ||
} | ||
})); | ||
} | ||
|
||
testQuery('Single Expression', 'x + 1', [{ type: 'lineage', criterion: '1@x' }]); | ||
testQuery('Multiple Queries', 'x + 1', [{ type: 'lineage', criterion: '1@x' }, { type: 'lineage', criterion: '1@x' }, { type: 'lineage', criterion: '1@x' }]); | ||
})); |
Oops, something went wrong.
22b5993
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"artificial" Benchmark Suite
Retrieve AST from R code
242.64114190909092
ms (101.22604012672635
)236.1199211818182
ms (98.66983024776289
)1.03
Normalize R AST
17.49391509090909
ms (31.589782917523895
)18.017819681818185
ms (30.826317957537874
)0.97
Produce dataflow information
39.29354286363637
ms (85.54310797296287
)39.13999777272727
ms (83.84025914001471
)1.00
Total per-file
814.0051005454545
ms (1465.8419149899091
)812.0954968181819
ms (1454.9698832785984
)1.00
Static slicing
2.048432091656461
ms (1.1401675279364303
)2.1591346071288307
ms (1.3606098316777646
)0.95
Reconstruct code
0.23730528557602315
ms (0.18858444915660885
)0.22943671546843153
ms (0.1742124327312039
)1.03
Total per-slice
2.300791116017012
ms (1.2177999463718405
)2.4043281804202783
ms (1.4361374673050025
)0.96
failed to reconstruct/re-parse
0
#0
#1
times hit threshold
0
#0
#1
reduction (characters)
0.7869360165281424
#0.7869360165281424
#1
reduction (normalized tokens)
0.7639690077689504
#0.7639690077689504
#1
memory (df-graph)
95.46617542613636
KiB (244.77619956879823
)95.46617542613636
KiB (244.77619956879823
)1
This comment was automatically generated by workflow using github-action-benchmark.
22b5993
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"social-science" Benchmark Suite
Retrieve AST from R code
241.23622498
ms (46.07994097014288
)242.00403574
ms (45.320075472333585
)1.00
Normalize R AST
18.595274059999998
ms (14.07642764847493
)20.69905216
ms (15.186291643827508
)0.90
Produce dataflow information
74.84718168
ms (88.1798105405472
)76.57805664
ms (89.58088354130591
)0.98
Total per-file
7771.5371134
ms (29395.65842744732
)7709.17616424
ms (28829.19832835734
)1.01
Static slicing
16.085559379520824
ms (44.843038892015315
)16.011826354372698
ms (44.07740390571893
)1.00
Reconstruct code
0.25443330397531116
ms (0.15103622777253903
)0.24862159317179558
ms (0.1500116592324732
)1.02
Total per-slice
16.347825067105454
ms (44.87252993299477
)16.268530062071488
ms (44.104014536012066
)1.00
failed to reconstruct/re-parse
0
#0
#1
times hit threshold
0
#0
#1
reduction (characters)
0.8712997340230448
#0.8712997340230448
#1
reduction (normalized tokens)
0.8102441553774778
#0.8102441553774778
#1
memory (df-graph)
99.8990234375
KiB (113.72812769327498
)99.8990234375
KiB (113.72812769327498
)1
This comment was automatically generated by workflow using github-action-benchmark.