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


 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
NumericUtils.h
Go to the documentation of this file.
1 // Copyright (c) 2009-2011 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  {
39  public:
40  virtual ~NumericUtils();
41 
43 
44  public:
47  static const int32_t PRECISION_STEP_DEFAULT;
48 
51  static const wchar_t SHIFT_START_LONG;
52 
55  static const int32_t BUF_SIZE_LONG;
56 
59  static const wchar_t SHIFT_START_INT;
60 
63  static const int32_t BUF_SIZE_INT;
64 
65  public:
72  static int32_t longToPrefixCoded(int64_t val, int32_t shift, CharArray buffer);
73 
78  static String longToPrefixCoded(int64_t val, int32_t shift);
79 
83  static String longToPrefixCoded(int64_t val);
84 
91  static int32_t intToPrefixCoded(int32_t val, int32_t shift, CharArray buffer);
92 
97  static String intToPrefixCoded(int32_t val, int32_t shift);
98 
102  static String intToPrefixCoded(int32_t val);
103 
107  static int64_t prefixCodedToLong(const String& prefixCoded);
108 
112  static int32_t prefixCodedToInt(const String& prefixCoded);
113 
118  static int64_t doubleToSortableLong(double val);
119 
121  static String doubleToPrefixCoded(double val);
122 
125  static double sortableLongToDouble(int64_t val);
126 
128  static double prefixCodedToDouble(const String& val);
129 
133  static void splitLongRange(LongRangeBuilderPtr builder, int32_t precisionStep, int64_t minBound, int64_t maxBound);
134 
138  static void splitIntRange(IntRangeBuilderPtr builder, int32_t precisionStep, int32_t minBound, int32_t maxBound);
139 
141  static void splitRange(LuceneObjectPtr builder, int32_t valSize, int32_t precisionStep, int64_t minBound, int64_t maxBound);
142 
144  static void addRange(LuceneObjectPtr builder, int32_t valSize, int64_t minBound, int64_t maxBound, int32_t shift);
145  };
146 
149  class LPPAPI LongRangeBuilder : public LuceneObject
150  {
151  public:
152  virtual ~LongRangeBuilder();
153 
154  public:
157  virtual void addRange(const String& minPrefixCoded, const String& maxPrefixCoded);
158 
161  virtual void addRange(int64_t min, int64_t max, int32_t shift);
162  };
163 
164  class LPPAPI IntRangeBuilder : public LuceneObject
165  {
166  public:
167  virtual ~IntRangeBuilder();
168 
169  public:
172  virtual void addRange(const String& minPrefixCoded, const String& maxPrefixCoded);
173 
176  virtual void addRange(int32_t min, int32_t max, int32_t shift);
177  };
178 }
179 
180 #endif

clucene.sourceforge.net