Skip to content
This repository was archived by the owner on May 15, 2019. It is now read-only.

How Graph Builder Works in POI

Roman Roschin edited this page Nov 6, 2015 · 3 revisions

How Graph Builder Works in POI

(How the GraphBuilder does create a graph in POI)

Purpose of this document

The purpose of this document is to describe a GraphBuilder component, what problems it solves, how POI does a Cell evaluation and how this evaluation correlates to the algorithm of the GraphBuilder.

Components: CalculationEngine Core

DataModel

An object that represents a spreadsheet. Basic interface is IDataModel.java, implementation is DataModel.java. DataModel.java aggregates an instance of Apache POI’s XSSFWorkbook as private field. DataModel contains Cells with formulas and values. Any cell can be evaluated and so graph can be built for such cell.

Evaluator

An object that does the evaluation of DataModel\DataModel’s Cell. It responsibility is to provide a calculated value for given Cell or the whole DataModel. Basic interface is IEvaluator.java, implementation is SpreadsheetEvaluator.java. SpreadsheetEvaluator.java aggregates an instance of Apache POI’s XSSFFormulaEvaluator. This object is used to does evaluation of XSSFWorkbook’s cell.

Auditor

An object that manages work of GraphBuilder and Evaluator at the same time. Its purpose is to inject the GraphBuilder instance to Evaluator and do some post processing operations on graph. This is also the start point to build a graph. Basic interface is IAuditor.java, implementation is SpreadsheetAuditor.java. Auditor requires an instance of Evaluator to be injected to work.

GraphBuilder

An object that does all the logic to build the actual execution graph. Its basic interface is IExecutionGraphBuilder.java from forked Apache POI library. Its methods like createVertex(), removeVertex(), connectVertices() are used to build graph (Directed graph with Vertex (as node) and Edge (as edge) is used). The only implementation is located in engine-evaluation library – PoiExecutionGraphBuilder.java. There is also an empty implementation of this interface – EmptyExecutionGraph$DoNothingExecutionGraphBuilder.java – this class with all empty method is used in POI evaluation algorithm when no graph recording is needed. PoiExecutionGraphBuilder is not thread safe and should be used in the only one instance of Auditor, since it does contain a state of a graph.

Components: Forked Apache POI

FormulaEvaluator

POI’s component to wrap WorkbookEvaluator and do evaluation.

WorkbookEvaluator

POI’s component where all evaluation steps are performed. It operates with Ptg – a simple part of formula. Ptgs are key elements to build a graph.

OperandResolver

An util object to resolve the actual Cell’s values. Contains several implementations for different purposes: OperandResolver.java, MultiOperandNumericFunction.java, Choose.java, etc.

GraphBuilder activity diagram

The activity diagram of all components can be found here: PDF