Diffusion Apple API  6.2.0
Unified Client Library for iOS, tvOS and OS X / macOS
 All Classes Functions Variables Properties Pages
Class Methods | Instance Methods | List of all members
PTDiffusionFetchRequest Class Reference

Introduction

A fetch request.

This defines a fetch request to be made to the server. A new request can be created using the fetchRequest (PTDiffusionTopicsFeature) method and modified to specify a range of topics and/or various levels of detail.

The fetch request is issued to the server using one of the data type specific fetch methods, supplying a topic selector which specifies the selection of topics (e.g. fetchJSONValuesWithTopicSelectorExpression:completionHandler: (PTDiffusionFetchRequest(PTDiffusionJSON)) for JSON).

A range is defined as being between two points of the topic tree which is ordered in full path name order. So an example tree order would be:

The start point of a range can be specified using fromTopicPath: (PTDiffusionFetchRequest) or afterTopicPath: (PTDiffusionFetchRequest) and an end point using toTopicPath: (PTDiffusionFetchRequest) or beforeTopicPath: (PTDiffusionFetchRequest). fromTopicPath: (PTDiffusionFetchRequest) and toTopicPath: (PTDiffusionFetchRequest) include any topic with the specified path in the selection, whereas afterTopicPath: (PTDiffusionFetchRequest) and beforeTopicPath: (PTDiffusionFetchRequest) are non-inclusive and useful for paging through a potentially large range of topics. If no start point is specified, the start point is assumed to be the logical beginning of the topic tree. Similarly, if no end point is specified, the end point is the logical end of the topic tree. Ranges should be within the scope indicated by the topic selector used when issuing the fetch.

As a minimum, the path and type of each topic selected will be returned. It is also possible to request that the topic values and/or properties are returned.

The topic types selected are naturally constrained by the data type indicated when the fetch is requested. So if fetchStringValuesWithTopicSelectorExpression:completionHandler: (PTDiffusionFetchRequest(PTDiffusionPrimitive)) is used, only PTDiffusionTopicType_String topics will be selected. However, if fetchJSONValuesWithTopicSelectorExpression:completionHandler: (PTDiffusionFetchRequest(PTDiffusionJSON)) is used, all types compatible with PTDiffusionJSON will be selected including PTDiffusionTopicType_String, PTDiffusionTopicType_Int64 and PTDiffusionTopicType_Double.

To select topic types when values are not required, or to further constrain the selection when values are required, it is also possible to specify exactly which topic types to select.

A limit on the number of results returned can be specified using first: (PTDiffusionFetchRequest). This is advisable when the result set could potentially be large. When such a limit is used then the result will indicate whether more results for the same selection would be available via the PTDiffusionFetchResult::more property.

The request can be sent to the server using one of the fetch methods provided by data type extensions. Results are returned in path order, earliest path first, starting from the beginning of any range specified.

It is also possible to request results from the end of the range indicated by specifying a limit to the number of results using last: (PTDiffusionFetchRequest). This returns up to the specified number of results from the end of the range, in path order. This is useful for paging backwards through a range of topics.

Slave topics are supported, in that if the slave topic itself is within the requested selector/range and it is currently linked to a topic that should be selected then a result will be returned for the slave topic with the type/value/properties of the source topic.

Routing topics are not supported, and if encountered will be ignored (i.e. treated as if they did not exist).

Instances of this class are immutable and can be safely shared and reused.

Since
6.2
Inheritance diagram for PTDiffusionFetchRequest:

Class Methods

(instancetype) + NS_UNAVAILABLE
 
(NSSet< NSNumber * > *) + allTypes
 

Instance Methods

(instancetype) - NS_UNAVAILABLE
 
(instancetype) - afterTopicPath:
 
(instancetype) - beforeTopicPath:
 
(instancetype) - fromTopicPath:
 
(instancetype) - toTopicPath:
 
(instancetype) - withProperties
 
(instancetype) - first:
 
(instancetype) - last:
 
(instancetype) - maximumResultSize:
 
(instancetype) - topicTypes:
 
(void) - fetchWithTopicSelectorExpression:completionHandler:
 
(void) - fetchBinaryValuesWithTopicSelectorExpression:completionHandler:
 
(void) - fetchJSONValuesWithTopicSelectorExpression:completionHandler:
 
(void) - fetchStringValuesWithTopicSelectorExpression:completionHandler:
 
(void) - fetchDoubleFloatNumberValuesWithTopicSelectorExpression:completionHandler:
 
(void) - fetchInt64NumberValuesWithTopicSelectorExpression:completionHandler:
 
(void) - fetchRecordValuesWithTopicSelectorExpression:completionHandler:
 

Method Documentation

- (instancetype) afterTopicPath: (NSString *)  topicPath

Specifies a logical start point within the topic tree.

If specified, only results for topics with a path that is lexically 'after' the specified path will be returned.

This is the non-inclusive equivalent of fromTopicPath: and if used will override any previous fromTopicPath: or afterTopicPath: constraint.

Parameters
topicPathThe topic path after which results are to be returned.
Returns
A new fetch request derived from this fetch request but selecting only topics after the specified path (not inclusive).
Since
6.2
+ (NSSet<NSNumber *> *) allTypes

A constant set of all topic types that can be fetched.

Since
6.2
- (instancetype) beforeTopicPath: (NSString *)  topicPath

Specifies a logical end point within the topic tree.

If specified, only results for topics with a path that is lexically 'before' the specified path will be returned.

This is the non-inclusive equivalent of toTopicPath: and if used will override any previous toTopicPath: or beforeTopicPath: constraint.

Parameters
topicPathThe topic path before which results are to be returned.
Returns
A new fetch request derived from this fetch request but selecting only topics before the specified path (not inclusive).
Since
6.2
- (void) fetchBinaryValuesWithTopicSelectorExpression: (NSString *)  expression
completionHandler: (PTDiffusionBinaryFetchResult *_Nullable)  result
(NSError *_Nullable error)  completionHandler 

Sends a fetch request to the server, specifying that values should be returned for selected topics, constraining the selection to only those topics with a data type compatible with Binary.

The Binary data type constrains the topic types. So, any topic types specified in a previous call to topicTypes: that cannot be read as Binary will be removed from the list of topic types.

Results are returned for all topics matching the selector that satisfy the request constraints within any range defined by fromTopicPath: / afterTopicPath: and/or toTopicPath: / beforeTopicPath:

Parameters
expressionSpecifies a topic selector, evaluated at the server, which selects the topics to be fetched.
completionHandlerBlock to be called asynchronously on success or failure. If the operation was successful, the error argument passed to the block will be nil. The completion handler will be called asynchronously on the main dispatch queue.
Exceptions
NSInvalidArgumentExceptionRaised if any supplied arguments are nil.
Since
6.2

Provided by category PTDiffusionFetchRequest(PTDiffusionBinary).

- (void) fetchDoubleFloatNumberValuesWithTopicSelectorExpression: (NSString *)  expression
completionHandler: (PTDiffusionNumberFetchResult *_Nullable)  result
(NSError *_Nullable error)  completionHandler 

Sends a fetch request to the server, specifying that values should be returned for selected topics, constraining the selection to only those topics with a data type compatible with double-precision floating point (Eight-byte IEEE 754).

The doubleFloat data type constrains the topic types. So, any topic types specified in a previous call to topicTypes: that cannot be read as double-precision floating point (Eight-byte IEEE 754) will be removed from the list of topic types.

Results are returned for all topics matching the selector that satisfy the request constraints within any range defined by fromTopicPath: / afterTopicPath: and/or toTopicPath: / beforeTopicPath:

Parameters
expressionSpecifies a topic selector, evaluated at the server, which selects the topics to be fetched.
completionHandlerBlock to be called asynchronously on success or failure. If the operation was successful, the error argument passed to the block will be nil. The completion handler will be called asynchronously on the main dispatch queue.
Exceptions
NSInvalidArgumentExceptionRaised if any supplied arguments are nil.
Since
6.2

Provided by category PTDiffusionFetchRequest(PTDiffusionPrimitive).

- (void) fetchInt64NumberValuesWithTopicSelectorExpression: (NSString *)  expression
completionHandler: (PTDiffusionNumberFetchResult *_Nullable)  result
(NSError *_Nullable error)  completionHandler 

Sends a fetch request to the server, specifying that values should be returned for selected topics, constraining the selection to only those topics with a data type compatible with 64-bit integer.

The int64 data type constrains the topic types. So, any topic types specified in a previous call to topicTypes: that cannot be read as 64-bit integer will be removed from the list of topic types.

Results are returned for all topics matching the selector that satisfy the request constraints within any range defined by fromTopicPath: / afterTopicPath: and/or toTopicPath: / beforeTopicPath:

Parameters
expressionSpecifies a topic selector, evaluated at the server, which selects the topics to be fetched.
completionHandlerBlock to be called asynchronously on success or failure. If the operation was successful, the error argument passed to the block will be nil. The completion handler will be called asynchronously on the main dispatch queue.
Exceptions
NSInvalidArgumentExceptionRaised if any supplied arguments are nil.
Since
6.2

Provided by category PTDiffusionFetchRequest(PTDiffusionPrimitive).

- (void) fetchJSONValuesWithTopicSelectorExpression: (NSString *)  expression
completionHandler: (PTDiffusionJSONFetchResult *_Nullable)  result
(NSError *_Nullable error)  completionHandler 

Sends a fetch request to the server, specifying that values should be returned for selected topics, constraining the selection to only those topics with a data type compatible with JSON.

The JSON data type constrains the topic types. So, any topic types specified in a previous call to topicTypes: that cannot be read as JSON will be removed from the list of topic types.

Results are returned for all topics matching the selector that satisfy the request constraints within any range defined by fromTopicPath: / afterTopicPath: and/or toTopicPath: / beforeTopicPath:

Parameters
expressionSpecifies a topic selector, evaluated at the server, which selects the topics to be fetched.
completionHandlerBlock to be called asynchronously on success or failure. If the operation was successful, the error argument passed to the block will be nil. The completion handler will be called asynchronously on the main dispatch queue.
Exceptions
NSInvalidArgumentExceptionRaised if any supplied arguments are nil.
Since
6.2

Provided by category PTDiffusionFetchRequest(PTDiffusionJSON).

- (void) fetchRecordValuesWithTopicSelectorExpression: (NSString *)  expression
completionHandler: (PTDiffusionRecordV2FetchResult *_Nullable)  result
(NSError *_Nullable error)  completionHandler 

Sends a fetch request to the server, specifying that values should be returned for selected topics, constraining the selection to only those topics with a data type compatible with records.

The record data type constrains the topic types. So, any topic types specified in a previous call to topicTypes: that cannot be read as records will be removed from the list of topic types.

Results are returned for all topics matching the selector that satisfy the request constraints within any range defined by fromTopicPath: / afterTopicPath: and/or toTopicPath: / beforeTopicPath:

Parameters
expressionSpecifies a topic selector, evaluated at the server, which selects the topics to be fetched.
completionHandlerBlock to be called asynchronously on success or failure. If the operation was successful, the error argument passed to the block will be nil. The completion handler will be called asynchronously on the main dispatch queue.
Exceptions
NSInvalidArgumentExceptionRaised if any supplied arguments are nil.
Since
6.2

Provided by category PTDiffusionFetchRequest(PTDiffusionRecordV2).

- (void) fetchStringValuesWithTopicSelectorExpression: (NSString *)  expression
completionHandler: (PTDiffusionStringFetchResult *_Nullable)  result
(NSError *_Nullable error)  completionHandler 

Sends a fetch request to the server, specifying that values should be returned for selected topics, constraining the selection to only those topics with a data type compatible with string.

The string data type constrains the topic types. So, any topic types specified in a previous call to topicTypes: that cannot be read as strings will be removed from the list of topic types.

Results are returned for all topics matching the selector that satisfy the request constraints within any range defined by fromTopicPath: / afterTopicPath: and/or toTopicPath: / beforeTopicPath:

Parameters
expressionSpecifies a topic selector, evaluated at the server, which selects the topics to be fetched.
completionHandlerBlock to be called asynchronously on success or failure. If the operation was successful, the error argument passed to the block will be nil. The completion handler will be called asynchronously on the main dispatch queue.
Exceptions
NSInvalidArgumentExceptionRaised if any supplied arguments are nil.
Since
6.2

Provided by category PTDiffusionFetchRequest(PTDiffusionPrimitive).

- (void) fetchWithTopicSelectorExpression: (NSString *)  expression
completionHandler: (PTDiffusionFetchResult *_Nullable)  result
(NSError *_Nullable error)  completionHandler 

Sends a fetch request to the server, specifying that values should not be returned for selected topics.

Results are returned for all topics matching the selector that satisfy the request constraints within any range defined by fromTopicPath: / afterTopicPath: and/or toTopicPath: / beforeTopicPath:

Parameters
expressionSpecifies a topic selector, evaluated at the server, which selects the topics to be fetched.
Since
6.2
- (instancetype) first: (UInt32)  number

Specifies a maximum number of topic results to be returned from the start of the required range.

If this is not specified, the number of results returned will only be limited by other constraints of the request.

This should be used to retrieve results in manageable batches and prevent very large result sets.

If there are potentially more results that would satisfy the other constraints, then the fetch result will indicate so via the PTDiffusionFetchResult::hasMore property.

Either this or last: may be specified. This will therefore override any previous last: or first: constraint.

Parameters
numberThe maximum number of results to return from the start of the range.
Returns
A new fetch request derived from this fetch request but selecting only the number of topics specified from the start of the range.
Exceptions
NSInvalidArgumentExceptionif number is greater than INT32_MAX.
Since
6.2
- (instancetype) fromTopicPath: (NSString *)  topicPath

Specifies a logical start point within the topic tree.

If specified, only results for topics with a path that is lexically equal to or 'after' the specified path will be returned.

This is the inclusive equivalent of afterTopicPath: and if used will override any previous afterTopicPath: or fromTopicPath: constraint.

Parameters
topicPathThe topic path from which results are to be returned.
Returns
A new fetch request derived from this fetch request but selecting only topics from the specified path onwards (inclusive).
Since
6.2
- (instancetype) last: (UInt32)  number

Specifies a maximum number of topic results to be returned from the end of the required range.

This is similar to first: except that the specified number of results are returned from the end of the range. This is useful for paging backwards through a range of topics. Results are always returned in topic path order (not reverse order).

Either this or first: may be specified. This will therefore override any previous first: or last: constraint.

Parameters
numberThe maximum number of results to return from the end of the range.
Returns
A new fetch request derived from this fetch request but selecting only the number of topics specified from the end of the range.
Exceptions
NSInvalidArgumentExceptionif number is greater than -INT32_MIN.
Since
6.2
- (instancetype) maximumResultSize: (UInt32)  size

Specifies the maximum data size of the result set.

This may be used to constrain the size of the result. If not specified then by default the maximum message size for the session (as specified by PTDiffusionSessionConfiguration::maximumMessageSize ) is used.

Parameters
sizeThe maximum size of the result set in bytes. If a value greater than the session's maximum message size is specified, the maximum message size will be used.
Returns
A new fetch request derived from this fetch request but constraining the size of the result to the specified maximum.
Exceptions
NSInvalidArgumentExceptionif size is greater than INT32_MAX.
Since
6.2
- (instancetype) topicTypes: (NSSet< NSNumber * > *)  topicTypes

Specifies that only topics of the specified topic types should be returned.

If this is not specified, allTypes will be returned (unless constrained by value data type).

This may be used instead to further constrain the results when already constraining by values. For example, you can use PTDiffusionFetchRequest::withJSONValues then specify PTDiffusionTopicType_JSON here to ensure that only JSON topics are returned and not those topics that are logically value subtypes of JSON (e.g. PTDiffusionTopicType_String).

If already constraining by value data type then the topic types specified here must be compatible with the value class specified.

Neither PTDiffusionTopicType_Slave nor PTDiffusionTopicType_Routing may be specified as only target topic types may be selected.

Parameters
topicTypesTopic types to be selected, boxed as NSNumber instances.
Returns
A new fetch request derived from this fetch request but specifying that only topics of the specified topic types should be returned.
Exceptions
IllegalArgumentExceptionif invalid topic types are specified
Since
6.2
- (instancetype) toTopicPath: (NSString *)  topicPath

Specifies a logical end point within the topic tree.

If specified, only results for topics with a path that is lexically equal to or 'before' the specified path will be returned.

This is the inclusive equivalent of beforeTopicPath: and if used will override any previous beforeTopicPath: or toTopicPath: constraint.

Parameters
topicPathThe topic path to which results are to be returned.
Returns
A new fetch request derived from this fetch request but selecting only topics including and before the specified path (inclusive).
Since
6.2
- (instancetype) withProperties

Specifies that all properties associated with each topic's PTDiffusionTopicSpecification should be returned.

Returns
A new fetch request derived from this fetch request but specifying that topic specification properties should be returned.
Since
6.2