User-Defined Function API 10.0
MarkLogic.h
1/* -*- mode: c++; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 *
3 * Copyright (c) 2020 MarkLogic Corporation
4 *
5 */
32#ifndef _MARKLOGIC_MARKLOGIC_H_
33#define _MARKLOGIC_MARKLOGIC_H_
34
35#include <stddef.h>
36
37#ifdef _MSC_VER
38typedef __int32 int32_t;
39typedef unsigned __int32 uint32_t;
40typedef __int64 int64_t;
41typedef unsigned __int64 uint64_t;
42#ifndef MLDLL
43#define MLDLL __declspec(dllimport)
44#endif
45#else // !_MSC_VER
46#include <stdint.h>
47#define MLDLL
48#endif
49
50#define MARKLOGIC_API_VERSION 3
51
52namespace marklogic
53{
54
55class CodePointStringImpl;
56class Map;
57class MapImpl;
58class SequenceImpl;
59class StringImpl;
60class LangStringImpl;
61
63class MLDLL RangeIndex
64{
65public:
74 enum Type {
93 POINT
94 };
95
97 enum Order {
98 ASCENDING,
99 DESCENDING
100 };
101};
102
103template<class T, typename PT>
105{
106protected:
107 PT val;
108
109public:
110 CTypeWrapperBase(): val(0) {}
111 CTypeWrapperBase(PT v): val(v) {}
112
113 operator PT&() { return val; }
114 operator const PT&() const { return val; }
115
116 bool operator<(T o) const { return val < o.val; }
117 bool operator<=(T o) const { return val <= o.val; }
118 bool operator>(T o) const { return val > o.val; }
119 bool operator>=(T o) const { return val >= o.val; }
120 bool operator==(T o) const { return val == o.val; }
121 bool operator!=(T o) const { return val != o.val; }
122
123 T operator-(T o) const { return val - o.val; }
124 T operator+(T o) const { return val + o.val; }
125 T operator*(T o) const { return val * o.val; }
126 T operator/(T o) const { return val / o.val; }
127
128 T operator--(int) { return val--; }
129 T operator++(int) { return val++; }
130 T& operator--() { --val; return (T&)*this; }
131 T& operator++() { ++val; return (T&)*this; }
132 T& operator-=(T o) { val -= o.val; return (T&)*this; }
133 T& operator+=(T o) { val += o.val; return (T&)*this; }
134 T& operator*=(T o) { val *= o.val; return (T&)*this; }
135 T& operator/=(T o) { val /= o.val; return (T&)*this; }
136};
137
138template<class T, typename PT>
139class MLDLL CTypeWrapperF : public CTypeWrapperBase<T,PT>
140{
141protected:
143
144public:
145 CTypeWrapperF() {}
147
148 T operator-() const { return -this->val; }
149 T operator+() const { return +this->val; }
150};
151
152template<class T, typename PT>
153class MLDLL CTypeWrapperU : public CTypeWrapperBase<T,PT>
154{
155protected:
157
158public:
159 CTypeWrapperU() {}
161
162 T operator%(T o) const { return this->val % o.val; }
163 T& operator%=(T o) { this->val %= o.val; return (T&)*this; }
164};
165
166template<class T, typename PT>
167class MLDLL CTypeWrapper : public CTypeWrapperU<T,PT>
168{
169protected:
170 typedef CTypeWrapper<T,PT> Base;
171
172public:
173 CTypeWrapper() {}
175
176 T operator-() const { return -this->val; }
177 T operator+() const { return +this->val; }
178};
179
180
181#ifdef _MSC_VER
182typedef double DecimalType;
183#else
184typedef long double DecimalType;
185#endif
187class MLDLL Decimal : public CTypeWrapperF<Decimal,DecimalType>
188{
189public:
190 Decimal(): Base() {}
191 Decimal(DecimalType v): Base(v) {}
192};
193
195class MLDLL DateTime : public CTypeWrapper<DateTime,int64_t>
196{
197public:
198 DateTime(): Base() {}
199 DateTime(int64_t v): Base(v) {}
200};
201
203class MLDLL Date : public CTypeWrapper<Date,int64_t>
204{
205public:
206 Date(): Base() {}
207 Date(int64_t v): Base(v) {}
208};
209
211class MLDLL Time : public CTypeWrapper<Time,int64_t>
212{
213public:
214 Time(): Base() {}
215 Time(int64_t v): Base(v) {}
216};
217
219class MLDLL GYearMonth : public CTypeWrapper<GYearMonth,int>
220{
221public:
222 GYearMonth(): Base() {}
223 GYearMonth(int v): Base(v) {}
224};
225
227class MLDLL GYear : public CTypeWrapper<GYear,int>
228{
229public:
230 GYear(): Base() {}
231 GYear(int v): Base(v) {}
232};
233
235class MLDLL GMonth : public CTypeWrapperU<GMonth,unsigned>
236{
237public:
238 GMonth(): Base() {}
239 GMonth(unsigned v): Base(v) {}
240};
241
243class MLDLL GDay : public CTypeWrapperU<GDay,unsigned>
244{
245public:
246 GDay(): Base() {}
247 GDay(unsigned v): Base(v) {}
248};
249
251class MLDLL YearMonthDuration : public CTypeWrapper<YearMonthDuration,int>
252{
253public:
254 YearMonthDuration(): Base() {}
255 YearMonthDuration(int v): Base(v) {}
256};
257
259class MLDLL DayTimeDuration : public CTypeWrapper<DayTimeDuration,int64_t>
260{
261public:
262 DayTimeDuration(): Base() {}
263 DayTimeDuration(int64_t v): Base(v) {}
264};
265
268class MLDLL String
269{
270public:
271 String(StringImpl* =0);
272 String(const char* _str, const char* _collation = 0);
273 String(const String& o);
274 String& operator=(const String& o);
275 ~String();
276
277 operator bool() const { return str!=0; }
278
279 operator const char*() const;
280 const char* get() const;
281 size_t length() const;
282 const char* collation() const;
283
284 bool operator<(const String& o) const;
285 bool operator<=(const String& o) const;
286 bool operator>(const String& o) const;
287 bool operator>=(const String& o) const;
288 bool operator==(const String& o) const;
289 bool operator!=(const String& o) const;
290
291protected:
292 StringImpl* str;
293};
294
297class MLDLL LangString
298{
299public:
300 LangString(LangStringImpl* =0);
301 LangString(const char* _str, const char* _language = 0);
302 LangString(const LangString& o);
303 LangString& operator=(const LangString& o);
304 ~LangString();
305
306 operator bool () const { return str!=0; }
307
308 operator const char*() const;
309 const char* get() const;
310 size_t length() const;
311 const char* language() const;
312
313 bool operator<(const LangString& o) const;
314 bool operator<=(const LangString& o) const;
315 bool operator>(const LangString& o) const;
316 bool operator>=(const LangString& o) const;
317 bool operator==(const LangString& o) const;
318 bool operator!=(const LangString& o) const;
319
320protected:
321 LangStringImpl* str;
322};
323
325class MLDLL Point
326{
327protected:
328 double lat;
329 double lng;
330 const void* coord;
331
332public:
333 Point();
334 Point(double _lat, double _lng, const char* _coordinateSystem = "wgs84");
335
336 double latitude() const;
337 double longitude() const;
338 const char* coordinateSystem() const;
339
340 bool operator<(const Point& o) const;
341 bool operator<=(const Point& o) const;
342 bool operator>(const Point& o) const;
343 bool operator>=(const Point& o) const;
344 bool operator==(const Point& o) const;
345 bool operator!=(const Point& o) const;
346};
347
373class MLDLL TupleIterator
374{
375public:
377 virtual void next() =0;
379 virtual bool done() const =0;
380
381 // Information about this tuple iterator
383 virtual bool descending() const =0;
385 virtual size_t width() const =0;
387 virtual RangeIndex::Type type(size_t i) const =0;
391 virtual const char* collation(size_t i) const =0;
395 virtual const char* coordinateSystem(size_t i) const =0;
396
397 // Information about the current tuple
404 virtual uint64_t frequency() const =0;
408 virtual bool null(size_t i) const =0;
409
422 virtual void value(size_t i, int&) const =0;
423 virtual void value(size_t i, unsigned&) const =0;
424 virtual void value(size_t i, int64_t&) const =0;
425 virtual void value(size_t i, uint64_t&) const =0;
426 virtual void value(size_t i, float&) const =0;
427 virtual void value(size_t i, double&) const =0;
428 virtual void value(size_t i, Decimal&) const =0;
429 virtual void value(size_t i, DateTime&) const =0;
430 virtual void value(size_t i, Date&) const =0;
431 virtual void value(size_t i, Time&) const =0;
432 virtual void value(size_t i, GYearMonth&) const =0;
433 virtual void value(size_t i, GYear&) const =0;
434 virtual void value(size_t i, GMonth&) const =0;
435 virtual void value(size_t i, GDay&) const =0;
436 virtual void value(size_t i, YearMonthDuration&) const =0;
437 virtual void value(size_t i, DayTimeDuration&) const =0;
438 virtual void value(size_t i, String&) const =0;
439 virtual void value(size_t i, Point&) const =0;
440 virtual void value(size_t i, LangString&) const =0;
443protected:
445 virtual ~TupleIterator();
446private:
448 TupleIterator &operator=(const TupleIterator&);
449};
450
464class MLDLL OutputSequence
465{
466public:
470 virtual void writeValue(int) =0;
471 virtual void writeValue(unsigned) =0;
472 virtual void writeValue(int64_t) =0;
473 virtual void writeValue(uint64_t) =0;
474 virtual void writeValue(float) =0;
475 virtual void writeValue(double) =0;
476 virtual void writeValue(Decimal) =0;
477 virtual void writeValue(DateTime) =0;
478 virtual void writeValue(Date) =0;
479 virtual void writeValue(Time) =0;
480 virtual void writeValue(GYearMonth) =0;
481 virtual void writeValue(GYear) =0;
482 virtual void writeValue(GMonth) =0;
483 virtual void writeValue(GDay) =0;
484 virtual void writeValue(YearMonthDuration) =0;
485 virtual void writeValue(DayTimeDuration) =0;
486 virtual void writeValue(const String&) =0;
487 virtual void writeValue(Point) =0;
488 virtual void writeValue(bool) =0;
489 virtual void writeValue(const LangString&) =0;
517 virtual void startMap() =0;
521 virtual void writeMapKey(const char*) =0;
523 virtual void endMap() =0;
526protected:
528 virtual ~OutputSequence();
529private:
531 OutputSequence &operator=(const OutputSequence&);
532};
533
540class MLDLL Encoder
541{
542public:
543 virtual void encode(const void*, size_t) =0;
544
545 virtual void encode(int) =0;
546 virtual void encode(unsigned) =0;
547 virtual void encode(int64_t) =0;
548 virtual void encode(uint64_t) =0;
549 virtual void encode(float) =0;
550 virtual void encode(double) =0;
551 virtual void encode(Decimal) =0;
552 virtual void encode(DateTime) =0;
553 virtual void encode(Date) =0;
554 virtual void encode(Time) =0;
555 virtual void encode(GYearMonth) =0;
556 virtual void encode(GYear) =0;
557 virtual void encode(GMonth) =0;
558 virtual void encode(GDay) =0;
559 virtual void encode(YearMonthDuration) =0;
560 virtual void encode(DayTimeDuration) =0;
561 virtual void encode(const String&) =0;
562 virtual void encode(Point) =0;
563 virtual void encode(bool) =0;
564 virtual void encode(const LangString&) =0;
565
566protected:
567 Encoder();
568 virtual ~Encoder();
569private:
570 Encoder(const Encoder&);
571 Encoder &operator=(const Encoder&);
572};
573
580class MLDLL Decoder
581{
582public:
583 virtual void decode(const void*&, size_t&) =0;
584 virtual void decode(void*, size_t) =0;
585
586 virtual void decode(int&) =0;
587 virtual void decode(unsigned&) =0;
588 virtual void decode(int64_t&) =0;
589 virtual void decode(uint64_t&) =0;
590 virtual void decode(float&) =0;
591 virtual void decode(double&) =0;
592 virtual void decode(Decimal&) =0;
593 virtual void decode(DateTime&) =0;
594 virtual void decode(Date&) =0;
595 virtual void decode(Time&) =0;
596 virtual void decode(GYearMonth&) =0;
597 virtual void decode(GYear&) =0;
598 virtual void decode(GMonth&) =0;
599 virtual void decode(GDay&) =0;
600 virtual void decode(YearMonthDuration&) =0;
601 virtual void decode(DayTimeDuration&) =0;
602 virtual void decode(String&) =0;
603 virtual void decode(Point&) =0;
604 virtual void decode(bool&) =0;
605 virtual void decode(LangString&) =0;
606
607protected:
608 Decoder();
609 virtual ~Decoder();
610private:
611 Decoder(const Decoder&);
612 Decoder &operator=(const Decoder&);
613};
614
626class MLDLL Reporter
627{
628public:
630 enum LogLevel {
631 Finest,
632 Finer,
633 Fine,
634 Debug,
635 Config,
636 Info,
637 Notice,
638 Warning,
639 Error,
640 Critical,
641 Alert,
642 Emergency,
643 Disabled
644 };
645
650 virtual LogLevel logLevel() const =0;
652 virtual void log(LogLevel level, const char* message) =0;
659 virtual void error(const char* message) =0;
660
661protected:
662 Reporter();
663 virtual ~Reporter();
664private:
665 Reporter(const Reporter&);
666 Reporter &operator=(const Reporter&);
667};
668
670class MLDLL Item
671{
672public:
680 enum Type {
681 // Atomic types
701
702 // QNAME,
703 // NOTATION,
704 // DURATION,
705 // G_MONTH_DAY,
706 // BASE_64_BINARY,
707 // HEX_BINARY,
708 // UNTYPED_ATOMIC,
709
710 // MarkLogic types
713
714 // RDF types
716
717 // BOX,
718 // CIRCLE,
719 // POLYGON,
720 // LINESTRING,
721 // COMPLEX_POLYGON,
722 // ARRAY,
723
724 // // Nodes
725 // DOCUMENT,
726 // ELEMENT,
727 // ATTRIBUTE,
728 // TEXT,
729 // PROCESSING_INSTRUCTION,
730 // COMMENT,
731 // NAMESPACE,
732 // BINARY,
733
734 // FUNCTION,
735
736 OTHER
737 };
738};
739
750class MLDLL Sequence
751{
752public:
753 Sequence(SequenceImpl* =0);
754 Sequence(const Sequence&);
755 Sequence& operator=(const Sequence&);
756 ~Sequence();
757
759 operator bool() const { return seq!=0; }
760
764 void next();
766 bool done() const;
767
773 uint64_t frequency() const;
774
778 void value(int&) const;
779 void value(unsigned&) const;
780 void value(int64_t&) const;
781 void value(uint64_t&) const;
782 void value(float&) const;
783 void value(double&) const;
784 void value(Decimal&) const;
785 void value(DateTime&) const;
786 void value(Date&) const;
787 void value(Time&) const;
788 void value(GYearMonth&) const;
789 void value(GYear&) const;
790 void value(GMonth&) const;
791 void value(GDay&) const;
792 void value(YearMonthDuration&) const;
793 void value(DayTimeDuration&) const;
794 void value(String&) const;
795 void value(bool&) const;
796
797 void value(Point&) const;
798 void value(Map&) const;
799 void value(LangString&) const;
802private:
803 SequenceImpl* seq;
804};
805
807class MLDLL Map
808{
809public:
810 Map(MapImpl* =0);
811 Map(const Map&);
812 Map& operator=(const Map&);
813 ~Map();
814
816 operator bool() const { return map!=0; }
817
819 Sequence get(const char* key) const;
820
821private:
822 MapImpl* map;
823};
824
856class MLDLL AggregateUDF
857{
858public:
859 // Management methods
872 virtual AggregateUDF* clone() const =0;
878 virtual void close() =0;
879
892 virtual void start(Sequence& arg, Reporter& r) =0;
904 virtual void finish(OutputSequence& os, Reporter& r) =0;
905
906 // Map/reduce methods
918 virtual void map(TupleIterator& values, Reporter& r) =0;
934 virtual void reduce(const AggregateUDF* o, Reporter& r) =0;
935
936 // Serialize/deserialize
948 virtual void encode(Encoder& e, Reporter& r) =0;
960 virtual void decode(Decoder& d, Reporter& r) =0;
961
971
972protected:
973 // Detect DLLs compiled against a different API version
987 AggregateUDF(unsigned version = MARKLOGIC_API_VERSION);
988 virtual ~AggregateUDF();
989};
990
1002typedef AggregateUDF*(*AggregateFunction)();
1003
1010class MLDLL Token
1011{
1012public:
1022 typedef unsigned char TokenType;
1023
1024 static const TokenType SPACE = 's';
1025 static const TokenType PUNCT = 'p';
1026 static const TokenType WORD = 'w';
1027 static const TokenType SPECIAL = 'x';
1028
1049 typedef unsigned char PartOfSpeech;
1050 static const PartOfSpeech UNSPECIFIED_POS = '\0';
1051 static const PartOfSpeech NOUN_POS = 'n';
1052 static const PartOfSpeech VERB_POS = 'v';
1053 static const PartOfSpeech ADJECTIVE_POS = 'a';
1054 static const PartOfSpeech ADVERB_POS = 'r';
1055 static const PartOfSpeech PRONOUN_POS = 'p';
1056 static const PartOfSpeech CONJUNCTION_POS = 'c';
1057 static const PartOfSpeech DETERMINER_POS = 'd';
1058 static const PartOfSpeech MISC_POS = '?';
1059
1060public:
1061 unsigned begin;
1062 unsigned end;
1063 TokenType type;
1064 PartOfSpeech pos;
1065
1066public:
1067 Token(unsigned _begin, unsigned _end, TokenType _type, PartOfSpeech _pos):
1068 begin(_begin), end(_end), type(_type), pos(_pos) {}
1069 Token(unsigned _begin, unsigned _end, TokenType _type):
1070 begin(_begin), end(_end), type(_type), pos(UNSPECIFIED_POS) {}
1071 Token(): begin(0), end(0), type(SPACE), pos(UNSPECIFIED_POS) {}
1072 Token(const Token& t):
1073 begin(t.begin), end(t.end), type(t.type), pos(t.pos) {}
1074 ~Token() {}
1075};
1076
1080typedef unsigned CodePoint;
1081
1083{
1084public:
1085 CodePointString(const CodePoint* ptr, unsigned siz);
1086 CodePointString(const char* utf8);
1087 CodePointString(const CodePointString& other);
1088 CodePointString& operator=(const CodePointString& other);
1090
1092 operator bool() const { return cpstr!=0; };
1093
1095 const CodePoint* data() const;
1097 unsigned length() const;
1098
1100 void appendUTF8(const char* utf8);
1102 void append(const CodePoint* ptr, unsigned siz);
1104 void push_back(CodePoint cp);
1106 void clear();
1108 void reserve(size_t sz);
1109
1110protected:
1111 CodePointStringImpl* cpstr;
1112};
1113
1153class MLDLL LexerUDF
1154{
1155public:
1156 // Management methods
1161 virtual void close() =0;
1167 virtual bool isStale() const =0;
1178 virtual void initialize(const char* lang,
1179 int argc, const char** argv,
1180 Reporter& r) =0;
1181
1182 // Operations
1192 virtual void reset(const CodePoint* cp, unsigned sz, Reporter& r) =0;
1200 virtual void finish(Reporter& r) =0;
1206 virtual bool next(Reporter& r) =0;
1213 virtual const Token* token() const =0;
1214
1215protected:
1216 // Detect DLLs compiled against a different API version
1230 LexerUDF(unsigned version = MARKLOGIC_API_VERSION);
1231 virtual ~LexerUDF();
1232};
1233
1245typedef LexerUDF*(*LexerFunction)();
1246
1297class MLDLL StemmerUDF
1298{
1299public:
1300 // Management methods
1305 virtual void close() =0;
1311 virtual bool isStale() const =0;
1322 virtual void initialize(const char* lang,
1323 int argc, const char** argv,
1324 Reporter& r) =0;
1325
1326 // Operations
1334 virtual void reset(const CodePoint* cp, const unsigned sz, Token::PartOfSpeech pos, Reporter& r) =0;
1335
1342 virtual void start(Reporter& r) =0;
1343
1349 virtual bool next(Reporter& r) =0;
1350
1357 virtual const CodePointString* stem() =0;
1358
1367 virtual bool delegate() const =0;
1368
1369protected:
1370 // Detect DLLs compiled against a different API version
1384 StemmerUDF(unsigned version = MARKLOGIC_API_VERSION);
1385 virtual ~StemmerUDF();
1386};
1387
1399typedef StemmerUDF*(*StemmerFunction)();
1400
1424class MLDLL Registry
1425{
1426public:
1443 void version(unsigned pluginVersion = makeVersion(__DATE__,__TIME__),
1444 unsigned marklogicVersion = MARKLOGIC_API_VERSION);
1445
1462 template<class T> void registerAggregate(const char* name);
1482 virtual void registerAggregate(const char* name, AggregateFunction f) =0;
1483
1499 template<class T> void registerLexer(const char* name);
1518 virtual void registerLexer(const char* name, LexerFunction f) =0;
1519
1535 template<class T> void registerStemmer(const char* name);
1554 virtual void registerStemmer(const char* name, StemmerFunction f) =0;
1555
1556protected:
1557 Registry();
1558 virtual ~Registry();
1559private:
1560 Registry(const Registry&);
1561 Registry &operator=(const Registry&);
1562 static unsigned makeVersion(const char*,const char*);
1563protected:
1564 unsigned pluginVersion;
1565};
1566
1567template<class T>
1568inline AggregateUDF*
1569constructAggregate()
1570{
1571 return new T();
1572}
1573
1574template<class T>
1575inline LexerUDF*
1576constructLexer()
1577{
1578 return new T();
1579}
1580
1581template<class T>
1582inline StemmerUDF*
1583constructStemmer()
1584{
1585 return new T();
1586}
1587
1588template<class T>
1589inline void Registry::
1590registerAggregate(const char* name)
1591{
1592 registerAggregate(name, marklogic::constructAggregate<T>);
1593}
1594
1595template<class T>
1596inline void Registry::
1597registerLexer(const char* name)
1598{
1599 registerLexer(name, marklogic::constructLexer<T>);
1600}
1601
1602template<class T>
1603inline void Registry::
1604registerStemmer(const char* name)
1605{
1606 registerStemmer(name, marklogic::constructStemmer<T>);
1607}
1608
1609}
1610
1611#endif
Encapsulation of a User Defined Function for performing aggregate analysis across co-occurrences in r...
Definition: MarkLogic.h:857
virtual void map(TupleIterator &values, Reporter &r)=0
Entry point for performing map analysis. MarkLogic Server calls this method at lesat once per stand.
virtual void finish(OutputSequence &os, Reporter &r)=0
Finalize the results of an aggregate MapReduce job and prepare them for return to the calling applica...
AggregateUDF(unsigned version=MARKLOGIC_API_VERSION)
Construct an object compatible with a specific MarkLogic Native Plugin API version.
virtual RangeIndex::Order getOrder() const
Determine the order of range index input values.
virtual void encode(Encoder &e, Reporter &r)=0
Serialize this object's state so the object can be distributed across a MarkLogic Server cluster.
virtual void start(Sequence &arg, Reporter &r)=0
Initialize an aggregate MapReduce job.
virtual AggregateUDF * clone() const =0
Create a copy of an AggregateUDF.
virtual void decode(Decoder &d, Reporter &r)=0
De-serialize this object's state so the object can be reconstituted on a remote host.
virtual void close()=0
Release an AggregateUDF clone.
virtual void reduce(const AggregateUDF *o, Reporter &r)=0
Reduce the intermediate results of map analysis to a final result.
Definition: MarkLogic.h:105
Definition: MarkLogic.h:140
Definition: MarkLogic.h:154
Definition: MarkLogic.h:168
Definition: MarkLogic.h:1083
void push_back(CodePoint cp)
Append a single codepoint.
unsigned length() const
Number of codepoints.
void append(const CodePoint *ptr, unsigned siz)
Append a certain number of codepoints.
void reserve(size_t sz)
Reserve a certain buffer size.
void clear()
Clear out the codepoints.
const CodePoint * data() const
Get handle to codepoints.
void appendUTF8(const char *utf8)
Append a UTF8 encoded character string.
C++ representation of the XQuery type xs:dateTime.
Definition: MarkLogic.h:196
C++ representation of the XQuery type xs:date.
Definition: MarkLogic.h:204
C++ representation of the XQuery type xs:dayTimeDuration.
Definition: MarkLogic.h:260
C++ representation of the XQuery type xs:decimal.
Definition: MarkLogic.h:188
De-serialize values.
Definition: MarkLogic.h:581
Serialize values.
Definition: MarkLogic.h:541
C++ representation of the XQuery type xs:gDay.
Definition: MarkLogic.h:244
C++ representation of the XQuery type xs:gMonth.
Definition: MarkLogic.h:236
C++ representation of the XQuery type xs:gYearMonth.
Definition: MarkLogic.h:220
C++ representation of the XQuery type xs:gYear.
Definition: MarkLogic.h:228
Encapsulation of XQuery sequence item value type.
Definition: MarkLogic.h:671
Type
The types of item values that can occur in a Sequence.
Definition: MarkLogic.h:680
@ DAY_TIME_DURATION
xs:dayTimeDuration
Definition: MarkLogic.h:697
@ YEAR_MONTH_DURATION
xs:yearMonthDuration
Definition: MarkLogic.h:696
@ DECIMAL
xs:decimal
Definition: MarkLogic.h:688
@ MAP
map:map (MarkLogic XQuery dialect)
Definition: MarkLogic.h:712
@ TIME
xs:time
Definition: MarkLogic.h:690
@ ANY_URI
xs:anyURI
Definition: MarkLogic.h:699
@ DOUBLE
xs:double
Definition: MarkLogic.h:687
@ G_YEAR_MONTH
xs:gYearMonth
Definition: MarkLogic.h:692
@ G_MONTH
xs:gMonth
Definition: MarkLogic.h:694
@ INT
xs:int
Definition: MarkLogic.h:682
@ STRING
xs:string
Definition: MarkLogic.h:698
@ G_YEAR
xs:gYear
Definition: MarkLogic.h:693
@ G_DAY
xs:gDay
Definition: MarkLogic.h:695
@ DATE
xs:date
Definition: MarkLogic.h:691
@ LONG
xs:long
Definition: MarkLogic.h:684
@ DATE_TIME
xs:dateTime
Definition: MarkLogic.h:689
@ FLOAT
xs:float
Definition: MarkLogic.h:686
@ BOOLEAN
xs:boolean
Definition: MarkLogic.h:700
@ POINT
cts:point (MarkLogic XQuery dialect)
Definition: MarkLogic.h:711
@ UNSIGNED_LONG
xs:unsignedLong
Definition: MarkLogic.h:685
@ UNSIGNED_INT
xs:unsignedInt
Definition: MarkLogic.h:683
@ LANG_STRING
rdf:langString (SPARQL)
Definition: MarkLogic.h:715
C++ representation of the RDF type rdf:langString, encapsulating a string value with its language.
Definition: MarkLogic.h:298
Encapsulation of a User Defined Function for performing tokenization of text runs.
Definition: MarkLogic.h:1154
virtual bool next(Reporter &r)=0
Advance to the next token. Return true if the is another token to fetch.
LexerUDF(unsigned version=MARKLOGIC_API_VERSION)
Construct an object compatible with a specific MarkLogic Native Plugin API version.
virtual bool isStale() const =0
Return true if the LexerUDF instance can no longer be reused.
virtual void initialize(const char *lang, int argc, const char **argv, Reporter &r)=0
Initialize a lexer. This method is called once after the lexer is constructed.
virtual void reset(const CodePoint *cp, unsigned sz, Reporter &r)=0
Initiate a new tokenization episode on a new text run.
virtual void finish(Reporter &r)=0
Clean up from tokenizing a text run.
virtual const Token * token() const =0
Return the current token.
virtual void close()=0
Release a LexerUDF instance.
A key-value map, equivalent to the MarkLogic XQuery type map:map.
Definition: MarkLogic.h:808
Sequence get(const char *key) const
Extract the value(s) associated with a given key.
A sequence of values produced by your AggregateUDF::finish implementation.
Definition: MarkLogic.h:465
virtual void writeMapKey(const char *)=0
Add a key to the map. Use OutputSequence::writeValue to add the value.
virtual void startMap()=0
Begin adding a map value to the sequence.
virtual void endMap()=0
Close off the current map.
C++ representation of the MarkLogic XQuery cts:point.
Definition: MarkLogic.h:326
Encapsulation of the configuration of a range index.
Definition: MarkLogic.h:64
Type
The type of the values in a range index.
Definition: MarkLogic.h:74
@ ANY_URI
xs:anyURI
Definition: MarkLogic.h:92
@ G_YEAR_MONTH
xs:gYearMonth
Definition: MarkLogic.h:85
@ DECIMAL
xs:decimal
Definition: MarkLogic.h:81
@ DATE_TIME
xs:dateTime
Definition: MarkLogic.h:82
@ G_DAY
xs:gDay
Definition: MarkLogic.h:88
@ YEAR_MONTH_DURATION
xs:yearMonthDuration
Definition: MarkLogic.h:89
@ G_MONTH
xs:gMonth
Definition: MarkLogic.h:87
@ TIME
xs:time
Definition: MarkLogic.h:83
@ G_YEAR
xs:gYear
Definition: MarkLogic.h:86
@ INT
xs:int
Definition: MarkLogic.h:75
@ DAY_TIME_DURATION
xs:dayTimeDuration
Definition: MarkLogic.h:90
@ UNSIGNED_LONG
xs:unsignedLong
Definition: MarkLogic.h:78
@ STRING
xs:string
Definition: MarkLogic.h:91
@ FLOAT
xs:float
Definition: MarkLogic.h:79
@ UNSIGNED_INT
xs:unsignedInt
Definition: MarkLogic.h:76
@ LONG
xs:long
Definition: MarkLogic.h:77
@ DATE
xs:date
Definition: MarkLogic.h:84
@ DOUBLE
xs:double
Definition: MarkLogic.h:80
Order
Whether the index values are in ascending or descending order.
Definition: MarkLogic.h:97
The MarkLogic Server native plugin registry.
Definition: MarkLogic.h:1425
void registerStemmer(const char *name)
Register a StemmerUDF implementation with MarkLogic Server.
Definition: MarkLogic.h:1604
void version(unsigned pluginVersion=makeVersion(__DATE__, __TIME__), unsigned marklogicVersion=MARKLOGIC_API_VERSION)
Register the version of your plugin library and the version of the MarkLogic Server Native Plugin API...
virtual void registerStemmer(const char *name, StemmerFunction f)=0
Register a StemmerUDF implementation with MarkLogic Server.
virtual void registerLexer(const char *name, LexerFunction f)=0
Register a LexerUDF implementation with MarkLogic Server.
virtual void registerAggregate(const char *name, AggregateFunction f)=0
Register an AggregateUDF implementation with MarkLogic Server.
void registerAggregate(const char *name)
Register an AggregateUDF implementation with MarkLogic Server.
Definition: MarkLogic.h:1590
void registerLexer(const char *name)
Register a LexerUDF implementation with MarkLogic Server.
Definition: MarkLogic.h:1597
Log messages and report errors to MarkLogic Server. You do not need to subclass this class.
Definition: MarkLogic.h:627
virtual void log(LogLevel level, const char *message)=0
Log a message at a particular log level.
virtual void error(const char *message)=0
Log an error and cancel the current job.
LogLevel
Available log levels.
Definition: MarkLogic.h:630
virtual LogLevel logLevel() const =0
Determine the current log level.
A sequence of Item values.
Definition: MarkLogic.h:751
void next()
Advance to the next item in the sequence. If the sequence is exhausted, XDMP-UDFSEQEND is raised.
uint64_t frequency() const
Determine the number of times the current value occurs in the sequence.
Item::Type type() const
Determine the type of the current item.
bool done() const
Test whether or not there are more items in the sequence.
Encapsulation of a User Defined Function for performing stemming of individual words.
Definition: MarkLogic.h:1298
virtual bool next(Reporter &r)=0
Advance to the next stem. Return true if the is another stem to fetch.
virtual void initialize(const char *lang, int argc, const char **argv, Reporter &r)=0
Initialize a stemmer. This method is called once after the stemmer is constructed.
StemmerUDF(unsigned version=MARKLOGIC_API_VERSION)
Construct an object compatible with a specific MarkLogic Native Plugin API version.
virtual const CodePointString * stem()=0
Return the current stem.
virtual void start(Reporter &r)=0
Start iteration of stems. Normal stemming operations may require the iteration to be performed more t...
virtual void reset(const CodePoint *cp, const unsigned sz, Token::PartOfSpeech pos, Reporter &r)=0
Get stems for the input word.
virtual void close()=0
Release a StemmerUDF instance.
virtual bool delegate() const =0
Delegate to base stemmer. Return true if the base stemmer should be asked to provide stems for the in...
virtual bool isStale() const =0
Return true if the StemmerUDF instance can no longer be reused.
C++ representation of the XQuery type xs:string, encapsulating a string value with its collation.
Definition: MarkLogic.h:269
C++ representation of the XQuery type xs:time.
Definition: MarkLogic.h:212
C++ representation of the MarkLogic token.
Definition: MarkLogic.h:1011
unsigned char PartOfSpeech
The part of speech of the token being returned. Part of speech is only relevant for word tokens.
Definition: MarkLogic.h:1049
unsigned char TokenType
The kind of token being returned.
Definition: MarkLogic.h:1022
Iterator over a sequence of N-way co-occurrences of range index values from a single stand....
Definition: MarkLogic.h:374
virtual const char * coordinateSystem(size_t i) const =0
If the Ith value in each tuple is a Point (cts:point), determine its coordinate system.
virtual void next()=0
Advance to the next tuple in the sequence.
virtual const char * collation(size_t i) const =0
If the Ith value in each tuple is a string, determine its collation.
virtual void value(size_t i, int &) const =0
Extract the Ith value in the current tuple.
virtual size_t width() const =0
Determine the number of values in each tuple.
virtual bool done() const =0
Test whether or not there are more tuples in the sequence.
virtual RangeIndex::Type type(size_t i) const =0
Determine the type of the Ith value in each tuple.
virtual uint64_t frequency() const =0
Determine the number of times the current tuple occurs.
virtual bool descending() const =0
Test whether tuples are in descending order in the sequence.
C++ representation of the XQuery type xs:yearMonthDuration.
Definition: MarkLogic.h:252