Skip to main content
Version: Java (Groovy)

Simple table constructors

newTable

Columns are created using the following methods:

result = newTable(
intCol("Integers", 1, 2, 3),
stringCol("Strings", "These", "are", "Strings"),
)

Formula columns

var = 3

f = { a, b -> a + b }

source = newTable(intCol("A", 1, 2, 3, 4, 5), intCol("B", 10, 20, 30, 40, 50))

result = source.update("X = A + 3 * sqrt(B) + var + (int)f(A, B)")

String columns

scores = newTable(
stringCol("Name", "James", "Lauren", "Zoey"),
intCol("Math", 95, 72, 100),
intCol("Science", 100, 78, 98),
intCol("Art", 90, 92, 96),
)

total = scores.update("Total = Math + Science + Art")
average = scores.update("Average = (Math + Science + Art) / 3 ")

emptyTable

result = emptyTable(5)

// Empty tables are often followed with a formula
result1 = result.update("X = 5")

timeTable

result = timeTable("PT2S")

RingTableTools.of

import io.deephaven.engine.table.impl.sources.ring.RingTableTools

source = timeTable("PT00:00:01")
result = RingTableTools.of(source, 3)

img

InputTable

import io.deephaven.engine.table.impl.util.AppendOnlyArrayBackedInputTable
import io.deephaven.engine.table.TableDefinition
import io.deephaven.engine.table.ColumnDefinition

// from an existing table
source = emptyTable(10).update("X = i")

result = AppendOnlyArrayBackedInputTable.make(source)


// from scratch
tableDef = TableDefinition.of(ColumnDefinition.ofInt("Integers"), ColumnDefinition.ofDouble("Doubles"), ColumnDefinition.ofString("Srings"))

result2 = AppendOnlyArrayBackedInputTable.make(tableDef)