View on GitHub

carnival

JVM property graph data unification framework

MappedDataTable

The MappedDataTable supports tabular data where each row of data is identified by a single unique key

Example: Mapped data table

@Grab(group='org.pmbb', module='carnival-util', version='2.0.1-SNAPSHOT')

import carnival.util.MappedDataTable

def mdt = new MappedDataTable(
  name:"myMappedDataTable",
  idFieldName:'ID'
)
mdt.dataAdd(ID:'1A', NAME:'alex')

def currentDir = new File(System.getProperty("user.dir"))
mdt.writeFiles(currentDir)

The result of this script will be two files in the current directory:

As noted above, mapped data tables have a primary key, which is enforced to be unique.

Example: Non-unique identifiers

@Grab(group='org.pmbb', module='carnival-util', version='0.2.6')

import carnival.util.MappedDataTable

def mdt = new MappedDataTable(
    name:"myMappedDataTable",
    idFieldName:'ID'
)

mdt.dataAdd(ID:'1A', NAME:'alex') mdt.dataAdd(ID:'1A', NAME:'bob')

This will cause an exception, since the ID ‘1A’ was already added to the data table.