summaryrefslogtreecommitdiffstats
path: root/searchcommon
diff options
context:
space:
mode:
authorGeir Storli <geirst@yahoo-inc.com>2017-03-14 14:11:06 +0000
committerGeir Storli <geirst@yahoo-inc.com>2017-03-14 14:11:06 +0000
commit4d641153080e1e8fc5dfdd4bbf636887413e68ca (patch)
tree40b2826c5838954325dd9b422af9b5b369c3ad02 /searchcommon
parent880ce3b68950dc86be0f6d5ae79813ac2c3e8b32 (diff)
Move search::attribute::ISearchContext to searchcommon in preparation of extending IAttributeVector API.
Diffstat (limited to 'searchcommon')
-rw-r--r--searchcommon/src/vespa/searchcommon/attribute/i_search_context.h68
-rw-r--r--searchcommon/src/vespa/searchcommon/common/range.h30
2 files changed, 98 insertions, 0 deletions
diff --git a/searchcommon/src/vespa/searchcommon/attribute/i_search_context.h b/searchcommon/src/vespa/searchcommon/attribute/i_search_context.h
new file mode 100644
index 00000000000..bb6dfe0daf6
--- /dev/null
+++ b/searchcommon/src/vespa/searchcommon/attribute/i_search_context.h
@@ -0,0 +1,68 @@
+// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+
+#pragma once
+
+#include <vespa/searchcommon/common/range.h>
+
+namespace search {
+
+namespace fef {
+ class TermFieldMatchData;
+}
+namespace queryeval {
+ class SearchIterator;
+}
+
+class QueryTermBase;
+
+namespace attribute {
+
+
+ class ISearchContext {
+ public:
+ virtual ~ISearchContext() {}
+
+ virtual unsigned int approximateHits() const = 0;
+
+ /**
+ * Creates an attribute search iterator associated with this
+ * search context.
+ *
+ * @return attribute search iterator
+ *
+ * @param matchData the attribute match data used when
+ * unpacking data for a hit
+ *
+ * @param strict whether the iterator should be strict or not
+ **/
+ virtual std::unique_ptr<queryeval::SearchIterator>
+ createIterator(fef::TermFieldMatchData *matchData, bool strict) = 0;
+
+ /**
+ * Creates an attribute search iterator associated with this
+ * search context. Postings lists are not used.
+ *
+ * @return attribute search iterator
+ *
+ * @param matchData the attribute match data used when
+ * unpacking data for a hit
+ *
+ * @param strict whether the iterator should be strict or not
+ **/
+ virtual std::unique_ptr<queryeval::SearchIterator>
+ createFilterIterator(fef::TermFieldMatchData *matchData, bool strict) = 0;
+
+ /*
+ * Create temporary posting lists. Should be called before
+ * createIterator is called.
+ */
+ virtual void fetchPostings(bool strict) = 0;
+ virtual bool valid() const = 0;
+ virtual Int64Range getAsIntegerTerm() const = 0;
+
+ virtual const QueryTermBase & queryTerm() const = 0;
+
+ };
+
+}
+}
diff --git a/searchcommon/src/vespa/searchcommon/common/range.h b/searchcommon/src/vespa/searchcommon/common/range.h
new file mode 100644
index 00000000000..f33630daaf4
--- /dev/null
+++ b/searchcommon/src/vespa/searchcommon/common/range.h
@@ -0,0 +1,30 @@
+// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+// Copyright (C) 1998-2003 Fast Search & Transfer ASA
+// Copyright (C) 2003 Overture Services Norway AS
+
+#pragma once
+
+namespace search
+{
+
+template <typename T>
+class Range {
+public:
+ Range() :
+ _lower(std::numeric_limits<T>::max()),
+ _upper(std::numeric_limits<T>::min()) { }
+ Range(T v) : _lower(v), _upper(v) { }
+ Range(T low, T high) : _lower(low), _upper(high) { }
+ T lower() const { return _lower; }
+ T upper() const { return _upper; }
+ bool valid() const { return _lower <= _upper; }
+ bool isPoint() const { return _lower == _upper; }
+private:
+ T _lower;
+ T _upper;
+};
+
+using Int64Range = Range<int64_t>;
+
+} // namespace search
+