summaryrefslogtreecommitdiffstats
path: root/searchlib
diff options
context:
space:
mode:
authorGeir Storli <geirst@verizonmedia.com>2019-06-05 14:39:56 +0200
committerGitHub <noreply@github.com>2019-06-05 14:39:56 +0200
commita895c7edfe1880493f7f068b0504c085c48280a0 (patch)
treed4b3f93f2c49d19b9806813bcb71be786443b6db /searchlib
parente31ba22c2997a3294fc8979e3b9085485964a278 (diff)
parent88f14e72712df210a1325cb016b9eb8fbcd6668e (diff)
Merge pull request #9689 from vespa-engine/geirst/common-code-for-average-field-length
Geirst/common code for average field length
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;
+};
+
+}