XAP

Property Annotations

The GigaSpaces API supports field-level decorations with PONOs. These can be specified via annotations on the space class source itself. The annotations are defined on the getter methods.

SpaceId

Syntax SpaceId AutoGenerate
Argument boolean
Default false
Description Defines whether this field value is used when generating the Object ID. The field value should be unique – i.e., no multiple objects with the same value should be written into the space (each object should have a different field value). When writing an object into the space with an existing id field value, an EntryAlreadyInSpaceException is thrown. The Object ID is created, based on the id field value.
Specifies if the object ID is generated automatically by the space when written into the space. If false, the field is indexed automatically, and if true, the field isn't indexed. If autoGenerate is declared as false, the field is indexed automatically. If autoGenerate is declared as true, the field isn't indexed. If AutoGenerate is true, the field must be of the type String.

Example:

[SpaceClass]
public class Person {

  [SpaceId(AutoGenerate=false)]
  public long? Id {set; get;}

}

SpaceRouting

Syntax SpaceRouting
Description The [SpaceRouting] annotation specifies a get method for the field to be used to calculate the target space for the space operation (Read , Write...). The [SpaceRouting] field value hash code is used to calculate the target space when the space is running in partitioned mode.

Example:

[SpaceClass]
public class Employee {

  [SpaceId]
  [SpaceRouting]
  public long DepartmentId {set; get}

}

Data Partitioning

SpaceProperty

Syntax SpaceProperty NullValue
Argument nullValue
Default null
Description Specifies that a property value be treated as null when the object is written to the space and no value is assigned to the attribute. (where -1 functions as a null value in case of an int)

Example:

[SpaceClass]
public class Employee {

  [SpaceProperty(NullValue="-1")]
  public int Age {set; get;}
}

}

SpaceIndex

Syntax SpaceIndex Type
Argument SpaceIndexType
Description Querying indexed fields speeds up read and take operations. The [SpaceIndex] annotation should be used to specify an indexed field.

Example:

[SpaceClass]
public class User {
    [SpaceIndex(Type = SpaceIndexType.Basic)]
    public String Name {set; get;}

    [SpaceIndex(Type = SpaceIndexType.Extended)]
    public double Balance{set; get;}
}

Unique Index

Syntax SpaceIndex Type, Unique
Argument SpaceIndexType
Description Unique constraints can be defined for an attribute or attributes of a space class.
Note The uniqueness is enforced per partition and not over the whole cluster.

Example:

[SpaceClass]
public class Person
{
    [SpaceIndex(Type=SpaceIndexType.Basic, Unique=true)]
    public String LastName{ get; set; }

}

SpaceIndex Path

Syntax SpaceIndex Path ,Type
Argument SpaceIndexType
Description The path() attribute represents the path of the indexed property within a nested object.

Example:

[SpaceClass]
public class Person {

   [SpaceIndex(Path = "SocialSecurity", Type = SpaceIndexType.Extended)]
   public Info PersonalInfo{ get; set; }
}

public class Info : Serializable {
    public String Name { get; set; }
    public Address Address{ get; set; }
    public Date Birthday { get; set; }
    public long SocialSecurity{ get; set; }
}

SpaceVersion

Syntax SpaceVersion
Description This annotation is used for object versioning used for optimistic locking.
Note The attribute must be an int data type.

Example:

[SpaceClass]
public class Employee {

  [SpaceVersion]
  public int Version { get; set; }

}

SpacePersist

Syntax SpacePersist
Description This specifies a getter method for holding the persistency mode of the object overriding the class level persist declaration. This field should be of the boolean data type.
If the persist class level annotation is true, all objects of this class type will be persisted into the underlying data store (MirrorClosed Performs the replication of changes to the target table or accumulation of source table changes used to replicate changes to the target table at a later time. If you have implemented bidirectional replication in your environment, mirroring can occur to and from both the source and target tables., ExternalDataSource, Storage Adapter).
Note When using this option, you must have the space class level persist decoration specified.

Example:

[SpaceClass(Persist=true)
public class Employee {

  [SpacePersist]
  public Bool Persist{ get; set; }
}

SpaceExclude

Syntax SpaceExclude
Description When this annotation is specified the attribute is not written into the space.

Example:

[SpaceClass]
public class Employee {

  [SpaceExclude]
  public String MothersName{ get; set; }
}

SpaceStorageType

Syntax SpaceStorageType StorageType
Argument StorageType
Default StorageType.Object
Description This annotation is used to specify how the attribute is stored in the space.

Example:

[SpaceClass]
public class Message {

  [SpaceStorageType(storageType=StorageType.BINARY)]
  public String PayLoad{ get; set; }

}

SpaceFifoGroupingProperty

Syntax SpaceFifoGroupingProperty Path
Argument path
Description This annotation is used to define a space FIFOClosed FIFO is an acronym for first in, first out, a method for organizing the manipulation of a data structure where the oldest entry, or "head" of the queue, is processed first. grouping property.
Note If defined, the TakeModifiers.FIFO_GROUPING_POLL or ReadModifiers.FIFO_GROUPING_POLL modifiers can be used to return all space entries that match the selection template in FIFO order. Different values of the FG property define groups of space entries that match each value. FIFO ordering exists within each group and not between different groups.

Example:

[SpaceClass]
public class FlightReservation
{
    [SpaceFifoGroupingProperty(Path = "FlightNumber")]
    public FlightInfo Info { get; set; }

}

SpaceFifoGroupingIndex

Syntax SpaceFifoGroupingIndex Path
Description This annotation is used to define a space FIFO grouping Index.
Note This annotation can be declared on several properties in a class in order to assist in efficient traversal.
If defined, there must be a property in the class, marked with the [SpaceFifoGroupingProperty] annotation.
A compound index that contains this FIFO grouping index and the FIFO grouping property will be created.

Example:

[SpaceFifoGroupingIndex]
public State ProcessingState { get; set; }
[SpaceFifoGroupingIndex(Path = "Id")]
public Person Customer { get; set; }

SpaceDynamicProperties

Syntax SpaceDynamicProperties
Description Allows adding properties freely to a class without worrying about the schema.
Note Only one property per class can be annotated with [SpaceDynamicProperties].

Example:

[SpaceClass]
public class Person {

    public String Name { get; set; }

    [SpaceDynamicProperties]
    public DocumentProperties ExtraInfo { get; set; }
}

Alias Name

Syntax AliasName
Description In some cases, usually in interoperability scenarios, you may need to map your C# properties to different names in the SpaceClosed Where GigaSpaces data is stored. It is the logical cache that holds data objects in memory and might also hold them in layered in tiering. Data is hosted from multiple SoRs, consolidated as a unified data model.. You can do that using the AliasName property on [SpaceProperty].
Note When using space SqlQuery on an object with properties which are aliased, the query text needs to use the aliased property names. For more information about SqlQuery, see GigaSpaces.NET - Sql Query.

Example:

[SpaceClass]
public class Person {

 [SpaceProperty(AliasName="firstName")]
 public String FirstName {set; get;}

}