summaryrefslogtreecommitdiffstats
path: root/searchlib
diff options
context:
space:
mode:
authorGeir Storli <geirst@verizonmedia.com>2019-06-05 12:04:35 +0000
committerGeir Storli <geirst@verizonmedia.com>2019-06-05 12:04:35 +0000
commit88f14e72712df210a1325cb016b9eb8fbcd6668e (patch)
tree3efb4af348cfae75daef9a6069df64b755e93c05 /searchlib
parent8c5743fca9173e780a527f88b36cda797179623f (diff)
Add common class and interface needed for tracking average field length for index fields.
Diffstat (limited to 'searchlib')
-rw-r--r--searchlib/src/vespa/searchlib/index/field_length_info.h31
-rw-r--r--searchlib/src/vespa/searchlib/index/i_field_length_inspector.h23
2 files changed, 54 insertions, 0 deletions
diff --git a/searchlib/src/vespa/searchlib/index/field_length_info.h b/searchlib/src/vespa/searchlib/index/field_length_info.h
new file mode 100644
index 00000000000..3ae3d38d86e
--- /dev/null
+++ b/searchlib/src/vespa/searchlib/index/field_length_info.h
@@ -0,0 +1,31 @@
+// Copyright 2019 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+
+#pragma once
+
+namespace search::index {
+
+/**
+ * Information about average field length for a single index field.
+ */
+class FieldLengthInfo {
+private:
+ double _average_field_length;
+ uint32_t _num_samples;
+
+public:
+ FieldLengthInfo()
+ : FieldLengthInfo(0.0, 0)
+ {
+ }
+
+ FieldLengthInfo(double average_field_length, uint32_t num_samples)
+ : _average_field_length(average_field_length),
+ _num_samples(num_samples)
+ {
+ }
+
+ double get_average_field_length() const { return _average_field_length; }
+ uint32_t get_num_samples() const { return _num_samples; }
+};
+
+}
diff --git a/searchlib/src/vespa/searchlib/index/i_field_length_inspector.h b/searchlib/src/vespa/searchlib/index/i_field_length_inspector.h
new file mode 100644
index 00000000000..31b0a44b0c3
--- /dev/null
+++ b/searchlib/src/vespa/searchlib/index/i_field_length_inspector.h
@@ -0,0 +1,23 @@
+// Copyright 2019 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+
+#pragma once
+
+#include "field_length_info.h"
+#include <vespa/vespalib/stllike/string.h>
+
+namespace search::index {
+
+/**
+ * Interface used to inspect field length info for various index fields.
+ */
+class IFieldLengthInspector {
+public:
+ virtual ~IFieldLengthInspector() {}
+
+ /**
+ * Returns the field length info for the given index field, or empty info if the field is not found.
+ */
+ virtual FieldLengthInfo get_field_length_info(const vespalib::string& field_name) const = 0;
+};
+
+}