rtlkey.hpp 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. /*##############################################################################
  2. HPCC SYSTEMS software Copyright (C) 2012 HPCC Systems.
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. ############################################################################## */
  13. #ifndef RTLKEY_INCL
  14. #define RTLKEY_INCL
  15. #include "eclrtl.hpp"
  16. enum KeySegmentMonitorSerializeType
  17. {
  18. KSMST_none, // can't serialize
  19. KSMST_WILDKEYSEGMENTMONITOR,
  20. KSMST_SETKEYSEGMENTMONITOR,
  21. KSMST_SINGLEKEYSEGMENTMONITOR,
  22. KSMST_SINGLEBIGSIGNEDKEYSEGMENTMONITOR,
  23. KSMST_SINGLELITTLESIGNEDKEYSEGMENTMONITOR,
  24. KSMST_CSINGLELITTLEKEYSEGMENTMONITOR,
  25. KSMST_DUMMYKEYSEGMENTMONITOR,
  26. KSMST_OVERRIDEABLEKEYSEGMENTMONITOR,
  27. KSMST_max
  28. };
  29. interface ITransition : extends IInterface
  30. {
  31. virtual bool getState() const = 0;
  32. virtual const void *getValue() const = 0;
  33. virtual MemoryBuffer &serialize(size32_t size, MemoryBuffer &buffer) const = 0;
  34. };
  35. interface IStringSet : public IInterface
  36. {
  37. virtual void addRange(const void *loval, const void *hival) = 0;
  38. virtual void addAll() = 0;
  39. virtual ITransition *queryTransition(unsigned idx) = 0;
  40. virtual bool getTransitionValue(void *value, unsigned idx) = 0;
  41. virtual void killRange(const void *loval, const void *hival) = 0;
  42. virtual bool inRange(const void *val) const = 0;
  43. virtual bool inRange(const void *val, unsigned &transition) const = 0;
  44. virtual size32_t getSize() = 0;
  45. virtual void reset() = 0;
  46. virtual unsigned transitionCount() = 0;
  47. virtual const char *describe(StringBuffer &ret) = 0;
  48. virtual IStringSet *invertSet() = 0;
  49. virtual IStringSet *unionSet(IStringSet *) = 0;
  50. virtual IStringSet *intersectSet(IStringSet *) = 0;
  51. virtual bool isEmptySet() const = 0;
  52. virtual bool isFullSet() const = 0;
  53. virtual bool isSingleValue() const = 0;
  54. virtual bool isSigned() const = 0;
  55. virtual bool isBigEndian() const = 0;
  56. virtual unsigned numValues() const = 0;
  57. virtual int memcmp(const void *val1, const void *val2, size32_t size) const = 0;
  58. virtual bool decrement(void *val) const = 0;
  59. virtual bool increment(void *val) const = 0;
  60. virtual MemoryBuffer &serialize(MemoryBuffer &buffer) const = 0;
  61. };
  62. ECLRTL_API IStringSet *createStringSet(size32_t size);
  63. ECLRTL_API IStringSet *createStringSet(size32_t size, bool bigEndian, bool isSigned);
  64. ECLRTL_API IStringSet *deserializeStringSet(MemoryBuffer &mb);
  65. ECLRTL_API int memcmpbigsigned(const void *l, const void *r, unsigned size);
  66. ECLRTL_API int memcmplittleunsigned(const void *l, const void *r, unsigned size);
  67. ECLRTL_API int memcmplittlesigned(const void *l, const void *r, unsigned size);
  68. interface IKeySegmentMonitor : public IInterface
  69. {
  70. public:
  71. virtual bool increment(void * expandedRow) const = 0;
  72. virtual void setLow(void * expanddRow) const = 0;
  73. virtual void endRange(void * expandedRow) const = 0;
  74. virtual bool matches(const void * rawRow) const = 0;
  75. virtual IKeySegmentMonitor *merge(IKeySegmentMonitor *with) const = 0; // merge with adjacent, if possible
  76. virtual IKeySegmentMonitor *combine(const IKeySegmentMonitor *with) const = 0; // combine with overlapping (compulsory)
  77. virtual IKeySegmentMonitor * split(unsigned splitSize) = 0;
  78. virtual bool isWild() const = 0;
  79. virtual unsigned getOffset() const = 0;
  80. virtual unsigned getSize() const = 0;
  81. virtual void *queryValue() const = 0;
  82. virtual int docompare(const void * expandedLeft, const void * rawRight) const = 0;
  83. // virtual unsigned getFlags() const = 0;
  84. virtual bool isEmpty() const = 0;
  85. virtual bool equivalentTo(const IKeySegmentMonitor &other) const = 0;
  86. virtual bool isSigned() const = 0;
  87. virtual bool isLittleEndian() const = 0;
  88. virtual int docompareraw(const void * rawLeft, const void * rawRight) const = 0;
  89. virtual unsigned queryHashCode() const = 0;
  90. virtual bool isWellKeyed() const = 0;
  91. virtual bool setOffset(unsigned _offset) = 0;
  92. virtual bool isOptional() const = 0;
  93. virtual void setHigh(void * expanddRow) const = 0;
  94. virtual bool isSimple() const = 0;
  95. virtual void copy(void *expandedRow, const void *rawRow) const = 0;
  96. virtual MemoryBuffer &serialize(MemoryBuffer &mb) const = 0;
  97. virtual KeySegmentMonitorSerializeType serializeType() const = 0;
  98. virtual IKeySegmentMonitor *clone() const = 0;
  99. };
  100. interface IOverrideableKeySegmentMonitor : public IKeySegmentMonitor
  101. {
  102. virtual void setOverrideBuffer(const void *ptr) = 0;
  103. };
  104. interface IBlobProvider
  105. {
  106. virtual byte * lookupBlob(unsigned __int64 id) = 0; // return reference, not freed by code generator, can dispose once transform() has returned.
  107. };
  108. interface IBlobCreator
  109. {
  110. virtual unsigned __int64 createBlob(size32_t _size, const void * _ptr) = 0;
  111. };
  112. interface IIndexReadContext
  113. {
  114. public:
  115. virtual void append(IKeySegmentMonitor *segment) = 0;
  116. virtual unsigned ordinality() const = 0;
  117. virtual IKeySegmentMonitor *item(unsigned idx) const = 0;
  118. virtual void setMergeBarrier(unsigned offset) = 0;
  119. };
  120. interface IKeySegmentOffsetTranslator : public IInterface
  121. {
  122. virtual const void * getSegmentBase(const void * row) const = 0;
  123. virtual const char * queryFactoryName() const = 0;
  124. };
  125. interface IKeySegmentFormatTranslator : public IInterface
  126. {
  127. virtual void extractField(void * target, const void * row) const = 0;
  128. virtual const char * queryFactoryName() const = 0;
  129. virtual unsigned queryHashCode() const = 0;
  130. };
  131. ECLRTL_API IStringSet *createRtlStringSet(size32_t size);
  132. ECLRTL_API IStringSet *createRtlStringSetEx(size32_t size, bool bigEndian, bool isSigned);
  133. ECLRTL_API IStringSet *createRtlStringValue(size32_t size, const char * value);
  134. //Following can optionally return either of their arguments as the result.
  135. ECLRTL_API IStringSet *rtlUnionSet(IStringSet * lhs, IStringSet * rhs);
  136. ECLRTL_API IStringSet *rtlIntersectSet(IStringSet * lhs, IStringSet * rhs);
  137. ECLRTL_API IKeySegmentMonitor *createKeySegmentMonitor(bool optional, IStringSet *set, unsigned _offset, unsigned _size);
  138. ECLRTL_API IKeySegmentMonitor *createEmptyKeySegmentMonitor(bool optional, unsigned _offset, unsigned _size);
  139. ECLRTL_API IKeySegmentMonitor *createWildKeySegmentMonitor(unsigned _offset, unsigned _size);
  140. ECLRTL_API IKeySegmentMonitor *createDummyKeySegmentMonitor(unsigned _offset, unsigned _size, bool isSigned, bool isLittleEndian);
  141. ECLRTL_API IKeySegmentMonitor *createSingleKeySegmentMonitor(bool optional, unsigned _offset, unsigned _size, const void * value);
  142. ECLRTL_API IOverrideableKeySegmentMonitor *createOverrideableKeySegmentMonitor(IKeySegmentMonitor *base);
  143. ECLRTL_API IKeySegmentMonitor *createSingleBigSignedKeySegmentMonitor(bool optional, unsigned offset, unsigned size, const void * value);
  144. ECLRTL_API IKeySegmentMonitor *createSingleLittleSignedKeySegmentMonitor(bool optional, unsigned offset, unsigned size, const void * value);
  145. ECLRTL_API IKeySegmentMonitor *createSingleLittleKeySegmentMonitor(bool optional, unsigned offset, unsigned size, const void * value);
  146. //takes over ownership of both arguments
  147. ECLRTL_API IKeySegmentMonitor *createVarOffsetKeySegmentMonitor(IKeySegmentMonitor * base, unsigned offset, IKeySegmentOffsetTranslator * translator);
  148. ECLRTL_API IKeySegmentMonitor *createTranslatedKeySegmentMonitor(IKeySegmentMonitor * base, unsigned offset, IKeySegmentFormatTranslator * translator);
  149. ECLRTL_API IKeySegmentMonitor *deserializeKeySegmentMonitor(MemoryBuffer &mb);
  150. #endif