Skip to content

Commit

Permalink
Move parts of the dependency graph to src/DependencyGraph/
Browse files Browse the repository at this point in the history
  • Loading branch information
swistak35 committed Jul 4, 2019
1 parent 21fe9b3 commit 641cd31
Show file tree
Hide file tree
Showing 42 changed files with 81 additions and 82 deletions.
2 changes: 1 addition & 1 deletion benchmark/parser/02b-parser-caching.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {CellAddress} from '../../src/parser/CellAddress'
import {Config} from '../../src/Config'
import {ParserWithCaching} from '../../src/parser/ParserWithCaching'
import {SheetMapping} from '../../src/SheetMapping'
import {SheetMapping} from '../../src/DependencyGraph'

const rows = 100000
const millisecondsPerThousandRows = 160
Expand Down
2 changes: 1 addition & 1 deletion bin/handsonengine-diff.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import parse from 'csv-parse/lib/sync'
import * as fs from 'fs'
import * as path from 'path'
import {findBoundaries} from '../src/AddressMapping'
import {findBoundaries} from '../src/DependencyGraph'
import {sheetCellAddress, sheetCellAddressToString} from '../src/Cell'

// Config
Expand Down
2 changes: 1 addition & 1 deletion src/AbsoluteCellRange.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {CellRange, CellValue, simpleCellAddress, SimpleCellAddress} from './Cell'
import {CellAddress} from './parser/CellAddress'
import {Matrix} from './Matrix'
import {SheetMapping} from "./SheetMapping";
import {SheetMapping} from "./DependencyGraph";
import {Sheets} from "./GraphBuilder";
import {add} from "./interpreter/scalar";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import {AbsoluteCellRange} from './AbsoluteCellRange'
import {CellValue, SheetCellAddress, SimpleCellAddress} from './Cell'
import {AbsoluteCellRange} from '../AbsoluteCellRange'
import {CellValue, SheetCellAddress, SimpleCellAddress} from '../Cell'
import {Graph} from './Graph'
import {Sheet} from './GraphBuilder'
import {Sheet} from '../GraphBuilder'
import {CellVertex, EmptyCellVertex, MatrixVertex, Vertex} from './Vertex'
import {filterWith} from "./generatorUtils";
import {filterWith} from "../generatorUtils";

/**
* Interface for mapping from sheet addresses to vertices.
Expand Down
10 changes: 5 additions & 5 deletions src/DependencyGraph/DependencyGraph.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import {AddressMapping} from '../AddressMapping'
import {RangeMapping} from '../RangeMapping'
import {SheetMapping} from '../SheetMapping'
import {AddressMapping} from './AddressMapping'
import {RangeMapping} from './RangeMapping'
import {SheetMapping} from './SheetMapping'
import {SimpleCellAddress} from '../Cell'
import {CellDependency} from '../CellDependency'
import {findSmallerRange} from '../interpreter/plugin/SumprodPlugin'
import {Graph} from '../Graph'
import {Graph} from './Graph'
import {Ast, CellAddress, collectDependencies, absolutizeDependencies} from '../parser'
import {AbsoluteCellRange} from '../AbsoluteCellRange'
import assert from 'assert';
Expand All @@ -16,7 +16,7 @@ import {
RangeVertex,
ValueCellVertex,
Vertex
} from '../Vertex'
} from './Vertex'

export class DependencyGraph {
public recentlyChangedVertices: Set<Vertex> = new Set()
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {SimpleCellAddress} from './Cell'
import {SimpleCellAddress} from '../Cell'
import {RangeVertex, Vertex} from './Vertex'

/**
Expand Down
File renamed without changes.
10 changes: 5 additions & 5 deletions src/Vertex.ts → src/DependencyGraph/Vertex.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {AbsoluteCellRange} from './AbsoluteCellRange'
import {CellValue, CellError, SimpleCellAddress} from './Cell'
import {CriterionLambda} from './interpreter/Criterion'
import {Matrix} from './Matrix'
import {Ast} from './parser'
import {AbsoluteCellRange} from '../AbsoluteCellRange'
import {CellValue, CellError, SimpleCellAddress} from '../Cell'
import {CriterionLambda} from '../interpreter/Criterion'
import {Matrix} from '../Matrix'
import {Ast} from '../parser'

/**
* Represents vertex which keeps values of one or more cells
Expand Down
15 changes: 14 additions & 1 deletion src/DependencyGraph/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,15 @@
export { DependencyGraph, fetchOrCreateEmptyCell } from './DependencyGraph'

export { AddressMapping, DenseStrategy, SparseStrategy, findBoundaries } from './AddressMapping'
export { Graph } from './Graph'
export { RangeMapping } from './RangeMapping'
export { SheetMapping } from './SheetMapping'
export {
CellVertex,
Vertex,
FormulaCellVertex,
ValueCellVertex,
EmptyCellVertex,
MatrixVertex,
RangeVertex,
CriterionCache,
} from './Vertex'
2 changes: 1 addition & 1 deletion src/Evaluator.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Vertex} from './Vertex'
import {Vertex} from './DependencyGraph'

export interface Evaluator {
run(): void,
Expand Down
10 changes: 5 additions & 5 deletions src/GraphBuilder.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
import {AbsoluteCellRange} from './AbsoluteCellRange'
import {AddressMapping} from './AddressMapping'
import {CellError, ErrorType, simpleCellAddress, SimpleCellAddress} from './Cell'
import {CellDependency} from './CellDependency'
import {Config} from './Config'
import {Graph} from './Graph'
import {GraphBuilderMatrixHeuristic} from './GraphBuilderMatrixHeuristic'
import {findSmallerRange} from './interpreter/plugin/SumprodPlugin'
import {checkMatrixSize, MatrixSizeCheck} from './Matrix'
import {isFormula, isMatrix, ParserWithCaching, ProcedureAst} from './parser'
import {RangeMapping} from './RangeMapping'
import {SheetMapping} from './SheetMapping'
import {Statistics, StatType} from './statistics/Statistics'
import {DependencyGraph, fetchOrCreateEmptyCell} from './DependencyGraph'
import {
Expand All @@ -20,7 +16,11 @@ import {
RangeVertex,
ValueCellVertex,
Vertex,
} from './Vertex'
AddressMapping,
Graph,
RangeMapping,
SheetMapping,
} from './DependencyGraph'

/**
* Two-dimenstional array representation of sheet
Expand Down
5 changes: 1 addition & 4 deletions src/GraphBuilderMatrixHeuristic.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
import {AbsoluteCellRange} from './AbsoluteCellRange'
import {AddressMapping} from './AddressMapping'
import {simpleCellAddress, SimpleCellAddress} from './Cell'
import {CellAddress, CellReferenceType} from './parser/CellAddress'
import {CellDependency} from './CellDependency'
import {Config} from './Config'
import {Graph} from './Graph'
import {Size} from './Matrix'
import {Ast, AstNodeType, buildCellRangeAst, buildProcedureAst, CellRangeAst, isMatrix, ProcedureAst} from './parser'
import {FormulaCellVertex, MatrixVertex, ValueCellVertex, Vertex} from './Vertex'
import {FormulaCellVertex, MatrixVertex, ValueCellVertex, Vertex, SheetMapping, Graph, AddressMapping} from './DependencyGraph'
import {Sheets} from "./GraphBuilder";
import {SheetMapping} from "./SheetMapping";
import {Cache} from "./parser/Cache";
import {absolutizeDependencies} from "./parser/ParserWithCaching";

Expand Down
13 changes: 7 additions & 6 deletions src/HandsOnEngine.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,28 @@
import {AddressMapping} from './AddressMapping'
import {CellError, CellValue, ErrorType, simpleCellAddress, SimpleCellAddress} from './Cell'
import {CellDependency} from './CellDependency'
import {CellAddress} from './parser/CellAddress'
import {Ast, AstNodeType, collectDependencies, absolutizeDependencies, buildCellErrorAst, buildErrorAst} from './parser'
import {Config} from './Config'
import {Evaluator} from './Evaluator'
import {Graph} from './Graph'
import {buildMatrixVertex, GraphBuilder, Sheet, Sheets} from './GraphBuilder'
import {cellAddressFromString, isFormula, isMatrix, ParserWithCaching, ProcedureAst} from './parser'
import {RangeMapping} from './RangeMapping'
import {SheetMapping} from './SheetMapping'
import {SingleThreadEvaluator} from './SingleThreadEvaluator'
import {Statistics, StatType} from './statistics/Statistics'
import {DependencyGraph, fetchOrCreateEmptyCell} from './DependencyGraph'
import {
DependencyGraph,
fetchOrCreateEmptyCell,
AddressMapping,
Graph,
RangeMapping,
SheetMapping,
CellVertex,
EmptyCellVertex,
FormulaCellVertex,
MatrixVertex,
RangeVertex,
ValueCellVertex,
Vertex
} from './Vertex'
} from './DependencyGraph'
import {AbsoluteCellRange} from "./AbsoluteCellRange";

/**
Expand Down
5 changes: 1 addition & 4 deletions src/SingleThreadEvaluator.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
import {AddressMapping} from './AddressMapping'
import {CellError, ErrorType,} from './Cell'
import {Config} from './Config'
import {Evaluator} from './Evaluator'
import {Graph} from './Graph'
import {Interpreter} from './interpreter/Interpreter'
import {Ast} from './parser'
import {RangeMapping} from './RangeMapping'
import {Statistics, StatType} from './statistics/Statistics'
import {FormulaCellVertex, MatrixVertex, RangeVertex, Vertex} from './Vertex'
import {FormulaCellVertex, MatrixVertex, RangeVertex, Vertex, RangeMapping, Graph, AddressMapping} from './DependencyGraph'

export class SingleThreadEvaluator implements Evaluator {
private interpreter: Interpreter
Expand Down
5 changes: 1 addition & 4 deletions src/interpreter/Interpreter.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
import {AbsoluteCellRange} from '../AbsoluteCellRange'
import {AddressMapping} from '../AddressMapping'
import {AddressMapping, RangeMapping, Graph, Vertex} from '../DependencyGraph'
import {CellError, CellValue, ErrorType, SimpleCellAddress} from '../Cell'
import {CellAddress} from '../parser/CellAddress'
import {Config} from '../Config'
import {Graph} from '../Graph'
import {Matrix} from '../Matrix'
import {Ast, AstNodeType} from '../parser/Ast'
import {RangeMapping} from '../RangeMapping'
import {Vertex} from '../Vertex'
import {BooleanPlugin} from './plugin/BooleanPlugin'
import {CountUniquePlugin} from './plugin/CountUniquePlugin'
import {DatePlugin} from './plugin/DatePlugin'
Expand Down
5 changes: 1 addition & 4 deletions src/interpreter/plugin/FunctionPlugin.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import {AbsoluteCellRange} from '../../AbsoluteCellRange'
import {AddressMapping} from '../../AddressMapping'
import {CellError, CellValue, ErrorType, simpleCellAddress, SimpleCellAddress} from '../../Cell'
import {Config} from '../../Config'
import {Graph} from '../../Graph'
import {Ast, AstNodeType, ProcedureAst} from '../../parser/Ast'
import {RangeMapping} from '../../RangeMapping'
import {Vertex} from '../../Vertex'
import {Vertex, RangeMapping, Graph, AddressMapping} from '../../DependencyGraph'
import {Interpreter} from '../Interpreter'
import {Matrix} from "../../Matrix";

Expand Down
2 changes: 1 addition & 1 deletion src/interpreter/plugin/MatrixPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {AbsoluteCellRange} from '../../AbsoluteCellRange'
import {CellError, CellValue, ErrorType, SimpleCellAddress} from '../../Cell'
import {checkMatrixSize, Matrix} from '../../Matrix'
import {Ast, NumberAst, AstNodeType, ProcedureAst} from '../../parser/Ast'
import {MatrixVertex} from '../../Vertex'
import {MatrixVertex} from '../../DependencyGraph'
import {Interpreter} from '../Interpreter'
import {FunctionPlugin} from './FunctionPlugin'

Expand Down
4 changes: 1 addition & 3 deletions src/interpreter/plugin/SumifPlugin.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {AbsoluteCellRange} from '../../AbsoluteCellRange'
import {AddressMapping} from '../../AddressMapping'
import {AddressMapping, RangeMapping, CriterionCache, RangeVertex} from '../../DependencyGraph'
import {
CellError,
CellValue,
Expand All @@ -9,8 +9,6 @@ import {
} from '../../Cell'
import {count, split} from '../../generatorUtils'
import {AstNodeType, CellReferenceAst, ProcedureAst} from '../../parser/Ast'
import {RangeMapping} from '../../RangeMapping'
import {CriterionCache, RangeVertex} from '../../Vertex'
import {buildCriterionLambda, Criterion, CriterionLambda, parseCriterion} from '../Criterion'
import {add} from '../scalar'
import {FunctionPlugin} from './FunctionPlugin'
Expand Down
3 changes: 1 addition & 2 deletions src/interpreter/plugin/SumprodPlugin.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import {AbsoluteCellRange} from '../../AbsoluteCellRange'
import {CellError, CellValue, ErrorType, simpleCellAddress, SimpleCellAddress} from '../../Cell'
import {AstNodeType, ProcedureAst} from '../../parser/Ast'
import {RangeMapping} from '../../RangeMapping'
import {RangeVertex} from '../../Vertex'
import {RangeMapping, RangeVertex} from '../../DependencyGraph'
import {FunctionPlugin} from './FunctionPlugin'
import {Matrix} from "../../Matrix";
import {zip} from "../../generatorUtils";
Expand Down
2 changes: 1 addition & 1 deletion test/adding-row.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {Config, HandsOnEngine} from "../src";
import {simpleCellAddress, SimpleCellAddress} from "../src/Cell";
import './testConfig.ts'
import {EmptyCellVertex, FormulaCellVertex, RangeVertex} from "../src/Vertex";
import {EmptyCellVertex, FormulaCellVertex, RangeVertex} from "../src/DependencyGraph";
import {CellAddress} from "../src/parser/CellAddress"
import {CellReferenceAst} from "../src/parser/Ast"

Expand Down
4 changes: 2 additions & 2 deletions test/address-mapping.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {AbsoluteCellRange} from '../src/AbsoluteCellRange'
import {AddressMapping, DenseStrategy, SparseStrategy} from '../src/AddressMapping'
import {AddressMapping, DenseStrategy, SparseStrategy} from '../src/DependencyGraph'
import {simpleCellAddress} from '../src/Cell'
import {EmptyCellVertex, MatrixVertex, ValueCellVertex} from '../src/Vertex'
import {EmptyCellVertex, MatrixVertex, ValueCellVertex} from '../src/DependencyGraph'

const sharedExamples = (builder: (width: number, height: number) => AddressMapping) => {
it('simple set', () => {
Expand Down
2 changes: 1 addition & 1 deletion test/cell-address-from-string.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {simpleCellAddress} from '../src/Cell'
import {CellAddress} from '../src/parser/CellAddress'
import {cellAddressFromString} from '../src/parser'
import {SheetMapping} from '../src/SheetMapping'
import {SheetMapping} from '../src/DependencyGraph'

describe('cellAddressFromString', () => {
it('is zero based', () => {
Expand Down
2 changes: 1 addition & 1 deletion test/change-cell-content.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {Config, HandsOnEngine} from "../src";
import {simpleCellAddress, SimpleCellAddress} from "../src/Cell";
import './testConfig.ts'
import {MatrixVertex, FormulaCellVertex, EmptyCellVertex} from "../src/Vertex";
import {MatrixVertex, FormulaCellVertex, EmptyCellVertex} from "../src/DependencyGraph";
import {CellAddress} from "../src/parser/CellAddress"

describe('changing cell content', () => {
Expand Down
2 changes: 1 addition & 1 deletion test/compute-hash.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { CellAddress } from '../src/parser/CellAddress'
import { Config } from '../src/Config'
import { buildLexerConfig, FormulaLexer, ParserWithCaching } from '../src/parser'
import { SheetMapping } from '../src/SheetMapping'
import { SheetMapping } from '../src/DependencyGraph'

describe('computeHash', () => {
const computeFunc = (code: string, address: CellAddress): string => {
Expand Down
2 changes: 1 addition & 1 deletion test/disable-matrix-optimizations.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {Config, HandsOnEngine} from "../src";
import {simpleCellAddress} from "../src/Cell";
import {EmptyCellVertex, MatrixVertex, RangeVertex, ValueCellVertex} from "../src/Vertex";
import {EmptyCellVertex, MatrixVertex, RangeVertex, ValueCellVertex} from "../src/DependencyGraph";
import './testConfig.ts'

describe("Disable matrix optimizatoins", () => {
Expand Down
2 changes: 1 addition & 1 deletion test/find-boundaries.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {findBoundaries} from '../src/AddressMapping'
import {findBoundaries} from '../src/DependencyGraph'

describe('findBoundaries', () => {
it('find correct dimensions', () => {
Expand Down
10 changes: 5 additions & 5 deletions test/graph-builder.spec.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import {AddressMapping} from '../src/AddressMapping'
import {AddressMapping} from '../src/DependencyGraph'
import {simpleCellAddress} from '../src/Cell'
import {CellAddress} from '../src/parser/CellAddress'
import {Config} from '../src/Config'
import {Graph} from '../src/Graph'
import {GraphBuilder} from '../src/GraphBuilder'
import {Graph} from '../src/DependencyGraph'
import {buildCellRangeAst, buildProcedureAst, ParserWithCaching} from '../src/parser'
import {RangeMapping} from '../src/RangeMapping'
import {SheetMapping} from '../src/SheetMapping'
import {RangeMapping} from '../src/DependencyGraph'
import {SheetMapping} from '../src/DependencyGraph'
import {Statistics} from '../src/statistics/Statistics'
import {EmptyCellVertex, MatrixVertex, ValueCellVertex, Vertex} from '../src/Vertex'
import {EmptyCellVertex, MatrixVertex, ValueCellVertex, Vertex} from '../src/DependencyGraph'
import './testConfig.ts'

describe('GraphBuilder', () => {
Expand Down
4 changes: 2 additions & 2 deletions test/graph-vertex.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {Graph} from '../src/Graph'
import {ValueCellVertex, Vertex} from '../src/Vertex'
import {Graph} from '../src/DependencyGraph'
import {ValueCellVertex, Vertex} from '../src/DependencyGraph'

describe('Graph with Vertex', () => {
it('#addNode works correctly with Vertex instances', () => {
Expand Down
2 changes: 1 addition & 1 deletion test/graph.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Graph} from '../src/Graph'
import {Graph} from '../src/DependencyGraph'

const identifiableString = (id: number, str: string) => ({ id, str })

Expand Down
2 changes: 1 addition & 1 deletion test/matrix-size-check.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {CellAddress} from '../src/parser/CellAddress'
import {Config} from '../src/Config'
import {checkMatrixSize, Size} from '../src/Matrix'
import {ParserWithCaching} from '../src/parser'
import {SheetMapping} from '../src/SheetMapping'
import {SheetMapping} from '../src/DependencyGraph'
import './testConfig.ts'

describe('Matrix size check tests', () => {
Expand Down
2 changes: 1 addition & 1 deletion test/parser-dependencies.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {simpleCellAddress} from '../src/Cell'
import {CellAddress} from '../src/parser/CellAddress'
import {Config} from '../src/Config'
import {ParserWithCaching} from '../src/parser'
import {SheetMapping} from '../src/SheetMapping'
import {SheetMapping} from '../src/DependencyGraph'

describe('Parsing collecting dependencies', () => {
it('works for CELL_REFERENCE with relative dependency', () => {
Expand Down
2 changes: 1 addition & 1 deletion test/parser/boolean-operators.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
LessThanOrEqualOpAst, NotEqualOpAst,
ParserWithCaching,
} from '../../src/parser'
import {SheetMapping} from '../../src/SheetMapping'
import {SheetMapping} from '../../src/DependencyGraph'

describe('Parser - Boolean operators', () => {
it('Equals operator', () => {
Expand Down
2 changes: 1 addition & 1 deletion test/parser/compute-hash-from-ast.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {buildLexerConfig, CellReferenceAst, FormulaLexer, ParserWithCaching} from "../../src/parser";
import {Config} from "../../src";
import {SheetMapping} from "../../src/SheetMapping";
import {SheetMapping} from "../../src/DependencyGraph";
import {CellAddress} from "../../src/parser/CellAddress";
import {simpleCellAddress} from "../../src/Cell";

Expand Down
Loading

0 comments on commit 641cd31

Please sign in to comment.