Options
All
  • Public
  • Public/Protected
  • All
Menu

Class DSVModel

A data model implementation for in-memory delimiter-separated data. The namespace for the DSVModel class statics.

Notes

This model handles data with up to 2**32 characters.

Hierarchy

  • DataModel
    • DSVModel

Implements

  • IDisposable

Index

Type aliases

Static CellRegion

CellRegion: "body" | "row-header" | "column-header" | "corner-header"

A type alias for the data model cell regions.

Static ChangedArgs

ChangedArgs: IRowsChangedArgs | IColumnsChangedArgs | IRowsMovedArgs | IColumnsMovedArgs | ICellsChangedArgs | IModelResetArgs

A type alias for the args objects of the changed signal.

Static ColumnRegion

ColumnRegion: "body" | "row-header"

A type alias for the data model column regions.

Static Metadata

Metadata: object

The metadata for a column in a data model.

Type declaration

  • [key: string]: any

Static RowRegion

RowRegion: "body" | "column-header"

A type alias for the data model row regions.

Constructors

constructor

  • Create a data model with static CSV data.

    Parameters

    • options: IOptions

      The options for initializing the data model.

    Returns DSVModel

Properties

Private _columnCount

_columnCount: number

Private _columnOffsets

_columnOffsets: Uint32Array = new Uint32Array(0)

The column offset cache, starting with row _columnOffsetsStartingRow

Notes

The index of the first character in the data string for row r, column c is columnOffsets[(r-this.columnOffsetsStartingRow)*numColumns+c]

Private _columnOffsetsStartingRow

_columnOffsetsStartingRow: number = 0

The row that _columnOffsets[0] represents.

Private _data

_data: string

Private _delayedParse

_delayedParse: number = null

Private _delimiter

_delimiter: string

Private _doneParsing

_doneParsing: boolean = false

Private _header

_header: string[] = []

The header strings.

Private _initialRows

_initialRows: number

The number of rows to parse initially before doing a delayed parse of the entire data.

Private _isDisposed

_isDisposed: boolean = false

Private _maxCacheGet

_maxCacheGet: number = 1000

The maximum number of rows to parse when there is a cache miss.

Private _parser

_parser: "quotes" | "noquotes"

Private _quote

_quote: string

Private _quoteEscaped

_quoteEscaped: RegExp

Private _ready

_ready: PromiseDelegate<void> = new PromiseDelegate<void>()

Private _rowCount

_rowCount: number = 1

Private _rowDelimiter

_rowDelimiter: string

Private _rowOffsets

_rowOffsets: Uint32Array = new Uint32Array(1)

The index for the start of each row.

Private _startedParsing

_startedParsing: boolean = false

changed

changed: ISignal<this, DataModel.ChangedArgs>

A signal emitted when the data model has changed.

Static emptyMetadata

emptyMetadata: Metadata

A singleton empty metadata object.

Accessors

isDisposed

  • get isDisposed(): boolean
  • Whether this model has been disposed.

    Returns boolean

ready

  • get ready(): Promise<void>
  • A promise that resolves when the model has parsed all of its data.

    Returns Promise<void>

Methods

Private _computeRowOffsets

  • _computeRowOffsets(endRow?: number): void
  • Compute the row offsets and initialize the column offset cache.

    Parameters

    • Default value endRow: number = 4294967295

      The last row to parse, from the start of the data (first row is row 1).

      Notes

      This method supports parsing the data incrementally by calling it with incrementally higher endRow. Rows that have already been parsed will not be parsed again.

    Returns void

Private _getField

  • _getField(row: number, column: number): string
  • Get the parsed string field for a row and column.

    Parameters

    • row: number

      The row number of the data item.

    • column: number

      The column number of the data item.

    Returns string

    The parsed string for the data item.

Private _getOffsetIndex

  • _getOffsetIndex(row: number, column: number): number
  • Get the index in the data string for the first character of a row and column.

    Parameters

    • row: number

      The row of the data item.

    • column: number

      The column of the data item.

    Returns number

    • The index into the data string where the data item starts.

Private _parseAsync

  • _parseAsync(): void
  • Parse the data string asynchronously.

    Notes

    It can take several seconds to parse a several hundred megabyte string, so we parse the first 500 rows to get something up on the screen, then we parse the full data string asynchronously.

    Returns void

Private _resetParser

  • _resetParser(): void
  • Reset the parser state.

    Returns void

columnCount

  • columnCount(region: DataModel.ColumnRegion): number
  • Get the column count for a region in the data model.

    Parameters

    • region: DataModel.ColumnRegion

      The column region of interest.

    Returns number

    • The column count for the region.

data

  • data(region: DataModel.CellRegion, row: number, column: number): string
  • Get the data value for a cell in the data model.

    Parameters

    • region: DataModel.CellRegion

      The cell region of interest.

    • row: number

      The row index of the cell of interest.

    • column: number

      The column index of the cell of interest.

    Returns string

dispose

  • dispose(): void
  • Dispose the resources held by this model.

    Returns void

Protected emitChanged

  • emitChanged(args: DataModel.ChangedArgs): void
  • Emit the changed signal for the data model.

    Notes

    Subclass should call this method whenever the data model has changed so that attached data grids can update themselves.

    Parameters

    • args: DataModel.ChangedArgs

    Returns void

metadata

  • metadata(region: DataModel.CellRegion, column: number): DataModel.Metadata
  • Get the metadata for a column in the data model.

    Parameters

    • region: DataModel.CellRegion

      The cell region of interest.

    • column: number

      The index of the column of interest.

    Returns DataModel.Metadata

    The metadata for the column.

    Notes

    The returned metadata should be treated as immutable.

    Models which support columnar data may reimplement this method to return the metadata for a column.

    The metadata can be used by custom cell renderers and cell editors to customize handling of specific cell data types.

    This method is called often, and so should be efficient.

    The default implementation returns {}.

rowCount

  • rowCount(region: DataModel.RowRegion): number
  • Get the row count for a region in the data model.

    Parameters

    • region: DataModel.RowRegion

      The row region of interest.

    Returns number

    • The row count for the region.

Generated using TypeDoc