Version Attributes

Versioned Attribute System

Introduction

Both nodes and edges use versioned attribute system, allowing the tracking of attribute changes over time and preserving historical context.

Core Concepts

The central idea behind the versioned attribute system is that we have a container (VersionedAttribute) that can hold multiple versions of an attribute (Attribute). Each Attribute carries its own value, which could be of different data types such as String, Boolean, or Integer.

Attribute

An Attribute is a simple key-value pair. The key is usually a string (the attribute's name) and the value can be of any type, for instance, String, Boolean, Integer, and so forth. The value type is encapsulated by AttributeValue implementations like StringAttributeValue, BooleanAttributeValue, etc.

Example:

var attribute = new LeafAttribute<>("attribute_name", new StringAttributeValue("attribute_value"));

VersionedAttribute

A VersionedAttribute is a container that holds multiple versions of an Attribute. Each version of the attribute in a VersionedAttribute shares the same name but may have different values and types. The versions are maintained in the order they were added, with the most recent one considered the "current" version.

Example:

var version1 = new LeafAttribute<>("attribute_name", new StringAttributeValue("value1"));
var version2 = new LeafAttribute<>("attribute_name", new StringAttributeValue("value2"));
var versionedAttribute = new ImmutableVersionedAttribute<>(version1, version2);

Rules

  • A VersionedAttribute cannot be empty. It must contain at least one attribute.
  • A VersionedAttribute can contain attributes of the same name but of different types.
  • A VersionedAttribute cannot be created with attributes of different names. All attributes inside a VersionedAttribute must share the same name.
  • Adding a new version of an attribute to a VersionedAttribute with a different name throws CannotAddNewVersionOfAttribute exception.
  • Merging two VersionedAttribute with different names throws CannotMergeTwoVersionedAttributes exception. bb- Two VersionedAttribute objects can be merged, combining their versions, using the mergeOverwrite method. In the resulting VersionedAttribute, the versions from the second object follow those of the first. The versions from the second object overwrite any matching versions from the first.