MarkLogic Server 11.0 Product Documentation
hadoop:get-splits

hadoop:get-splits(
   $nsbindings as xs:string*,
   $doc-selector as xs:string,
   $query as xs:string
) as item()*

Summary

This function returns (forest_id, record_count, host_name) tuples where forest_id and host_name identify the target forest of the split input, and record_count is a rough estimate of the number of input key-value pairs in the split.

Parameters
nsbindings Namespace binding declarations.
doc-selector A fully searchable path expression to define document scope for the splits.
query A serialized cts:query string in XML or JSON format specifying the search to perform for the splits.

Usage Notes

The function creates split tuples using a searchable expression and cts:query. The parameters determine the documents under consideration in each forest, equivalent to the $expression and $query parameters of cts:search. The function returns an estimate rather than a true count to improve performance.

Note: As of MarkLogic 11.3.7, hadoop:get-splits enforces stricter input validation. The query parameter only accepts a serialized cts:query string in XML or JSON format; a string containing a cts:query constructor call, such as 'cts:or-query(())', is no longer accepted and raises HADOOP-BADQUERY. If you are upgrading from an earlier release, update any code that relies on the previous, more permissive formats.

Example

xquery version "1.0-ml";
import module namespace hadoop= "http://marklogic.com/xdmp/hadoop" 
          at "/MarkLogic/hadoop.xqy";
hadoop:get-splits('', 'fn:doc()',
    '<cts:and-query xmlns:cts="http://marklogic.com/cts"/>')
=>
8456374036761185098 97 doc.marklogic.com
  

Example

xquery version "1.0-ml";
import module namespace hadoop= "http://marklogic.com/xdmp/hadoop" 
          at "/MarkLogic/hadoop.xqy";
hadoop:get-splits(
  'declare namespace ex="http://example.com/ns";',
  'fn:collection(("foo", "bar"))',
  '<cts:document-root-query xmlns:cts="http://marklogic.com/cts"><cts:root xmlns:ex="http://example.com/ns">ex:order</cts:root></cts:document-root-query>'
)
=>
8456374036761185098 97 doc.marklogic.com
  
Powered by MarkLogic Server | Terms of Use | Privacy Policy