Skip to content

Implement virtual links structures concept#1035

Open
konard wants to merge 3 commits into
masterfrom
issue-599-35bcce68
Open

Implement virtual links structures concept#1035
konard wants to merge 3 commits into
masterfrom
issue-599-35bcce68

Conversation

@konard

@konard konard commented Oct 26, 2025

Copy link
Copy Markdown
Owner

Summary

This PR implements the concept of virtual links structures as described in issue #599. Virtual links structures allow traditional table data (like strings, numbers, or binary data) to be accessed through a links-like interface without being physically stored in the links space.

What are Virtual Links Structures?

Virtual links structures are a design pattern that:

  • Store data in optimized formats (e.g., strings in a dictionary/table)
  • Present a links-like interface for uniform access
  • Are traversable like real links
  • Do not occupy space in the physical links database

Implementation Details

Core Components

  1. IVirtualLinksStructure (IVirtualLinksStructure.cs)

    • Defines the interface for virtual links structures
    • Provides GetSource(), GetTarget(), Contains() methods
    • Enables uniform access patterns across real and virtual links
  2. VirtualStringTable (VirtualStringTable.cs)

    • Example implementation for efficient string storage
    • Stores strings in a Dictionary (simulating a table)
    • Accessible through links interface without physical link storage
    • Demonstrates the core concept with a practical use case

Documentation & Examples

  1. Comprehensive Documentation (virtual-links-structures.md)

    • Detailed explanation of the concept
    • Use cases and benefits
    • Integration patterns
    • Future enhancement possibilities
  2. Demonstration Code (VirtualLinksStructureDemo.cs)

    • Interactive demonstration showing how virtual structures work
    • Examples of adding, accessing, and traversing virtual links
    • Educational tool for understanding the concept
  3. Integration Example (VirtualLinksIntegrationExample.cs)

    • Shows how virtual links integrate with real links systems
    • Practical scenario with entity relationships and string labels
    • Demonstrates ID space partitioning

Key Benefits

  • Efficient Storage: Data stored in optimal format for its type
  • Uniform Access: Same interface for real and virtual links
  • Traversable: Virtual structures can be navigated like real links
  • Reduced Overhead: No need to decompose complex data into individual links
  • Type Specialization: Different virtual structures for different data types

How It Addresses Issue #599

Issue #599 states:

"Each row in additional table can be represented as virtual links structure. It is possible to traverse this structure, but it not actually stored."

This implementation:

  • ✅ Represents table rows (strings) as virtual links
  • ✅ Allows traversal through GetSource() and GetTarget()
  • ✅ Stores data in a table (Dictionary), not in links space
  • ✅ Provides example with strings, but extensible to other data types

Example Usage

// Create a virtual string table with base ID of 1,000,000
var stringTable = new VirtualStringTable<long>(
    baseId: 1_000_000L,
    increment: x => x + 1,
    greaterThanOrEqual: (a, b) => a >= b,
    lessThan: (a, b) => a < b,
    subtract: (a, b) => a - b,
    add: (a, n) => a + n
);

// Add strings (stored in table, not as links)
var link1 = stringTable.Add("Hello");
var link2 = stringTable.Add("World");

// Access like links
var source = stringTable.GetSource(link1);  // Virtual source
var target = stringTable.GetTarget(link1);  // Virtual target
var exists = stringTable.Contains(link1);   // true

// Traverse virtual structure
stringTable.Traverse(link1, (link, src, tgt) => {
    Console.WriteLine($"Link: {link}, Source: {src}, Target: {tgt}");
});

Testing

  • ✅ Code compiles successfully (dotnet build passes)
  • ✅ Follows existing codebase patterns and style
  • ✅ Includes comprehensive examples and documentation

Future Enhancements

This foundation enables:

  • Virtual number tables for numeric data
  • Virtual binary tables for blob/file storage
  • Virtual time series for temporal data
  • Lazy virtual structures that generate links on-the-fly
  • Integration with external data sources

Related Issue

Fixes #599


🤖 Generated with Claude Code

Adding CLAUDE.md with task information for AI processing.
This file will be removed when the task is complete.

Issue: undefined
@konard konard self-assigned this Oct 26, 2025
Add core interfaces and implementations for virtual links structures,
which allow traditional table data to be accessed through a links-like
interface without being physically stored in the links space.

Key additions:
- IVirtualLinksStructure<TLink>: Interface defining virtual links API
- VirtualStringTable<TLink>: Example implementation for string storage
- Comprehensive documentation in doc/articles/virtual-links-structures.md
- Demonstration code in experiments/VirtualLinksStructureDemo.cs
- Integration example in examples/VirtualLinksIntegrationExample.cs

This addresses issue #599 by demonstrating how each table can be
represented as a virtual links structure that is traversable but not
physically stored in the links database.

Benefits:
- Efficient storage for specialized data types
- Uniform access pattern across real and virtual links
- Reduced overhead compared to decomposing data into individual links
- Type-specific optimization opportunities

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@konard konard changed the title [WIP] Each table as a virtual links structure Implement virtual links structures concept Oct 26, 2025
@konard konard marked this pull request as ready for review October 26, 2025 10:28
@konard

konard commented Oct 26, 2025

Copy link
Copy Markdown
Owner Author

🤖 Solution Draft Log

This log file contains the complete execution trace of the AI solution draft process.

📎 Log file uploaded as GitHub Gist (342KB)
🔗 View complete solution draft log


Now working session is ended, feel free to review and add any feedback on the solution draft.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Each table as a virtual links structure

1 participant