Example

Collections

Demonstrates how helix-collections helps track map access and retain historical values. Shows TrackingMap operation history and accessed keys, plus VersionedMap current and historical lookups.
Group
Library
Path
examples/library/collections

Overview

Helix Java application that shows how to use TrackingMap and VersionedMap from helix-collections.

Run this example from the shared examples build:

Run

Run this example from the shared examples build


./gradlew -p examples runExample -Pexample=library/collections --init-script "$(pwd)/helix.init.gradle"

What It Shows

  • using TrackingMap to record read, write, and delete operations against a wrapped map
  • retrieving the ordered operation history from TrackingMap
  • checking the set of accessed keys after a workflow runs
  • using VersionedMap to keep prior values for the same key
  • reading current values and historical versions from VersionedMap

Example Output

Helix collections example
tracking.current={customer=tier-2, status=active}
tracking.accessedKeys=[customer, region, status]
tracking.history=[WRITE:status, WRITE:customer, READ:status, READ:region, WRITE:customer]
versioned.current={customer=tier-2, status=active}
versioned.status.v0=draft
versioned.status.v1=active
versioned.customer.versions=[2=tier-1, 3=tier-2]

Development

Building the Application

Run the following command to build the application:

Command

Building the Application


./gradlew clean build

Testing the Application

Run the following command to run the application tests:

Command

Testing the Application


./gradlew test
./gradlew integration

Running the Example

Run the application and inspect the tracking and version snapshots:

Command

Running the Example


./gradlew run