Difference between revisions of "GCube Document Library (2.0)"
(→Advanced Projections) |
(→Utilities & F.A.Q.) |
||
(67 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
− | The '''gCube Document Library (gDL)''' is a client library for | + | The '''gCube Document Library (gDL)''' is a client library for adding, updating, deleting and retrieving document descriptions to, in, and from remote collections in a gCube infrastructure. |
The gDL is a high-level component of the subsystem of [[GCube_Information_Organisation_Services_(NEW)|gCube Information Services]] and it interacts with lower-level components of the subsystem to support document management processes within the infrastructure: | The gDL is a high-level component of the subsystem of [[GCube_Information_Organisation_Services_(NEW)|gCube Information Services]] and it interacts with lower-level components of the subsystem to support document management processes within the infrastructure: | ||
* the [[GCube_Document_Model#Overview|gCube Document Model]] (gDM) defines the basic notion of document and the [[GCube_Document_Model#Implementation|gCube Model Library]] (gML) implements that notion into objects; | * the [[GCube_Document_Model#Overview|gCube Document Model]] (gDM) defines the basic notion of document and the [[GCube_Document_Model#Implementation|gCube Model Library]] (gML) implements that notion into objects; | ||
− | * the objects of the gML can be exchanged in the infrastructure as edge-labelled trees, and the [[Content_Manager_Library|Content Manager Library]] (CML) can | + | * the objects of the gML can be exchanged in the infrastructure as edge-labelled trees, and the [[Content_Manager_Library|Content Manager Library]] (CML) can dispatch them to the read and write operations of the [[Content_Manager_(NEW)|Content Manager]] (CM) service; |
− | * the CM implements | + | * the CM implements its operations by translating trees to and from the content models of diverse repository back-ends. |
The gDL builds on the gML and the CML to implement a local interface of <code>CRUD</code> operations that lift those of the CM to the domain of documents, efficiently and effectively. | The gDL builds on the gML and the CML to implement a local interface of <code>CRUD</code> operations that lift those of the CM to the domain of documents, efficiently and effectively. | ||
Line 11: | Line 11: | ||
= Preliminaries = | = Preliminaries = | ||
− | The core functionality of the gDL lies in its operations to read and write | + | The core functionality of the gDL lies in its operations to read and write document descriptions. The operations trigger interactions with the [[Content_Manager_(NEW)|Content Manager]] service and the movement of potentially large volumes of data across the infrastructure. This may have a non-trivial and combined impact on the responsiveness of clients and the overall load of the infrastructure. The operations have been designed to minimise this impact. In particular: |
− | * when reading, clients can qualify the documents that are relevant to their queries, and indeed what properties of | + | * when reading, clients can qualify the documents that are relevant to their queries, and indeed what properties of those documents should be actually retrieved. These retrieval directives are captured in the gDL by the notion of [[#Projections|document projections]]. |
− | * when reading and writing, clients can move large numbers of documents across the infrastructure. The gDL ''streams'' this I/O movements so as to make efficient use of local and remote resources. It then defines a facilities with which clients can conveniently consume input streams, produce output streams, and more generally | + | * when reading and writing, clients can move large numbers of documents across the infrastructure. The gDL ''streams'' this I/O movements so as to make efficient use of local and remote resources. It then defines a facilities with which clients can conveniently consume input streams, produce output streams, and more generally convert one stream into an other regardless of its origin. These facilities are collected into the [[#Streams|stream DSL]], an Embedded Domain-Specific Language (EDSL) for stream conversion and processing. |
− | Understanding document projections and the stream DSL is key to reading and writing documents effectively. We discuss these preliminary concepts first, and then consider their use as input and outputs | + | Understanding document projections and the stream DSL is key to reading and writing documents effectively with the gDL. We discuss these preliminary concepts first, and then consider their use as input and outputs in read and write the operations of the library. |
== Projections == | == Projections == | ||
− | A projection is a set of constraints over the properties of | + | A projection is a set of constraints over the properties of document descriptions. It can be be used in the [[#Reading Documents|read operations]] of the gDL to: |
− | + | ||
− | + | ||
− | * | + | * characterise relevant descriptions as those that ''match'' the constraints (''projections as types''); |
− | * | + | * specify what properties of relevant descriptions should be retrieved (''projections as retrieval directives''). |
− | + | Constraints take accordingly two forms: | |
* '''include constraints''' apply to properties that must be matched ''and'' retrieved; | * '''include constraints''' apply to properties that must be matched ''and'' retrieved; | ||
* '''filter constraints''' apply to properties that must be matched but ''not'' retrieved. | * '''filter constraints''' apply to properties that must be matched but ''not'' retrieved. | ||
− | '''note''': in both cases, the constraints take the form of 'predicates' of the [[Content_Manager_Library|Content Manager Library] (CML) | + | '''note''': in both cases, the constraints take the form of ''predicates'' of the [[Content_Manager_Library|Content Manager Library]] (CML). The projection itself converts into a complex predicate which is amenable for processing by the Content Manager service in the execution of its retrieval operations. In this sense, projections are a key part of the document-oriented layer that the gDL defines over lower-level components of the gCube [[GCube_Information_Organisation_Services_(NEW)|subsystem dedicated]] to content management. |
− | As a | + | As a first example, a projection may specify an include constraint over the name of metadata elements and a filter constraint over the time of last update. It may then be used to: |
− | + | ||
− | It may then be used to: | + | |
− | * characterise | + | * characterise document descriptions with at least one metadata element that matches both constraints; |
− | * retrieve of those | + | * retrieve of those descriptions only the name of matching metadata elements, excluding the time of last update, any other metadata property, and any other document property, include other inner elements and their properties. |
− | + | Projections have the <code>Projection</code> interface, which can be used to access their constraints in element-generic computations. To build projections, however, clients deal with one of the following implementation of the interface: | |
* <code>DocumentProjection</code> | * <code>DocumentProjection</code> | ||
Line 54: | Line 50: | ||
* <code>PropertyProjection</code> | * <code>PropertyProjection</code> | ||
− | allows clients to express constraints on the generic properties of | + | allows clients to express constraints on the generic properties of documents and their inner elements. |
− | + | [[GDL_Projections_(2.0)|read more...]] | |
− | + | == Streams == | |
− | + | In some of its operations, the gDL relies on streams to model, process, and transfer large-scale data collections. Streams may consist of document descriptions, document identifiers, and document updates. More generally, they may consist of the outcomes of operations that take in turn large-scale collections in input. Streamed processing makes efficient use of both local and remote resources, from local memory to network bandwidth, promoting the overall responsiveness of clients and services through reduced latencies. | |
− | + | ||
− | + | ||
− | + | ||
− | + | Clients that use these operations will need to route streams towards and across the operations of the gDL, converting between different stream interfaces, often injecting application logic in the process. As a common example, a client may need to: | |
− | + | * route a remote result set of document identifiers towards the read operations of the gDL; | |
+ | * process the document descriptions returned by the read operations, e.g. in order to update some of their properties; | ||
+ | * feed the modified document descriptions to the write operations of the gDL, so as to commit the changes; | ||
+ | * inspect commit outcomes, so as to report or otherwise handle the failures that may have occurred in the process. | ||
− | + | Throughout the workflow, it is important that the client remains within the paradigm of streamed processing, avoiding the accumulation of data in memory in all cases but where strictly required. Document identifiers will be streaming from the remote location of the original result set ''as'' documents descriptions will be flowing back from yet another remote location, ''as'' updated document descriptions will be leaving towards the same remote location, and ''as'' failures will be steadily coming back for handling. | |
− | + | Streaming raises significant opportunities for clients, as well as non-trivial challenges. In recognition of the difficulties, the gDL includes a set of general-purpose facilities for stream conversion that simplify the tasks of filtering, transforming, or otherwise processing streams. These facilities are cast as the sentences of the '''Stream DSL''', an Embedded Domain-Specific Language (EDSL). | |
− | + | [[GDL_Streams_(2.0)|read more...]] | |
− | + | = Operations = | |
− | + | The operations of the gDL allows clients to add, update, delete, and retrieve document descriptions to, in, and from remote collections within the infrastructure. These <code>CRUD</code> operations target (instances of) a specific back-end within the infrastructure, the [[Content_Manager_(NEW)|Content Manager]] (CM) service. It is a direct implication of the CM that the document descriptions may be stored in different forms within repositories which are inside or outside the strict boundaries of the infrastructure. While the gDL operations clearly expose the remote nature of document descriptions, the actual location of document descriptions, hosting repositories, and Content Manager instances is hidden to their clients. | |
− | + | In what follows, we discuss first ''read operations'', i.e. operations that localise document descriptions from remote collections. We then discuss ''write operations'', i.e. operations that persist in remote collections document descriptions which have been created or else modified locally. In all cases, operations are overloaded to work with different forms of inputs and outputs. In particular, we distinguish between: | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | * '''singleton operations''': these are operations that read, add, or change individual document descriptions. Singleton operations are used for punctual interactions with the infrastructure, most noticeably those required by front-end clients to implement user interfaces. All singleton operations that target existing document descriptions require the specifications of their identifiers; | |
+ | |||
+ | * '''bulk operations''': these are operations that read, add, or change multiple document descriptions in a single interaction with the infrastructure. Bulk operations can be used for batch interactions with the infrastructure, most noticeably those required by back-end clients to implement workflows. They can also be used for real-time interactions with the infrastructure, such as those required by front-end clients that process user queries. Bulk operations may be further classified in: | ||
+ | ** '''by-value operations''' are defined over in-memory collections of document descriptions. Accordingly, these operations are indicated for small-scale data transfer scenarios. As we shall see, they may also be used to move segments of larger data collections, when the creation of such fragments is a functional requirement. | ||
+ | ** '''by-reference operations''' are defined over [[#Streams|streams]] of document descriptions. These operations are indicated for medium-scale to large-scale data transfer scenarios, where the streamed processing promotes the responsiveness of clients and the effective use of network resources. | ||
− | + | Read and write operations work with document descriptions that align with the [[GCube_Document Model|gCube document model]] (gDM) and its implementation in the [[GCube_Document_Model#Implementation|gCube Model Library]] (gML). In the terminology of the gML, in particular, operations that create document descriptions expect [[GCube_Document_Model#New_Elements_and_Element_Proxies|new elements]], all the others take or produce [[GCube_Document_Model#New_Elements_and_Element_Proxies|element proxies]]. | |
− | + | Finally, read and write operations build on the facilities of the [[Content_Manager_Library| Content Manager Library]] (CML) to interact with the Content Manager service, including the adoption of [[Content_Manager_Library#High-Level Calls|best-effort strategies]] to discover and interact with instances of the service. These facilities are thus indirectly available to gDL clients as well. | |
− | + | [[GDL_Operations_(2.0)|read more...]] | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
+ | = Views = | ||
− | + | Some clients interact with remote collections to work exclusively with subsets of document descriptions that share certain properties, e.g. are in a given language, have changed in the last month, have metadata in a given schema, have parts of a given type, and so on. Their queries and updates are always resolved within these subsets, rather than the whole collection. Essentially, such clients have their own ''view'' of the collection. | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | ''' | + | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | The gDL offers support for working with two types of view: | |
− | + | * '''local views''': these are views defined by individual clients as the context for a number of subsequent queries and updates. Local views may have arbitrary long lifetimes, and may even outlive the client that created them, they are never used by multiple clients. Thus local views are commonly transient and if their definitions are somehow persisted, they are persisted locally to the 'owning' client and remain under its direct responsibility. | |
− | + | * '''remote views''': these are views defined by some clients and used by many others within the system. Remote views outlive all such clients and persist in the infrastructure, typically for as long as the collection does. They are defined through the [[View_Manager|View Manager]] service (VM), which materialises them as WS-Resources. Each VM resource encapsulates the definition of the view as well as its descriptive properties, and it is responsible for managing its lifetime, e.g. keep track of its cardinality and notify interested clients of changes to its contents. However, VM resources are [[View_Manager#Motivations|passive'']], i.e. do not mediate access to those content resources. | |
− | + | Naturally, the gDL uses [[#Projections|projections]] as view definitions. It then offers specialised <code>Reader</code>s that encapsulate such projections to implicitly resolve all their operations in the scope of the view. This yields view-based access to collections and allows clients to work with local views. In addition, the gDL provides local proxies of VM resources with which clients can create, discover, and inspect remote views. As these proxies map remote view definitions onto projections, remote views can be accessed with the same reading mechanisms available for local views. | |
− | + | [[GDL_Views_(2.0)|read more...]] | |
− | = | + | = Utilities & F.A.Q. = |
− | + | The GCube Document Library offers utility classes to manage the collections and the views in the system. | |
− | + | [[GDL_Utilities_%26_F.A.Q._(2.0)|read more...]] |
Latest revision as of 12:21, 21 March 2011
The gCube Document Library (gDL) is a client library for adding, updating, deleting and retrieving document descriptions to, in, and from remote collections in a gCube infrastructure.
The gDL is a high-level component of the subsystem of gCube Information Services and it interacts with lower-level components of the subsystem to support document management processes within the infrastructure:
- the gCube Document Model (gDM) defines the basic notion of document and the gCube Model Library (gML) implements that notion into objects;
- the objects of the gML can be exchanged in the infrastructure as edge-labelled trees, and the Content Manager Library (CML) can dispatch them to the read and write operations of the Content Manager (CM) service;
- the CM implements its operations by translating trees to and from the content models of diverse repository back-ends.
The gDL builds on the gML and the CML to implement a local interface of CRUD
operations that lift those of the CM to the domain of documents, efficiently and effectively.
Preliminaries
The core functionality of the gDL lies in its operations to read and write document descriptions. The operations trigger interactions with the Content Manager service and the movement of potentially large volumes of data across the infrastructure. This may have a non-trivial and combined impact on the responsiveness of clients and the overall load of the infrastructure. The operations have been designed to minimise this impact. In particular:
- when reading, clients can qualify the documents that are relevant to their queries, and indeed what properties of those documents should be actually retrieved. These retrieval directives are captured in the gDL by the notion of document projections.
- when reading and writing, clients can move large numbers of documents across the infrastructure. The gDL streams this I/O movements so as to make efficient use of local and remote resources. It then defines a facilities with which clients can conveniently consume input streams, produce output streams, and more generally convert one stream into an other regardless of its origin. These facilities are collected into the stream DSL, an Embedded Domain-Specific Language (EDSL) for stream conversion and processing.
Understanding document projections and the stream DSL is key to reading and writing documents effectively with the gDL. We discuss these preliminary concepts first, and then consider their use as input and outputs in read and write the operations of the library.
Projections
A projection is a set of constraints over the properties of document descriptions. It can be be used in the read operations of the gDL to:
- characterise relevant descriptions as those that match the constraints (projections as types);
- specify what properties of relevant descriptions should be retrieved (projections as retrieval directives).
Constraints take accordingly two forms:
- include constraints apply to properties that must be matched and retrieved;
- filter constraints apply to properties that must be matched but not retrieved.
note: in both cases, the constraints take the form of predicates of the Content Manager Library (CML). The projection itself converts into a complex predicate which is amenable for processing by the Content Manager service in the execution of its retrieval operations. In this sense, projections are a key part of the document-oriented layer that the gDL defines over lower-level components of the gCube subsystem dedicated to content management.
As a first example, a projection may specify an include constraint over the name of metadata elements and a filter constraint over the time of last update. It may then be used to:
- characterise document descriptions with at least one metadata element that matches both constraints;
- retrieve of those descriptions only the name of matching metadata elements, excluding the time of last update, any other metadata property, and any other document property, include other inner elements and their properties.
Projections have the Projection
interface, which can be used to access their constraints in element-generic computations. To build projections, however, clients deal with one of the following implementation of the interface:
-
DocumentProjection
-
MetadataProjection
-
AnnotationProjection
-
PartProjection
-
AlternativeProjection
A further implementation of the interface:
-
PropertyProjection
allows clients to express constraints on the generic properties of documents and their inner elements.
Streams
In some of its operations, the gDL relies on streams to model, process, and transfer large-scale data collections. Streams may consist of document descriptions, document identifiers, and document updates. More generally, they may consist of the outcomes of operations that take in turn large-scale collections in input. Streamed processing makes efficient use of both local and remote resources, from local memory to network bandwidth, promoting the overall responsiveness of clients and services through reduced latencies.
Clients that use these operations will need to route streams towards and across the operations of the gDL, converting between different stream interfaces, often injecting application logic in the process. As a common example, a client may need to:
- route a remote result set of document identifiers towards the read operations of the gDL;
- process the document descriptions returned by the read operations, e.g. in order to update some of their properties;
- feed the modified document descriptions to the write operations of the gDL, so as to commit the changes;
- inspect commit outcomes, so as to report or otherwise handle the failures that may have occurred in the process.
Throughout the workflow, it is important that the client remains within the paradigm of streamed processing, avoiding the accumulation of data in memory in all cases but where strictly required. Document identifiers will be streaming from the remote location of the original result set as documents descriptions will be flowing back from yet another remote location, as updated document descriptions will be leaving towards the same remote location, and as failures will be steadily coming back for handling.
Streaming raises significant opportunities for clients, as well as non-trivial challenges. In recognition of the difficulties, the gDL includes a set of general-purpose facilities for stream conversion that simplify the tasks of filtering, transforming, or otherwise processing streams. These facilities are cast as the sentences of the Stream DSL, an Embedded Domain-Specific Language (EDSL).
Operations
The operations of the gDL allows clients to add, update, delete, and retrieve document descriptions to, in, and from remote collections within the infrastructure. These CRUD
operations target (instances of) a specific back-end within the infrastructure, the Content Manager (CM) service. It is a direct implication of the CM that the document descriptions may be stored in different forms within repositories which are inside or outside the strict boundaries of the infrastructure. While the gDL operations clearly expose the remote nature of document descriptions, the actual location of document descriptions, hosting repositories, and Content Manager instances is hidden to their clients.
In what follows, we discuss first read operations, i.e. operations that localise document descriptions from remote collections. We then discuss write operations, i.e. operations that persist in remote collections document descriptions which have been created or else modified locally. In all cases, operations are overloaded to work with different forms of inputs and outputs. In particular, we distinguish between:
- singleton operations: these are operations that read, add, or change individual document descriptions. Singleton operations are used for punctual interactions with the infrastructure, most noticeably those required by front-end clients to implement user interfaces. All singleton operations that target existing document descriptions require the specifications of their identifiers;
- bulk operations: these are operations that read, add, or change multiple document descriptions in a single interaction with the infrastructure. Bulk operations can be used for batch interactions with the infrastructure, most noticeably those required by back-end clients to implement workflows. They can also be used for real-time interactions with the infrastructure, such as those required by front-end clients that process user queries. Bulk operations may be further classified in:
- by-value operations are defined over in-memory collections of document descriptions. Accordingly, these operations are indicated for small-scale data transfer scenarios. As we shall see, they may also be used to move segments of larger data collections, when the creation of such fragments is a functional requirement.
- by-reference operations are defined over streams of document descriptions. These operations are indicated for medium-scale to large-scale data transfer scenarios, where the streamed processing promotes the responsiveness of clients and the effective use of network resources.
Read and write operations work with document descriptions that align with the gCube document model (gDM) and its implementation in the gCube Model Library (gML). In the terminology of the gML, in particular, operations that create document descriptions expect new elements, all the others take or produce element proxies.
Finally, read and write operations build on the facilities of the Content Manager Library (CML) to interact with the Content Manager service, including the adoption of best-effort strategies to discover and interact with instances of the service. These facilities are thus indirectly available to gDL clients as well.
Views
Some clients interact with remote collections to work exclusively with subsets of document descriptions that share certain properties, e.g. are in a given language, have changed in the last month, have metadata in a given schema, have parts of a given type, and so on. Their queries and updates are always resolved within these subsets, rather than the whole collection. Essentially, such clients have their own view of the collection.
The gDL offers support for working with two types of view:
- local views: these are views defined by individual clients as the context for a number of subsequent queries and updates. Local views may have arbitrary long lifetimes, and may even outlive the client that created them, they are never used by multiple clients. Thus local views are commonly transient and if their definitions are somehow persisted, they are persisted locally to the 'owning' client and remain under its direct responsibility.
- remote views: these are views defined by some clients and used by many others within the system. Remote views outlive all such clients and persist in the infrastructure, typically for as long as the collection does. They are defined through the View Manager service (VM), which materialises them as WS-Resources. Each VM resource encapsulates the definition of the view as well as its descriptive properties, and it is responsible for managing its lifetime, e.g. keep track of its cardinality and notify interested clients of changes to its contents. However, VM resources are passive, i.e. do not mediate access to those content resources.
Naturally, the gDL uses projections as view definitions. It then offers specialised Reader
s that encapsulate such projections to implicitly resolve all their operations in the scope of the view. This yields view-based access to collections and allows clients to work with local views. In addition, the gDL provides local proxies of VM resources with which clients can create, discover, and inspect remote views. As these proxies map remote view definitions onto projections, remote views can be accessed with the same reading mechanisms available for local views.
Utilities & F.A.Q.
The GCube Document Library offers utility classes to manage the collections and the views in the system.