summaryrefslogtreecommitdiffstats
path: root/searchcorespi
diff options
context:
space:
mode:
authorArnstein Ressem <aressem@yahoo-inc.com>2016-10-10 14:24:38 +0200
committerArnstein Ressem <aressem@yahoo-inc.com>2016-10-10 14:24:38 +0200
commitc355f4c97a5455f46ff9c779b6320060f67211d0 (patch)
treefc8005b46c3661d02a6c2cc2c810af21a5ae85eb /searchcorespi
parent2eacefe6b4c7b7981c0fcec0a1fa5fdaa933ec36 (diff)
parent6abdd3d8960ce01422e0cc902cba7e2fa9facc67 (diff)
Merge branch 'master' into aressem/dont-allow-unresolved-symbols-in-shared-libs-or-executables
Diffstat (limited to 'searchcorespi')
-rw-r--r--searchcorespi/src/vespa/searchcorespi/index/CMakeLists.txt4
-rw-r--r--searchcorespi/src/vespa/searchcorespi/index/disk_index_stats.cpp28
-rw-r--r--searchcorespi/src/vespa/searchcorespi/index/disk_index_stats.h26
-rw-r--r--searchcorespi/src/vespa/searchcorespi/index/fakeindexsearchable.h6
-rw-r--r--searchcorespi/src/vespa/searchcorespi/index/iindexmaintaineroperations.h2
-rw-r--r--searchcorespi/src/vespa/searchcorespi/index/imemoryindex.h2
-rw-r--r--searchcorespi/src/vespa/searchcorespi/index/index_manager_explorer.cpp39
-rw-r--r--searchcorespi/src/vespa/searchcorespi/index/index_manager_stats.cpp61
-rw-r--r--searchcorespi/src/vespa/searchcorespi/index/index_manager_stats.h30
-rw-r--r--searchcorespi/src/vespa/searchcorespi/index/index_searchable_stats.cpp29
-rw-r--r--searchcorespi/src/vespa/searchcorespi/index/index_searchable_stats.h32
-rw-r--r--searchcorespi/src/vespa/searchcorespi/index/indexcollection.cpp20
-rw-r--r--searchcorespi/src/vespa/searchcorespi/index/indexcollection.h2
-rw-r--r--searchcorespi/src/vespa/searchcorespi/index/indexmaintainer.cpp36
-rw-r--r--searchcorespi/src/vespa/searchcorespi/index/indexmaintainer.h3
-rw-r--r--searchcorespi/src/vespa/searchcorespi/index/indexsearchable.h14
-rw-r--r--searchcorespi/src/vespa/searchcorespi/index/indexsearchablevisitor.h26
-rw-r--r--searchcorespi/src/vespa/searchcorespi/index/memory_index_stats.cpp26
-rw-r--r--searchcorespi/src/vespa/searchcorespi/index/memory_index_stats.h22
-rw-r--r--searchcorespi/src/vespa/searchcorespi/index/warmupindexcollection.cpp16
-rw-r--r--searchcorespi/src/vespa/searchcorespi/index/warmupindexcollection.h2
21 files changed, 408 insertions, 18 deletions
diff --git a/searchcorespi/src/vespa/searchcorespi/index/CMakeLists.txt b/searchcorespi/src/vespa/searchcorespi/index/CMakeLists.txt
index 65b006f8ea9..84891e37307 100644
--- a/searchcorespi/src/vespa/searchcorespi/index/CMakeLists.txt
+++ b/searchcorespi/src/vespa/searchcorespi/index/CMakeLists.txt
@@ -3,11 +3,13 @@ vespa_add_library(searchcorespi_index OBJECT
SOURCES
activediskindexes.cpp
diskindexcleaner.cpp
+ disk_index_stats.cpp
eventlogger.cpp
fusionrunner.cpp
iindexmanager.cpp
iindexcollection.cpp
index_manager_explorer.cpp
+ index_manager_stats.cpp
indexcollection.cpp
indexdisklayout.cpp
indexflushtarget.cpp
@@ -18,6 +20,8 @@ vespa_add_library(searchcorespi_index OBJECT
indexmanagerconfig.cpp
indexreadutilities.cpp
indexsearchable.cpp
+ index_searchable_stats.cpp
+ memory_index_stats.cpp
indexwriteutilities.cpp
warmupindexcollection.cpp
isearchableindexcollection.cpp
diff --git a/searchcorespi/src/vespa/searchcorespi/index/disk_index_stats.cpp b/searchcorespi/src/vespa/searchcorespi/index/disk_index_stats.cpp
new file mode 100644
index 00000000000..f9d5215d6f5
--- /dev/null
+++ b/searchcorespi/src/vespa/searchcorespi/index/disk_index_stats.cpp
@@ -0,0 +1,28 @@
+// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+
+#include <vespa/fastos/fastos.h>
+#include "disk_index_stats.h"
+#include "idiskindex.h"
+
+
+namespace searchcorespi {
+namespace index {
+
+DiskIndexStats::DiskIndexStats()
+ : IndexSearchableStats(),
+ _indexDir()
+{
+}
+
+DiskIndexStats::DiskIndexStats(const IDiskIndex &index)
+ : IndexSearchableStats(index),
+ _indexDir(index.getIndexDir())
+{
+}
+
+DiskIndexStats::~DiskIndexStats()
+{
+}
+
+} // namespace searchcorespi::index
+} // namespace searchcorespi
diff --git a/searchcorespi/src/vespa/searchcorespi/index/disk_index_stats.h b/searchcorespi/src/vespa/searchcorespi/index/disk_index_stats.h
new file mode 100644
index 00000000000..579a840b756
--- /dev/null
+++ b/searchcorespi/src/vespa/searchcorespi/index/disk_index_stats.h
@@ -0,0 +1,26 @@
+// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+#pragma once
+
+#include "index_searchable_stats.h"
+#include <vespa/vespalib/stllike/string.h>
+
+namespace searchcorespi {
+namespace index {
+
+struct IDiskIndex;
+
+/**
+ * Information about a disk index usable by state explorer.
+ */
+class DiskIndexStats : public IndexSearchableStats {
+ vespalib::string _indexDir;
+public:
+ DiskIndexStats();
+ DiskIndexStats(const IDiskIndex &index);
+ ~DiskIndexStats();
+
+ const vespalib::string &getIndexdir() const { return _indexDir; }
+};
+
+} // namespace searchcorespi::index
+} // namespace searchcorespi
diff --git a/searchcorespi/src/vespa/searchcorespi/index/fakeindexsearchable.h b/searchcorespi/src/vespa/searchcorespi/index/fakeindexsearchable.h
index 0db49c5f2df..00ede178339 100644
--- a/searchcorespi/src/vespa/searchcorespi/index/fakeindexsearchable.h
+++ b/searchcorespi/src/vespa/searchcorespi/index/fakeindexsearchable.h
@@ -37,6 +37,12 @@ public:
virtual search::SearchableStats getSearchableStats() const {
return search::SearchableStats();
}
+
+ virtual search::SerialNum getSerialNum() const override { return 0; }
+ virtual void accept(IndexSearchableVisitor &visitor) const override {
+ (void) visitor;
+ }
+
};
} // namespace searchcorespi
diff --git a/searchcorespi/src/vespa/searchcorespi/index/iindexmaintaineroperations.h b/searchcorespi/src/vespa/searchcorespi/index/iindexmaintaineroperations.h
index 2b8a3ac3965..eb5edbf3298 100644
--- a/searchcorespi/src/vespa/searchcorespi/index/iindexmaintaineroperations.h
+++ b/searchcorespi/src/vespa/searchcorespi/index/iindexmaintaineroperations.h
@@ -19,7 +19,7 @@ struct IIndexMaintainerOperations {
/**
* Creates a new memory index using the given schema.
*/
- virtual IMemoryIndex::SP createMemoryIndex(const search::index::Schema &schema) = 0;
+ virtual IMemoryIndex::SP createMemoryIndex(const search::index::Schema &schema, search::SerialNum serialNum) = 0;
/**
* Loads a disk index from the given directory.
diff --git a/searchcorespi/src/vespa/searchcorespi/index/imemoryindex.h b/searchcorespi/src/vespa/searchcorespi/index/imemoryindex.h
index fabaf730cb7..c8baaf9ca13 100644
--- a/searchcorespi/src/vespa/searchcorespi/index/imemoryindex.h
+++ b/searchcorespi/src/vespa/searchcorespi/index/imemoryindex.h
@@ -61,7 +61,7 @@ struct IMemoryIndex : public searchcorespi::IndexSearchable {
/**
* Commits the inserts and removes since the last commit, making them searchable.
**/
- virtual void commit(OnWriteDoneType onWriteDone) = 0;
+ virtual void commit(OnWriteDoneType onWriteDone, search::SerialNum serialNum) = 0;
/**
* Flushes this memory index to disk as a disk index.
diff --git a/searchcorespi/src/vespa/searchcorespi/index/index_manager_explorer.cpp b/searchcorespi/src/vespa/searchcorespi/index/index_manager_explorer.cpp
index f3695f2bd52..959f5ccdc59 100644
--- a/searchcorespi/src/vespa/searchcorespi/index/index_manager_explorer.cpp
+++ b/searchcorespi/src/vespa/searchcorespi/index/index_manager_explorer.cpp
@@ -4,14 +4,41 @@
#include <vespa/log/log.h>
LOG_SETUP(".searchcorespi.index.index_manager_explorer");
#include "index_manager_explorer.h"
+#include "index_manager_stats.h"
#include <vespa/vespalib/data/slime/cursor.h>
using vespalib::slime::Cursor;
using vespalib::slime::Inserter;
+using search::SearchableStats;
+using searchcorespi::index::DiskIndexStats;
+using searchcorespi::index::MemoryIndexStats;
namespace searchcorespi {
+namespace {
+
+void insertDiskIndex(Cursor &arrayCursor, const DiskIndexStats &diskIndex)
+{
+ Cursor &diskIndexCursor = arrayCursor.addObject();
+ const SearchableStats &sstats = diskIndex.getSearchableStats();
+ diskIndexCursor.setLong("serialNum", diskIndex.getSerialNum());
+ diskIndexCursor.setString("indexDir", diskIndex.getIndexdir());
+ diskIndexCursor.setLong("sizeOnDisk", sstats.sizeOnDisk());
+}
+
+void insertMemoryIndex(Cursor &arrayCursor, const MemoryIndexStats &memoryIndex)
+{
+ Cursor &memoryIndexCursor = arrayCursor.addObject();
+ const SearchableStats &sstats = memoryIndex.getSearchableStats();
+ memoryIndexCursor.setLong("serialNum", memoryIndex.getSerialNum());
+ memoryIndexCursor.setLong("docsInMemory", sstats.docsInMemory());
+ memoryIndexCursor.setLong("memoryUsage", sstats.memoryUsage());
+}
+
+}
+
+
IndexManagerExplorer::IndexManagerExplorer(IIndexManager::SP mgr)
: _mgr(std::move(mgr))
{
@@ -20,9 +47,19 @@ IndexManagerExplorer::IndexManagerExplorer(IIndexManager::SP mgr)
void
IndexManagerExplorer::get_state(const Inserter &inserter, bool full) const
{
- (void) full;
Cursor &object = inserter.insertObject();
object.setLong("lastSerialNum", _mgr->getCurrentSerialNum());
+ if (full) {
+ IndexManagerStats stats(*_mgr);
+ Cursor &diskIndexArrayCursor = object.setArray("diskIndexes");
+ for (const auto &diskIndex : stats.getDiskIndexes()) {
+ insertDiskIndex(diskIndexArrayCursor, diskIndex);
+ }
+ Cursor &memoryIndexArrayCursor = object.setArray("memoryIndexes");
+ for (const auto &memoryIndex : stats.getMemoryIndexes()) {
+ insertMemoryIndex(memoryIndexArrayCursor, memoryIndex);
+ }
+ }
}
} // namespace searchcorespi
diff --git a/searchcorespi/src/vespa/searchcorespi/index/index_manager_stats.cpp b/searchcorespi/src/vespa/searchcorespi/index/index_manager_stats.cpp
new file mode 100644
index 00000000000..035a5698c2f
--- /dev/null
+++ b/searchcorespi/src/vespa/searchcorespi/index/index_manager_stats.cpp
@@ -0,0 +1,61 @@
+// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+
+#include <vespa/fastos/fastos.h>
+#include "index_manager_stats.h"
+#include "iindexmanager.h"
+#include "indexsearchablevisitor.h"
+
+
+namespace searchcorespi {
+
+namespace {
+
+class Visitor : public IndexSearchableVisitor
+{
+public:
+ std::vector<index::DiskIndexStats> _diskIndexes;
+ std::vector<index::MemoryIndexStats> _memoryIndexes;
+
+ Visitor()
+ : _diskIndexes(),
+ _memoryIndexes()
+ {
+ }
+ virtual void visit(const index::IDiskIndex &index) override {
+ _diskIndexes.emplace_back(index);
+ }
+ virtual void visit(const index::IMemoryIndex &index) override {
+ _memoryIndexes.emplace_back(index);
+ }
+
+ void normalize() {
+ std::sort(_diskIndexes.begin(), _diskIndexes.end());
+ std::sort(_memoryIndexes.begin(), _memoryIndexes.end());
+ }
+};
+
+}
+
+IndexManagerStats::IndexManagerStats()
+ : _diskIndexes(),
+ _memoryIndexes()
+{
+}
+
+IndexManagerStats::IndexManagerStats(const IIndexManager &indexManager)
+ : _diskIndexes(),
+ _memoryIndexes()
+{
+ Visitor visitor;
+ IndexSearchable::SP searchable(indexManager.getSearchable());
+ searchable->accept(visitor);
+ visitor.normalize();
+ _diskIndexes = std::move(visitor._diskIndexes);
+ _memoryIndexes = std::move(visitor._memoryIndexes);
+}
+
+IndexManagerStats::~IndexManagerStats()
+{
+}
+
+} // namespace searchcorespi
diff --git a/searchcorespi/src/vespa/searchcorespi/index/index_manager_stats.h b/searchcorespi/src/vespa/searchcorespi/index/index_manager_stats.h
new file mode 100644
index 00000000000..048124b688f
--- /dev/null
+++ b/searchcorespi/src/vespa/searchcorespi/index/index_manager_stats.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.
+#pragma once
+
+#include "disk_index_stats.h"
+#include "memory_index_stats.h"
+
+namespace searchcorespi {
+
+class IIndexManager;
+
+/**
+ * Information about an index manager usable by state explorer.
+ */
+class IndexManagerStats {
+ std::vector<index::DiskIndexStats> _diskIndexes;
+ std::vector<index::MemoryIndexStats> _memoryIndexes;
+public:
+ IndexManagerStats();
+ IndexManagerStats(const IIndexManager &indexManager);
+ ~IndexManagerStats();
+
+ const std::vector<index::DiskIndexStats> &getDiskIndexes() const {
+ return _diskIndexes;
+ }
+ const std::vector<index::MemoryIndexStats> &getMemoryIndexes() const {
+ return _memoryIndexes;
+ }
+};
+
+} // namespace searchcorespi
diff --git a/searchcorespi/src/vespa/searchcorespi/index/index_searchable_stats.cpp b/searchcorespi/src/vespa/searchcorespi/index/index_searchable_stats.cpp
new file mode 100644
index 00000000000..c5ce5163aac
--- /dev/null
+++ b/searchcorespi/src/vespa/searchcorespi/index/index_searchable_stats.cpp
@@ -0,0 +1,29 @@
+// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+
+#include <vespa/fastos/fastos.h>
+#include "index_searchable_stats.h"
+#include "indexsearchable.h"
+
+
+namespace searchcorespi {
+namespace index {
+
+IndexSearchableStats::IndexSearchableStats()
+ : _serialNum(0),
+ _searchableStats()
+{
+}
+
+IndexSearchableStats::IndexSearchableStats(const IndexSearchable &index)
+ : _serialNum(index.getSerialNum()),
+ _searchableStats(index.getSearchableStats())
+{
+}
+
+bool IndexSearchableStats::operator<(const IndexSearchableStats &rhs) const
+{
+ return _serialNum < rhs._serialNum;
+}
+
+} // namespace searchcorespi::index
+} // namespace searchcorespi
diff --git a/searchcorespi/src/vespa/searchcorespi/index/index_searchable_stats.h b/searchcorespi/src/vespa/searchcorespi/index/index_searchable_stats.h
new file mode 100644
index 00000000000..dd904b3b286
--- /dev/null
+++ b/searchcorespi/src/vespa/searchcorespi/index/index_searchable_stats.h
@@ -0,0 +1,32 @@
+// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+
+#pragma once
+
+#include <vespa/searchlib/common/serialnum.h>
+#include <vespa/searchlib/util/searchable_stats.h>
+
+namespace searchcorespi {
+
+class IndexSearchable;
+
+namespace index {
+
+/**
+ * Information about a searchable index usable by state explorer.
+ */
+class IndexSearchableStats
+{
+ using SerialNum = search::SerialNum;
+ using SearchableStats = search::SearchableStats;
+ SerialNum _serialNum;
+ SearchableStats _searchableStats;
+public:
+ IndexSearchableStats();
+ IndexSearchableStats(const IndexSearchable &index);
+ bool operator<(const IndexSearchableStats &rhs) const;
+ SerialNum getSerialNum() const { return _serialNum; }
+ const SearchableStats &getSearchableStats() const { return _searchableStats; }
+};
+
+} // namespace searchcorespi::index
+} // namespace searchcorespi
diff --git a/searchcorespi/src/vespa/searchcorespi/index/indexcollection.cpp b/searchcorespi/src/vespa/searchcorespi/index/indexcollection.cpp
index 0284c4a682e..653cf0a28b4 100644
--- a/searchcorespi/src/vespa/searchcorespi/index/indexcollection.cpp
+++ b/searchcorespi/src/vespa/searchcorespi/index/indexcollection.cpp
@@ -9,6 +9,7 @@ LOG_SETUP(".searchcorespi.index.indexcollection");
#include <vespa/searchlib/queryeval/create_blueprint_visitor_helper.h>
#include <vespa/searchlib/queryeval/intermediate_blueprints.h>
#include <vespa/searchlib/queryeval/leaf_blueprints.h>
+#include "indexsearchablevisitor.h"
using namespace search::queryeval;
using namespace search::query;
@@ -116,6 +117,25 @@ IndexCollection::getSearchableStats() const
return stats;
}
+search::SerialNum
+IndexCollection::getSerialNum() const
+{
+ search::SerialNum serialNum = 0;
+ for (auto &source : _sources) {
+ serialNum = std::max(serialNum, source.source_wrapper->getSerialNum());
+ }
+ return serialNum;
+}
+
+
+void
+IndexCollection::accept(IndexSearchableVisitor &visitor) const
+{
+ for (auto &source : _sources) {
+ source.source_wrapper->accept(visitor);
+ }
+}
+
namespace {
struct Mixer {
diff --git a/searchcorespi/src/vespa/searchcorespi/index/indexcollection.h b/searchcorespi/src/vespa/searchcorespi/index/indexcollection.h
index 223b36fce99..38942abc9dc 100644
--- a/searchcorespi/src/vespa/searchcorespi/index/indexcollection.h
+++ b/searchcorespi/src/vespa/searchcorespi/index/indexcollection.h
@@ -61,6 +61,8 @@ public:
const Node &term,
const IAttributeContext &attrCtx);
virtual search::SearchableStats getSearchableStats() const;
+ virtual search::SerialNum getSerialNum() const override;
+ virtual void accept(IndexSearchableVisitor &visitor) const override;
static ISearchableIndexCollection::UP replaceAndRenumber(
const ISourceSelector::SP & selector,
diff --git a/searchcorespi/src/vespa/searchcorespi/index/indexmaintainer.cpp b/searchcorespi/src/vespa/searchcorespi/index/indexmaintainer.cpp
index 36d42e245e1..3db3875b561 100644
--- a/searchcorespi/src/vespa/searchcorespi/index/indexmaintainer.cpp
+++ b/searchcorespi/src/vespa/searchcorespi/index/indexmaintainer.cpp
@@ -117,6 +117,12 @@ public:
return _index->createBlueprint(requestContext, fields, term, attrCtx);
}
virtual search::SearchableStats getSearchableStats() const { return _index->getSearchableStats(); }
+ virtual search::SerialNum getSerialNum() const override {
+ return _index->getSerialNum();
+ }
+ virtual void accept(IndexSearchableVisitor &visitor) const override {
+ _index->accept(visitor);
+ }
/**
* Implements IDiskIndex
@@ -293,7 +299,8 @@ IDiskIndex::SP
IndexMaintainer::flushMemoryIndex(IMemoryIndex &memoryIndex,
uint32_t indexId,
uint32_t docIdLimit,
- SerialNum serialNum)
+ SerialNum serialNum,
+ FixedSourceSelector::SaveInfo &saveInfo)
{
// Called by a flush worker thread
const string flushDir = getFlushDir(indexId);
@@ -302,6 +309,11 @@ IndexMaintainer::flushMemoryIndex(IMemoryIndex &memoryIndex,
if (wtSchema.get() != NULL) {
updateDiskIndexSchema(flushDir, *wtSchema, noSerialNumHigh);
}
+ IndexWriteUtilities::writeSourceSelector(saveInfo, indexId, getAttrTune(),
+ _ctx.getFileHeaderContext(),
+ serialNum);
+ IndexWriteUtilities::writeSerialNum(serialNum, flushDir,
+ _ctx.getFileHeaderContext());
return loadDiskIndex(flushDir);
}
@@ -521,14 +533,8 @@ IndexMaintainer::flushMemoryIndex(FlushArgs &args,
IMemoryIndex &memoryIndex = *args.old_index;
Schema::SP wtSchema = memoryIndex.getWipeTimeSchema();
IDiskIndex::SP diskIndex = flushMemoryIndex(memoryIndex, args.old_absolute_id,
- docIdLimit, args.flush_serial_num);
- IndexWriteUtilities::writeSourceSelector(saveInfo, args.old_absolute_id,
- getAttrTune(), _ctx.getFileHeaderContext(),
- args.flush_serial_num);
- IndexWriteUtilities::writeSerialNum(args.flush_serial_num,
- getFlushDir(args.old_absolute_id),
- _ctx.getFileHeaderContext());
-
+ docIdLimit, args.flush_serial_num,
+ saveInfo);
// Post processing after memory index has been written to disk and
// opened as disk index.
args._changeGens = changeGens;
@@ -799,7 +805,7 @@ IndexMaintainer::IndexMaintainer(const IndexMaintainerConfig &config,
_last_fusion_id(),
_next_id(),
_current_index_id(),
- _current_index(operations.createMemoryIndex(_schema)),
+ _current_index(),
_current_serial_num(0),
_flush_serial_num(0),
_lastFlushTime(),
@@ -848,6 +854,7 @@ IndexMaintainer::IndexMaintainer(const IndexMaintainerConfig &config,
_selector.reset(getSourceSelector().cloneAndSubtract(ost.str(), id_diff).release());
assert(_last_fusion_id == _selector->getBaseId());
}
+ _current_index = operations.createMemoryIndex(_schema, _current_serial_num);
_current_index_id = getNewAbsoluteId() - _last_fusion_id;
assert(_current_index_id < ISourceSelector::SOURCE_LIMIT);
ISearchableIndexCollection::UP sourceList(loadDiskIndexes(spec, ISearchableIndexCollection::UP(new IndexCollection(_selector))));
@@ -874,7 +881,7 @@ IndexMaintainer::initFlush(SerialNum serialNum, searchcorespi::FlushStats * stat
_current_serial_num = std::max(_current_serial_num, serialNum);
}
- IMemoryIndex::SP new_index(_operations.createMemoryIndex(getSchema()));
+ IMemoryIndex::SP new_index(_operations.createMemoryIndex(getSchema(), _current_serial_num));
FlushArgs args;
args.stats = stats;
scheduleCommit();
@@ -1132,7 +1139,8 @@ IndexMaintainer::commit()
// only triggered via scheduleCommit()
assert(_ctx.getThreadingService().index().isCurrentThread());
LockGuard lock(_index_update_lock);
- _current_index->commit(std::shared_ptr<search::IDestructorCallback>());
+ _current_index->commit(std::shared_ptr<search::IDestructorCallback>(),
+ _current_serial_num);
// caller calls _ctx.getThreadingService().sync()
}
@@ -1142,7 +1150,7 @@ IndexMaintainer::commit(SerialNum serialNum, OnWriteDoneType onWriteDone)
assert(_ctx.getThreadingService().index().isCurrentThread());
LockGuard lock(_index_update_lock);
_current_serial_num = serialNum;
- _current_index->commit(onWriteDone);
+ _current_index->commit(onWriteDone, serialNum);
}
void
@@ -1169,7 +1177,7 @@ void
IndexMaintainer::setSchema(const Schema & schema, const Schema & fusionSchema)
{
assert(_ctx.getThreadingService().master().isCurrentThread());
- IMemoryIndex::SP new_index(_operations.createMemoryIndex(schema));
+ IMemoryIndex::SP new_index(_operations.createMemoryIndex(schema, _current_serial_num));
SetSchemaArgs args;
args._newSchema = schema;
diff --git a/searchcorespi/src/vespa/searchcorespi/index/indexmaintainer.h b/searchcorespi/src/vespa/searchcorespi/index/indexmaintainer.h
index 417f79fa6ca..39e3d116d44 100644
--- a/searchcorespi/src/vespa/searchcorespi/index/indexmaintainer.h
+++ b/searchcorespi/src/vespa/searchcorespi/index/indexmaintainer.h
@@ -185,7 +185,8 @@ class IndexMaintainer : public IIndexManager,
flushMemoryIndex(IMemoryIndex &memoryIndex,
uint32_t indexId,
uint32_t docIdLimit,
- SerialNum serialNum);
+ SerialNum serialNum,
+ search::FixedSourceSelector::SaveInfo &saveInfo);
ISearchableIndexCollection::UP loadDiskIndexes(const FusionSpec &spec, ISearchableIndexCollection::UP sourceList);
void replaceSource(uint32_t sourceId, const IndexSearchable::SP &source);
diff --git a/searchcorespi/src/vespa/searchcorespi/index/indexsearchable.h b/searchcorespi/src/vespa/searchcorespi/index/indexsearchable.h
index 2d4d7cd9674..89a7c8d9f07 100644
--- a/searchcorespi/src/vespa/searchcorespi/index/indexsearchable.h
+++ b/searchcorespi/src/vespa/searchcorespi/index/indexsearchable.h
@@ -8,9 +8,12 @@
#include <vespa/searchlib/queryeval/blueprint.h>
#include <vespa/searchlib/queryeval/irequestcontext.h>
#include <vespa/searchlib/util/searchable_stats.h>
+#include <vespa/searchlib/common/serialnum.h>
namespace searchcorespi {
+class IndexSearchableVisitor;
+
/**
* Abstract class extended by components to expose content that can be
* searched by a query term. A IndexSearchable component supports searching
@@ -72,6 +75,17 @@ public:
* Returns the searchable stats for this index searchable.
*/
virtual search::SearchableStats getSearchableStats() const = 0;
+
+ /*
+ * Returns the serial number for this index searchable.
+ */
+ virtual search::SerialNum getSerialNum() const = 0;
+
+ /*
+ * Calls visitor with properly downcasted argument to differentiate
+ * between different types of indexes (disk index or memory index).
+ */
+ virtual void accept(IndexSearchableVisitor &visitor) const = 0;
};
} // namespace searchcorespi
diff --git a/searchcorespi/src/vespa/searchcorespi/index/indexsearchablevisitor.h b/searchcorespi/src/vespa/searchcorespi/index/indexsearchablevisitor.h
new file mode 100644
index 00000000000..8238f916c99
--- /dev/null
+++ b/searchcorespi/src/vespa/searchcorespi/index/indexsearchablevisitor.h
@@ -0,0 +1,26 @@
+// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+
+#pragma once
+
+namespace searchcorespi {
+
+namespace index {
+
+struct IDiskIndex;
+struct IMemoryIndex;
+
+}
+
+/*
+ * Interface for visiting an index searchable containing disk and
+ * memory indexes.
+ */
+class IndexSearchableVisitor
+{
+public:
+ virtual ~IndexSearchableVisitor() { }
+ virtual void visit(const index::IDiskIndex &index) = 0;
+ virtual void visit(const index::IMemoryIndex &index) = 0;
+};
+
+} // namespace searchcorespi
diff --git a/searchcorespi/src/vespa/searchcorespi/index/memory_index_stats.cpp b/searchcorespi/src/vespa/searchcorespi/index/memory_index_stats.cpp
new file mode 100644
index 00000000000..7805702fd03
--- /dev/null
+++ b/searchcorespi/src/vespa/searchcorespi/index/memory_index_stats.cpp
@@ -0,0 +1,26 @@
+// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+
+#include <vespa/fastos/fastos.h>
+#include "memory_index_stats.h"
+#include "imemoryindex.h"
+
+
+namespace searchcorespi {
+namespace index {
+
+MemoryIndexStats::MemoryIndexStats()
+ : IndexSearchableStats()
+{
+}
+
+MemoryIndexStats::MemoryIndexStats(const IMemoryIndex &index)
+ : IndexSearchableStats(index)
+{
+}
+
+MemoryIndexStats::~MemoryIndexStats()
+{
+}
+
+} // namespace searchcorespi::index
+} // namespace searchcorespi
diff --git a/searchcorespi/src/vespa/searchcorespi/index/memory_index_stats.h b/searchcorespi/src/vespa/searchcorespi/index/memory_index_stats.h
new file mode 100644
index 00000000000..7508ecef3cc
--- /dev/null
+++ b/searchcorespi/src/vespa/searchcorespi/index/memory_index_stats.h
@@ -0,0 +1,22 @@
+// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+#pragma once
+
+#include "index_searchable_stats.h"
+
+namespace searchcorespi {
+namespace index {
+
+struct IMemoryIndex;
+
+/**
+ * Information about a memory index usable by state explorer.
+ */
+class MemoryIndexStats : public IndexSearchableStats {
+public:
+ MemoryIndexStats();
+ MemoryIndexStats(const IMemoryIndex &index);
+ ~MemoryIndexStats();
+};
+
+} // namespace searchcorespi::index
+} // namespace searchcorespi
diff --git a/searchcorespi/src/vespa/searchcorespi/index/warmupindexcollection.cpp b/searchcorespi/src/vespa/searchcorespi/index/warmupindexcollection.cpp
index c993c79a93e..53a2a4d59ea 100644
--- a/searchcorespi/src/vespa/searchcorespi/index/warmupindexcollection.cpp
+++ b/searchcorespi/src/vespa/searchcorespi/index/warmupindexcollection.cpp
@@ -184,6 +184,22 @@ WarmupIndexCollection::getSearchableStats() const
return _prev->getSearchableStats();
}
+
+search::SerialNum
+WarmupIndexCollection::getSerialNum() const
+{
+ return std::max(_prev->getSerialNum(), _next->getSerialNum());
+}
+
+
+void
+WarmupIndexCollection::accept(IndexSearchableVisitor &visitor) const
+{
+ _prev->accept(visitor);
+ _next->accept(visitor);
+}
+
+
void
WarmupIndexCollection::append(uint32_t id, const IndexSearchable::SP &source)
{
diff --git a/searchcorespi/src/vespa/searchcorespi/index/warmupindexcollection.h b/searchcorespi/src/vespa/searchcorespi/index/warmupindexcollection.h
index a304b3b9df2..be25b81d498 100644
--- a/searchcorespi/src/vespa/searchcorespi/index/warmupindexcollection.h
+++ b/searchcorespi/src/vespa/searchcorespi/index/warmupindexcollection.h
@@ -49,6 +49,8 @@ public:
const Node &term,
const IAttributeContext &attrCtx);
search::SearchableStats getSearchableStats() const override;
+ search::SerialNum getSerialNum() const override;
+ void accept(IndexSearchableVisitor &visitor) const override;
// Implements ISearchableIndexCollection
void append(uint32_t id, const IndexSearchable::SP &source) override;