Lucene++ - a full-featured, c++ search engine
API Documentation


NumericUtils.h
Go to the documentation of this file.
1 // Copyright (c) 2009-2014 Alan Wright. All rights reserved.
3 // Distributable under the terms of either the Apache License (Version 2.0)
4 // or the GNU Lesser General Public License.
6 
7 #ifndef NUMERICUTILS_H
8 #define NUMERICUTILS_H
9 
10 #include "LuceneObject.h"
11 
12 namespace Lucene {
13 
37 class LPPAPI NumericUtils : public LuceneObject {
38 public:
39  virtual ~NumericUtils();
40 
42 
43 public:
46  static const int32_t PRECISION_STEP_DEFAULT;
47 
50  static const wchar_t SHIFT_START_LONG;
51 
54  static const int32_t BUF_SIZE_LONG;
55 
58  static const wchar_t SHIFT_START_INT;
59 
62  static const int32_t BUF_SIZE_INT;
63 
64 public:
71  static int32_t longToPrefixCoded(int64_t val, int32_t shift, CharArray buffer);
72 
77  static String longToPrefixCoded(int64_t val, int32_t shift);
78 
82  static String longToPrefixCoded(int64_t val);
83 
90  static int32_t intToPrefixCoded(int32_t val, int32_t shift, CharArray buffer);
91 
96  static String intToPrefixCoded(int32_t val, int32_t shift);
97 
101  static String intToPrefixCoded(int32_t val);
102 
106  static int64_t prefixCodedToLong(const String& prefixCoded);
107 
111  static int32_t prefixCodedToInt(const String& prefixCoded);
112 
117  static int64_t doubleToSortableLong(double val);
118 
120  static String doubleToPrefixCoded(double val);
121 
124  static double sortableLongToDouble(int64_t val);
125 
127  static double prefixCodedToDouble(const String& val);
128 
132  static void splitLongRange(const LongRangeBuilderPtr& builder, int32_t precisionStep, int64_t minBound, int64_t maxBound);
133 
137  static void splitIntRange(const IntRangeBuilderPtr& builder, int32_t precisionStep, int32_t minBound, int32_t maxBound);
138 
140  static void splitRange(const LuceneObjectPtr& builder, int32_t valSize, int32_t precisionStep, int64_t minBound, int64_t maxBound);
141 
143  static void addRange(const LuceneObjectPtr& builder, int32_t valSize, int64_t minBound, int64_t maxBound, int32_t shift);
144 };
145 
148 class LPPAPI LongRangeBuilder : public LuceneObject {
149 public:
150  virtual ~LongRangeBuilder();
151 
152 public:
155  virtual void addRange(const String& minPrefixCoded, const String& maxPrefixCoded);
156 
159  virtual void addRange(int64_t min, int64_t max, int32_t shift);
160 };
161 
162 class LPPAPI IntRangeBuilder : public LuceneObject {
163 public:
164  virtual ~IntRangeBuilder();
165 
166 public:
169  virtual void addRange(const String& minPrefixCoded, const String& maxPrefixCoded);
170 
173  virtual void addRange(int32_t min, int32_t max, int32_t shift);
174 };
175 
176 }
177 
178 #endif
Lucene::NumericUtils::BUF_SIZE_LONG
static const int32_t BUF_SIZE_LONG
The maximum term length (used for char[] buffer size) for encoding long values.
Definition: NumericUtils.h:54
Lucene::IntRangeBuilderPtr
boost::shared_ptr< IntRangeBuilder > IntRangeBuilderPtr
Definition: LuceneTypes.h:537
LUCENE_CLASS
#define LUCENE_CLASS(Name)
Definition: LuceneObject.h:24
Lucene::NumericUtils::SHIFT_START_LONG
static const wchar_t SHIFT_START_LONG
Longs are stored at lower precision by shifting off lower bits. The shift count is stored as SHIFT_ST...
Definition: NumericUtils.h:50
Lucene::LuceneObjectPtr
boost::shared_ptr< LuceneObject > LuceneObjectPtr
Definition: LuceneTypes.h:539
Lucene::NumericUtils::BUF_SIZE_INT
static const int32_t BUF_SIZE_INT
The maximum term length (used for char[] buffer size) for encoding int values.
Definition: NumericUtils.h:62
Lucene::NumericUtils
This is a helper class to generate prefix-encoded representations for numerical values and supplies c...
Definition: NumericUtils.h:37
Lucene::IntRangeBuilder
Definition: NumericUtils.h:162
Lucene
Definition: AbstractAllTermDocs.h:12
Lucene::LuceneObject
Base class for all Lucene classes.
Definition: LuceneObject.h:31
Lucene::LongRangeBuilder
Callback for splitLongRange. You need to overwrite only one of the methods. NOTE: This is a very low-...
Definition: NumericUtils.h:148
Lucene::LongRangeBuilderPtr
boost::shared_ptr< LongRangeBuilder > LongRangeBuilderPtr
Definition: LuceneTypes.h:538
Lucene::NumericUtils::SHIFT_START_INT
static const wchar_t SHIFT_START_INT
Integers are stored at lower precision by shifting off lower bits. The shift count is stored as SHIFT...
Definition: NumericUtils.h:58
LuceneObject.h

clucene.sourceforge.net