Skip to content
GigaSpaces Logo GigaSpaces Logo
  • Products
    • InsightEdge Portfolio
      • Smart Cache
      • Smart ODS
      • Smart Augmented Transactions
    • GigaSpaces Cloud
  • Roles
    • Architects
    • CXOs
    • Product Teams
  • Solutions
    • Industry Solutions
      • Financial Services
      • Insurance
      • Retail and eCommerce
      • Telecommunications
      • Transportations
    • Technical Solutions
      • Operational BI
      • Mainframe & AS/400 Modernization
      • In Memory Data Grid
      • Transactional and Analytical Processing (HTAP)
      • Hybrid Cloud Data Fabric
      • Multi-Tiered Storage
      • Kubernetes Deployment
      • Streaming Analytics for Stateful Apps
  • Customers
  • Company
    • About GigaSpaces
    • Customers
    • Partners
    • Support & Services
      • University
      • Services
      • Support
    • News
    • Contact Us
    • Careers
  • Resources
    • Webinars
    • Blog
    • Demos
    • Solution Briefs & Whitepapers
    • Case Studies
    • Benchmarks
    • ROI Calculators
    • Analyst Reports
    • eBooks
    • Technical Documentation
  • Contact Us
  • Try Free

Schema evolution in XAP.NET 8.0.1

Subscribe to our blog!

Subscribe for Updates
Close
Back

Schema evolution in XAP.NET 8.0.1

GigaSpaces April 7, 2011
3 minutes read

GigaSpaces XAP.NET 8.0.1 introduces a few cool new features such as SpaceDocument (code name: Docu.NET API) as well as dynamic properties. Roughly speaking, a SpaceDocument is a virtual document-like type that can be written and read from the space like any other regular object, however, it provides a more dynamic API by having a key value dictionary in its properties instead of fixed properties that are part of the class code. Even though a document is dynamic, it fully supports indexing and even more powerfully so, since 8.0 now supports dynamic addition of indexes, it also supports indexing defined at runtime using the dynamic indexing capability (indexes can be added via the GigaSpaces management center at runtime).

Lets demonstrate this by evolving our beloved creature Nimbin.

SpaceDocument nimbin = new SpaceDocument(“Creature”);
// First schema of our creature
nimbin [“Name”] = “Nimbin”;
nimbin [“Age”] = 4;
nimbin [“Sex”] = Sex.Male;
nimbin [“DigestableFood”] = new String[]{“Carrot, Apple”};
// Write Nimbin to the space
spaceProxy.Write(nimbin);

After a while Nimbin has evolved and grown some new limbs.

// Get Nimbin and “evolve” it. 
SpaceDocument nimbin = spaceProxy.ReadById(new IdQuery<SpaceDocument>(“Creature”, “Nimbin”));
Dictionary<String, Object> tailDetails = new  Dictionary<String, Object>();
tailDetails[“Color”] = Colors.Green;
tailDetails[“Length”] = 1.5;
nimbin[“Tail”] =  tailDetails;
// Update Nimbin in the space:
spaceProxy.Write(document);

As seen here the document can contain nested properties which are key value dictionaries as well, in this case the newly added tail of Nimbin. A SpaceDocument is also fully interoperable with a regular concrete Object, we can have a corresponding class of the “Creature” that can support dynamic properties in dictionary form (or even without the dynamic properties, by having the object ignore the dynamic properties).
Let’s define a class for our Creature:

public class Creature
{
[SpaceID]
public String Name{ get; set; }
[SpaceIndex(Type=SpaceIndexType.Extended)]
public Int Age{ get; set; }
public Sex Sex{ get; set; }
public String[] DigestableFood{ get; set; }
[SpaceDynamicProperties]
public Dictionary<String, Object> { get; set; }
}

We can read Nimbin as the actual creature class as well:

Creature concreteNimbin = spaceProxy.ReadById<Creature>(“Nimbin”);
//We can also query for all creatures that have a tail shorter than 1.
SqlQuery<Creature> query = new SqlQuery<Creature>(“Tail.Length < ?”);
query.SetParameter(1, 1.0);
Creature[] shotTailCreatures = spaceProxy.ReadMultiple<Creature>(query);

The Docu.NET API is vast and contains many more capabilities such as the Document wrapper type that enables the use of dynamic SpaceDocuments while using it as a concrete object look and feel.

Cheers,
Eitan Yanovsky

CATEGORIES

  • .Net
  • Application Architecture
  • GigaSpaces
GigaSpaces

All Posts (23)

YOU MAY ALSO LIKE

September 20, 2008

Go out there and start…
9 minutes read

August 18, 2008

GigaSpaces XAP 6.5/6.6 new releases
13 minutes read

April 5, 2008

Speaking at the Virtualization Conference
1 minutes read
  • Copied to clipboard

PRODUCTS, SOLUTIONS & ROLES

  • Products
  • InsightEdge Portfolio
    • Smart Cache
    • Smart ODS
    • Smart Augmented Transactions
    • Compare InsightEdge Products
  • GigaSpaces Cloud
  • Roles
  • Architects
  • CXOs
  • Product Teams
  • Solutions
  • Industry
    • Financial Services
    • Insurance
    • Retail and eCommerce
    • Telecommunications
    • Transportation
  • Technical
    • Operational BI
    • Mainframe & AS/400 Modernization
    • In Memory Data Grid
    • HTAP
    • Hybrid Cloud Data Fabric
    • Multi-Tiered Storage
    • Kubernetes Deployment
    • Streaming Analytics for Stateful Apps

RESOURCES

  • Resource Hub
  • Webinars
  • Blogs
  • Demos
  • Solution Briefs & Whitepapers
  • Case Studies
  • Benchmarks
  • ROI Calculators
  • Analyst Reports
  • eBooks
  • Technical Documentation
  • Featured Case Studies
  • Mainframe Offload with Groupe PSA
  • Digital Transformation with Avanza Bank
  • High Peak Handling with PriceRunner
  • Optimizing Business Communications with Avaya

COMPANY

  • About
  • Customers
  • Management
  • Board Members
  • Investors
  • News
  • Events
  • Careers
  • Contact Us
  • Book A Demo
  • Try GigaSpaces For Free
  • Partners
  • OEM Partners
  • System Integrators
  • Value Added Resellers
  • Technology Partners
  • Support & Services
  • University
  • Services
  • Support
Copyright © GigaSpaces 2021 All rights reserved | Privacy Policy
LinkedInTwitterFacebookYouTube

Contact Us