Node.data

An object for manipulating a node's data.

The data is either empty, a string, or a matrix of numbers. You can read/write it as an array (row-major) or as a collection of rows and columns.

The easiest way to set the data's contents is
>>> node.data = "a string"      
>>> node.data = [1, 2, 3]      a 3x1 matrix of integers (4-byte signed)
>>> node.data = [1.0, 2, 3]      a 3x1 matrix of floating-point (double precision)

count

number of items == rows X cols

rows

number of rows (for strings: number of characters)

cols

number of columns (for strings: 1)

type

QTR_TYPE_*: a numeric constant describing the data's storage format
(int, float, or string; number of bytes)

size

how many bytes are taken by one row of data

loaded

(first, last): range of items loaded in memory. Should be (0, count-1) unless (not preload) or you've been messing with loadRows() and unloadRows()

loadedRows

(first, last): range of rows loaded in memory. Should be (0, rows-1) unless (not preload) or you've been messing with loadRows() and unloadRows()

preload

Whether the data should be loaded into RAM when reading this node from disk. default: true

data[ index ]

returns      number, string, or None

Access the data as a list.
read/write

setup( type, rows, cols )

Clears any existing data and makes room for a matrix. Numerical types only please. If you don't want memory allocated, set data.preload = false first.

resize( newRowcount )

newRowcount      the new number of rows

You can only resize if rows is already nonzero. (Otherwise, what type/size would the elements have?)
Sorry, can't resize the number of columns.

clear()

Removes any data from this node.

loadRows( first, last, doRead )

first      the first row index in the range
last      the last row index in the range
doRead      true: load the data from disk false: just allocate memory

Nodes on disk can keep the data on disk and load portions into RAM as needed. Nodes that aren't on disk can still pretend.

You can ignore this stuff unless a node might have data.preload == false, or [un]loadRows() may have been called.

unloadRows( doWrite )

doWrite      true: write the loaded region to disk false: just free its RAM.

Free up some RAM by paging data out to disk. If you know it hasn't changed, use doWrite = false.
If the node is not on disk, you will not save any RAM, but it will still behave as expected.

row( i )

Returns a sequence to access one row of data like a list.

col( i )

Returns a sequence to access one column of data like a list.