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

Loading...
Searching...
No Matches
NumericUtils.h
Go to the documentation of this file.
1
2// 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
41 LUCENE_CLASS(NumericUtils);
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
LuceneObject.h
LUCENE_CLASS
#define LUCENE_CLASS(Name)
Definition LuceneObject.h:24
Lucene::IntRangeBuilder
Definition NumericUtils.h:162
Lucene::IntRangeBuilder::addRange
virtual void addRange(const String &minPrefixCoded, const String &maxPrefixCoded)
Overwrite this method, if you like to receive the already prefix encoded range bounds....
Lucene::IntRangeBuilder::addRange
virtual void addRange(int32_t min, int32_t max, int32_t shift)
Overwrite this method, if you like to receive the raw int range bounds. You can use this for eg....
Lucene::IntRangeBuilder::~IntRangeBuilder
virtual ~IntRangeBuilder()
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::LongRangeBuilder::addRange
virtual void addRange(int64_t min, int64_t max, int32_t shift)
Overwrite this method, if you like to receive the raw long range bounds. You can use this for eg....
Lucene::LongRangeBuilder::addRange
virtual void addRange(const String &minPrefixCoded, const String &maxPrefixCoded)
Overwrite this method, if you like to receive the already prefix encoded range bounds....
Lucene::LongRangeBuilder::~LongRangeBuilder
virtual ~LongRangeBuilder()
Lucene::LuceneObject::LuceneObject
LuceneObject()
Lucene::NumericUtils
This is a helper class to generate prefix-encoded representations for numerical values and supplies c...
Definition NumericUtils.h:37
Lucene::NumericUtils::sortableLongToDouble
static double sortableLongToDouble(int64_t val)
Converts a sortable long back to a double.
Lucene::NumericUtils::splitIntRange
static void splitIntRange(const IntRangeBuilderPtr &builder, int32_t precisionStep, int32_t minBound, int32_t maxBound)
Splits an int32_t range recursively. You may implement a builder that adds clauses to a BooleanQuery ...
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
Lucene::NumericUtils::intToPrefixCoded
static int32_t intToPrefixCoded(int32_t val, int32_t shift, CharArray buffer)
Returns prefix coded bits after reducing the precision by shift bits. This is method is used by Numer...
Lucene::NumericUtils::doubleToSortableLong
static int64_t doubleToSortableLong(double val)
Converts a double value to a sortable signed long. The value is converted by getting their IEEE 754 f...
Lucene::NumericUtils::prefixCodedToInt
static int32_t prefixCodedToInt(const String &prefixCoded)
Returns an int from prefixCoded characters. Rightmost bits will be zero for lower precision codes....
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::NumericUtils::longToPrefixCoded
static String longToPrefixCoded(int64_t val, int32_t shift)
Returns prefix coded bits after reducing the precision by shift bits. This is method is used by LongR...
Lucene::NumericUtils::prefixCodedToDouble
static double prefixCodedToDouble(const String &val)
Convenience method: this just returns: sortableLongToDouble(prefixCodedToLong(val)).
Lucene::NumericUtils::longToPrefixCoded
static int32_t longToPrefixCoded(int64_t val, int32_t shift, CharArray buffer)
Returns prefix coded bits after reducing the precision by shift bits. This is method is used by Numer...
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::PRECISION_STEP_DEFAULT
static const int32_t PRECISION_STEP_DEFAULT
The default precision step used by NumericField, NumericTokenStream, NumericRangeQuery,...
Definition NumericUtils.h:46
Lucene::NumericUtils::splitRange
static void splitRange(const LuceneObjectPtr &builder, int32_t valSize, int32_t precisionStep, int64_t minBound, int64_t maxBound)
This helper does the splitting for both 32 and 64 bit.
Lucene::NumericUtils::doubleToPrefixCoded
static String doubleToPrefixCoded(double val)
Convenience method: this just returns: longToPrefixCoded(doubleToSortableLong(val)).
Lucene::NumericUtils::longToPrefixCoded
static String longToPrefixCoded(int64_t val)
This is a convenience method, that returns prefix coded bits of a long without reducing the precision...
Lucene::NumericUtils::intToPrefixCoded
static String intToPrefixCoded(int32_t val)
This is a convenience method, that returns prefix coded bits of an int without reducing the precision...
Lucene::NumericUtils::intToPrefixCoded
static String intToPrefixCoded(int32_t val, int32_t shift)
Returns prefix coded bits after reducing the precision by shift bits. This is method is used by IntRa...
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::NumericUtils::splitLongRange
static void splitLongRange(const LongRangeBuilderPtr &builder, int32_t precisionStep, int64_t minBound, int64_t maxBound)
Splits a int64_t range recursively. You may implement a builder that adds clauses to a BooleanQuery f...
Lucene::NumericUtils::~NumericUtils
virtual ~NumericUtils()
Lucene::NumericUtils::prefixCodedToLong
static int64_t prefixCodedToLong(const String &prefixCoded)
Returns a long from prefixCoded characters. Rightmost bits will be zero for lower precision codes....
Lucene::NumericUtils::addRange
static void addRange(const LuceneObjectPtr &builder, int32_t valSize, int64_t minBound, int64_t maxBound, int32_t shift)
Helper that delegates to correct range builder.
Lucene
Definition AbstractAllTermDocs.h:12
Lucene::IntRangeBuilderPtr
boost::shared_ptr< IntRangeBuilder > IntRangeBuilderPtr
Definition LuceneTypes.h:537
Lucene::LuceneObjectPtr
boost::shared_ptr< LuceneObject > LuceneObjectPtr
Definition LuceneTypes.h:539
Lucene::LongRangeBuilderPtr
boost::shared_ptr< LongRangeBuilder > LongRangeBuilderPtr
Definition LuceneTypes.h:538

clucene.sourceforge.net