-
Notifications
You must be signed in to change notification settings - Fork 2
SpaceRepository Class
Represents a strongly typed set of tuples that can be access through pattern matching. Provides methods to query and manipulate the set.
System.Object
public class SpaceRepository : RepositoryBase, IRepository
Name | Description |
---|---|
Space() | Initializes a new instance of the Space class that is empty. |
Name | Description |
---|---|
ISpace.Get(IPattern) | Retrieves and removes the first tuple from the ISpace, matching the specified pattern. The operation will block if no elements match. |
ISpace.Get(object[]) | Retrieves and removes the first tuple from the ISpace, matching the specified pattern. The operation will block if no elements match. |
ISpace.GetP(IPattern) | Retrieves and removes the first tuple from the ISpace, matching the specified pattern. The operation is non-blocking. The operation will return null if no elements match. |
ISpace.GetP(object[]) | Retrieves and removes the first tuple from the ISpace, matching the specified pattern. The operation is non-blocking. The operation will return null if no elements match. |
ISpace.GetAll(IPattern) | Retrieves and removes all tuples from the ISpace matching the specified pattern. The operation is non-blocking. The operation will return an empty set if no elements match. |
ISpace.GetAll(object[]) | Retrieves and removes all tuples from the ISpace matching the specified pattern. The operation is non-blocking. The operation will return an empty set if no elements match. |
ISpace.Query(IPattern) | Retrieves the first tuple from the ISpace, matching the specified pattern. The operation will block if no elements match. |
ISpace.Query(object[]) | Retrieves the first tuple from the ISpace, matching the specified pattern. The operation will block if no elements match. |
ISpace.QueryP(IPattern) | Retrieves the first tuple from the ISpace, matching the specified pattern. The operation is non-blocking. The operation will return null if no elements match. |
ISpace.QueryP(object[]) | Retrieves the first tuple from the ISpace, matching the specified pattern. The operation is non-blocking. The operation will return null if no elements match. |
ISpace.QueryAll(IPattern) | Retrieves all tuples from the ISpace matching the specified pattern. The operation is non-blocking. The operation will return an empty set if no elements match. |
ISpace.QueryAll(object[]) | Retrieves all tuples from the ISpace matching the specified pattern. The operation is non-blocking. The operation will return an empty set if no elements match. |
ISpace.Put(ITuple) | Inserts the tuple passed as argument into the ISpace. |
ISpace.Put(object[]) | Inserts the tuple passed as argument into the ISpace. |
The Space class is a threadsafe data structure. It implements the ISpace interface.
You can add tuples to a Space by using the Put methods. Conversely, tuples can be fetched through Query,QueryP, QueryAll, Get, GetP and GetAll.
Please note that all variants of the Get operations not only fetches the tuple(s), but also removes them from the space.
The Space class utilizes an internal hashmap for partitioning. Upon insertion of a Tuple, the hashvalue of the tuple is computed by the tuple signature. The tuple is then placed in a partition matching the hashvalue. This means that for each unique tuple signature, a partition is created. Subsequently, the searching time is reduced to the partition size.
When fetching tuples, the underlying parition in the tuple space is searched linearly. The worstcase runtime is thus O(n) where n is number of elements in the partition.
The Space class utilizes a Readers-Writer-locking mechanism. This means that the multiple concurrent Query operations is possible. Furthermore, because the underlying set is partitioned, multiple Get and Put are possible, as long they are performed on seperate partitions.
Tuples are retrieved by FIFO ordering with respect to the underlying partitions.