summaryrefslogtreecommitdiffstats
path: root/searchlib
diff options
context:
space:
mode:
authorHåvard Pettersen <havardpe@oath.com>2022-04-06 12:18:08 +0000
committerHåvard Pettersen <havardpe@oath.com>2022-04-08 13:45:13 +0000
commit9fbcf76d088740aacf535e6482f86c833cfae871 (patch)
treec62dcd0f9cdcee9876b37c60f741958c14147f80 /searchlib
parent69454cef2fe53694eb5541e5f622a4e973c081bf (diff)
remove FastOS_Application
fixup (per application): - maybe ignore SIGPIPE - wire argc/argv untangle Vespa Test Framework strip down deprecated TestApp
Diffstat (limited to 'searchlib')
-rw-r--r--searchlib/src/apps/docstore/benchmarkdatastore.cpp43
-rw-r--r--searchlib/src/apps/docstore/create-idx-from-dat.cpp29
-rw-r--r--searchlib/src/apps/docstore/documentstoreinspect.cpp41
-rw-r--r--searchlib/src/apps/docstore/verifylogdatastore.cpp27
-rw-r--r--searchlib/src/apps/uniform/uniform.cpp15
-rw-r--r--searchlib/src/apps/vespa-attribute-inspect/vespa-attribute-inspect.cpp20
-rw-r--r--searchlib/src/apps/vespa-fileheader-inspect/vespa-fileheader-inspect.cpp33
-rw-r--r--searchlib/src/apps/vespa-index-inspect/vespa-index-inspect.cpp79
-rw-r--r--searchlib/src/apps/vespa-ranking-expression-analyzer/vespa-ranking-expression-analyzer.cpp25
-rw-r--r--searchlib/src/tests/attribute/benchmark/attributebenchmark.cpp20
-rw-r--r--searchlib/src/tests/bitvector/bitvectorbenchmark.cpp18
-rw-r--r--searchlib/src/tests/diskindex/fieldwriter/fieldwriter_test.cpp20
-rw-r--r--searchlib/src/tests/diskindex/pagedict4/pagedict4test.cpp28
-rw-r--r--searchlib/src/tests/postinglistbm/postinglistbm.cpp17
-rw-r--r--searchlib/src/tests/transactionlogstress/translogstress.cpp18
15 files changed, 225 insertions, 208 deletions
diff --git a/searchlib/src/apps/docstore/benchmarkdatastore.cpp b/searchlib/src/apps/docstore/benchmarkdatastore.cpp
index 4a0be335b11..9c2a40d6e98 100644
--- a/searchlib/src/apps/docstore/benchmarkdatastore.cpp
+++ b/searchlib/src/apps/docstore/benchmarkdatastore.cpp
@@ -7,7 +7,7 @@
#include <vespa/vespalib/util/lambdatask.h>
#include <vespa/vespalib/util/size_literals.h>
#include <vespa/vespalib/util/threadstackexecutor.h>
-#include <vespa/fastos/app.h>
+#include <vespa/vespalib/util/signalhandler.h>
#include <unistd.h>
#include <random>
@@ -16,40 +16,41 @@ LOG_SETUP("documentstore.benchmark");
using namespace search;
-class BenchmarkDataStoreApp : public FastOS_Application
+class BenchmarkDataStoreApp
{
- void usage();
+ void usage(const char *self);
int benchmark(const vespalib::string & directory, size_t numReads, size_t numThreads, size_t perChunk, const vespalib::string & readType);
- int Main() override;
void read(size_t numReads, size_t perChunk, const IDataStore * dataStore);
+public:
+ int main(int argc, char **argv);
};
void
-BenchmarkDataStoreApp::usage()
+BenchmarkDataStoreApp::usage(const char *self)
{
- printf("Usage: %s <direcory> <numreads> <numthreads> <objects per read> <normal,directio,mmap>\n", _argv[0]);
+ printf("Usage: %s <direcory> <numreads> <numthreads> <objects per read> <normal,directio,mmap>\n", self);
fflush(stdout);
}
int
-BenchmarkDataStoreApp::Main()
+BenchmarkDataStoreApp::main(int argc, char **argv)
{
- if (_argc >= 2) {
+ if (argc >= 2) {
size_t numThreads(16);
size_t numReads(1000000);
size_t perChunk(1);
vespalib::string readType("directio");
- vespalib::string directory(_argv[1]);
- if (_argc >= 3) {
- numReads = strtoul(_argv[2], NULL, 0);
- if (_argc >= 4) {
- numThreads = strtoul(_argv[3], NULL, 0);
- if (_argc >= 5) {
- perChunk = strtoul(_argv[4], NULL, 0);
- if (_argc >= 5) {
- readType = _argv[5];
+ vespalib::string directory(argv[1]);
+ if (argc >= 3) {
+ numReads = strtoul(argv[2], NULL, 0);
+ if (argc >= 4) {
+ numThreads = strtoul(argv[3], NULL, 0);
+ if (argc >= 5) {
+ perChunk = strtoul(argv[4], NULL, 0);
+ if (argc >= 5) {
+ readType = argv[5];
}
}
}
@@ -57,7 +58,7 @@ BenchmarkDataStoreApp::Main()
return benchmark(directory, numReads, numThreads, perChunk, readType);
} else {
fprintf(stderr, "Too few arguments\n");
- usage();
+ usage(argv[0]);
return 1;
}
return 0;
@@ -111,4 +112,8 @@ BenchmarkDataStoreApp::benchmark(const vespalib::string & dir, size_t numReads,
return retval;
}
-FASTOS_MAIN(BenchmarkDataStoreApp);
+int main(int argc, char **argv) {
+ vespalib::SignalHandler::PIPE.ignore();
+ BenchmarkDataStoreApp app;
+ return app.main(argc, argv);
+}
diff --git a/searchlib/src/apps/docstore/create-idx-from-dat.cpp b/searchlib/src/apps/docstore/create-idx-from-dat.cpp
index 30af02ddb92..7ac6b37473c 100644
--- a/searchlib/src/apps/docstore/create-idx-from-dat.cpp
+++ b/searchlib/src/apps/docstore/create-idx-from-dat.cpp
@@ -4,24 +4,25 @@
#include <vespa/searchlib/docstore/randreaders.h>
#include <vespa/searchlib/index/dummyfileheadercontext.h>
#include <vespa/vespalib/objects/nbostream.h>
-#include <vespa/fastos/app.h>
+#include <vespa/vespalib/util/signalhandler.h>
#include <vespa/vespalib/util/exception.h>
#include <cinttypes>
#include <cassert>
using namespace search;
-class CreateIdxFileFromDatApp : public FastOS_Application
+class CreateIdxFileFromDatApp
{
- void usage();
+ void usage(const char *self);
int createIdxFile(const vespalib::string & datFileName, const vespalib::string & idxFileName);
- int Main() override;
+public:
+ int main(int argc, char **argv);
};
void
-CreateIdxFileFromDatApp::usage()
+CreateIdxFileFromDatApp::usage(const char *self)
{
- printf("Usage: %s <datfile> <idxfile>\n", _argv[0]);
+ printf("Usage: %s <datfile> <idxfile>\n", self);
fflush(stdout);
}
@@ -152,19 +153,23 @@ int CreateIdxFileFromDatApp::createIdxFile(const vespalib::string & datFileName,
}
int
-CreateIdxFileFromDatApp::Main()
+CreateIdxFileFromDatApp::main(int argc, char **argv)
{
vespalib::string cmd;
- if (_argc == 3) {
- vespalib::string datFile(_argv[1]);
- vespalib::string idxfile(_argv[2]);
+ if (argc == 3) {
+ vespalib::string datFile(argv[1]);
+ vespalib::string idxfile(argv[2]);
createIdxFile(datFile, idxfile);
} else {
fprintf(stderr, "Too few arguments\n");
- usage();
+ usage(argv[0]);
return 1;
}
return 0;
}
-FASTOS_MAIN(CreateIdxFileFromDatApp);
+int main(int argc, char **argv) {
+ vespalib::SignalHandler::PIPE.ignore();
+ CreateIdxFileFromDatApp app;
+ return app.main(argc, argv);
+}
diff --git a/searchlib/src/apps/docstore/documentstoreinspect.cpp b/searchlib/src/apps/docstore/documentstoreinspect.cpp
index 0fc0c26f9c7..34afa0216ed 100644
--- a/searchlib/src/apps/docstore/documentstoreinspect.cpp
+++ b/searchlib/src/apps/docstore/documentstoreinspect.cpp
@@ -3,7 +3,7 @@
#include <vespa/searchlib/docstore/logdatastore.h>
#include <vespa/searchlib/index/dummyfileheadercontext.h>
#include <vespa/searchlib/transactionlog/nosyncproxy.h>
-#include <vespa/fastos/app.h>
+#include <vespa/vespalib/util/signalhandler.h>
#include <vespa/vespalib/objects/nbostream.h>
#include <vespa/vespalib/util/size_literals.h>
#include <vespa/vespalib/util/threadstackexecutor.h>
@@ -11,20 +11,21 @@
using namespace search;
-class DocumentStoreInspectApp : public FastOS_Application
+class DocumentStoreInspectApp
{
- void usage();
+ void usage(const char *self);
int verify(const vespalib::string & directory);
int dumpIdxFile(const vespalib::string & file);
- int Main() override;
+public:
+ int main(int argc, char **argv);
};
void
-DocumentStoreInspectApp::usage()
+DocumentStoreInspectApp::usage(const char *self)
{
- printf("Usage: %s dumpidxfile [--idxfile idxFile]\n", _argv[0]);
+ printf("Usage: %s dumpidxfile [--idxfile idxFile]\n", self);
fflush(stdout);
}
@@ -64,35 +65,35 @@ int DocumentStoreInspectApp::dumpIdxFile(const vespalib::string & file)
}
int
-DocumentStoreInspectApp::Main()
+DocumentStoreInspectApp::main(int argc, char **argv)
{
vespalib::string cmd;
- if (_argc >= 2) {
- cmd = _argv[1];
+ if (argc >= 2) {
+ cmd = argv[1];
if (cmd == "dumpidxfile") {
vespalib::string idxfile;
- if (_argc >= 4) {
- if (vespalib::string(_argv[2]) == vespalib::string("--idxfile")) {
- idxfile = _argv[3];
+ if (argc >= 4) {
+ if (vespalib::string(argv[2]) == vespalib::string("--idxfile")) {
+ idxfile = argv[3];
dumpIdxFile(idxfile);
} else {
- fprintf(stderr, "Unknown option '%s'.\n", _argv[2]);
- usage();
+ fprintf(stderr, "Unknown option '%s'.\n", argv[2]);
+ usage(argv[0]);
return 1;
}
} else {
fprintf(stderr, "Too few arguments\n");
- usage();
+ usage(argv[0]);
return 1;
}
} else {
fprintf(stderr, "Unknown command '%s'.\n", cmd.c_str());
- usage();
+ usage(argv[0]);
return 1;
}
} else {
fprintf(stderr, "Too few arguments\n");
- usage();
+ usage(argv[0]);
return 1;
}
return 0;
@@ -116,4 +117,8 @@ DocumentStoreInspectApp::verify(const vespalib::string & dir)
return retval;
}
-FASTOS_MAIN(DocumentStoreInspectApp);
+int main(int argc, char **argv) {
+ vespalib::SignalHandler::PIPE.ignore();
+ DocumentStoreInspectApp app;
+ return app.main(argc, argv);
+}
diff --git a/searchlib/src/apps/docstore/verifylogdatastore.cpp b/searchlib/src/apps/docstore/verifylogdatastore.cpp
index c868707e545..3b673c172c9 100644
--- a/searchlib/src/apps/docstore/verifylogdatastore.cpp
+++ b/searchlib/src/apps/docstore/verifylogdatastore.cpp
@@ -4,38 +4,39 @@
#include <vespa/searchlib/docstore/logdatastore.h>
#include <vespa/searchlib/index/dummyfileheadercontext.h>
#include <vespa/searchlib/transactionlog/nosyncproxy.h>
-#include <vespa/fastos/app.h>
+#include <vespa/vespalib/util/signalhandler.h>
#include <vespa/vespalib/util/exception.h>
#include <vespa/vespalib/util/size_literals.h>
#include <vespa/vespalib/util/threadstackexecutor.h>
using namespace search;
-class VerifyLogDataStoreApp : public FastOS_Application
+class VerifyLogDataStoreApp
{
- void usage();
+ void usage(const char *self);
int verify(const vespalib::string & directory);
- int Main() override;
+public:
+ int main(int argc, char **argv);
};
void
-VerifyLogDataStoreApp::usage()
+VerifyLogDataStoreApp::usage(const char *self)
{
- printf("Usage: %s <direcory>\n", _argv[0]);
+ printf("Usage: %s <direcory>\n", self);
fflush(stdout);
}
int
-VerifyLogDataStoreApp::Main()
+VerifyLogDataStoreApp::main(int argc, char **argv)
{
- if (_argc >= 2) {
- vespalib::string directory(_argv[1]);
+ if (argc >= 2) {
+ vespalib::string directory(argv[1]);
return verify(directory);
} else {
fprintf(stderr, "Too few arguments\n");
- usage();
+ usage(argv[0]);
return 1;
}
return 0;
@@ -65,4 +66,8 @@ VerifyLogDataStoreApp::verify(const vespalib::string & dir)
return retval;
}
-FASTOS_MAIN(VerifyLogDataStoreApp);
+int main(int argc, char **argv) {
+ vespalib::SignalHandler::PIPE.ignore();
+ VerifyLogDataStoreApp app;
+ return app.main(argc, argv);
+}
diff --git a/searchlib/src/apps/uniform/uniform.cpp b/searchlib/src/apps/uniform/uniform.cpp
index baec62370ed..a72a13464fd 100644
--- a/searchlib/src/apps/uniform/uniform.cpp
+++ b/searchlib/src/apps/uniform/uniform.cpp
@@ -1,6 +1,6 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-#include <vespa/fastos/app.h>
+#include <vespa/vespalib/util/signalhandler.h>
#include <vespa/searchlib/bitcompression/compression.h>
#include <vespa/log/log.h>
@@ -13,7 +13,7 @@ maxExpGolombVal(uint64_t kValue, uint64_t maxBits)
(UINT64_C(1) << kValue));
}
-class UniformApp : public FastOS_Application
+class UniformApp
{
typedef search::bitcompression::EncodeContext64BE EC64;
@@ -27,7 +27,8 @@ class UniformApp : public FastOS_Application
static uint32_t encodeSpace(uint64_t x, uint32_t k) { return EC64::encodeExpGolombSpace(x, k); }
void clearBits();
void reportBits();
- int Main() override;
+public:
+ int main(int argc, char **argv);
};
@@ -55,7 +56,7 @@ UniformApp::reportBits()
int
-UniformApp::Main()
+UniformApp::main(int, char **)
{
int k, l, m, bestmask, oldbestmask;
printf("Hello world\n");
@@ -139,6 +140,10 @@ UniformApp::Main()
return 0;
}
-FASTOS_MAIN(UniformApp);
+int main(int argc, char **argv) {
+ vespalib::SignalHandler::PIPE.ignore();
+ UniformApp app;
+ return app.main(argc, argv);
+}
diff --git a/searchlib/src/apps/vespa-attribute-inspect/vespa-attribute-inspect.cpp b/searchlib/src/apps/vespa-attribute-inspect/vespa-attribute-inspect.cpp
index 5cf7528ff1c..ffcb4ca4019 100644
--- a/searchlib/src/apps/vespa-attribute-inspect/vespa-attribute-inspect.cpp
+++ b/searchlib/src/apps/vespa-attribute-inspect/vespa-attribute-inspect.cpp
@@ -8,14 +8,14 @@
#include <fstream>
#include <vespa/fastlib/io/bufferedfile.h>
-#include <vespa/fastos/app.h>
+#include <vespa/vespalib/util/signalhandler.h>
#include <unistd.h>
namespace search {
typedef AttributeVector::SP AttributePtr;
-class LoadAttribute : public FastOS_Application
+class LoadAttribute
{
private:
void load(const AttributePtr & ptr);
@@ -24,7 +24,7 @@ private:
void usage();
public:
- int Main() override;
+ int main(int argc, char **argv);
};
void
@@ -105,7 +105,7 @@ LoadAttribute::usage()
}
int
-LoadAttribute::Main()
+LoadAttribute::main(int argc, char **argv)
{
bool doPrintContent = false;
bool doApplyUpdate = false;
@@ -115,7 +115,7 @@ LoadAttribute::Main()
int opt;
bool optError = false;
- while ((opt = getopt(_argc, _argv, "pasf:h")) != -1) {
+ while ((opt = getopt(argc, argv, "pasf:h")) != -1) {
switch (opt) {
case 'p':
doPrintContent = true;
@@ -144,12 +144,12 @@ LoadAttribute::Main()
}
}
- if (_argc != (optind + 1) || optError) {
+ if (argc != (optind + 1) || optError) {
usage();
return -1;
}
- vespalib::string fileName(_argv[optind]);
+ vespalib::string fileName(argv[optind]);
vespalib::FileHeader fh;
{
vespalib::string datFileName(fileName + ".dat");
@@ -199,8 +199,8 @@ LoadAttribute::Main()
}
-int main(int argc, char ** argv)
-{
+int main(int argc, char ** argv) {
+ vespalib::SignalHandler::PIPE.ignore();
search::LoadAttribute myApp;
- return myApp.Entry(argc, argv);
+ return myApp.main(argc, argv);
}
diff --git a/searchlib/src/apps/vespa-fileheader-inspect/vespa-fileheader-inspect.cpp b/searchlib/src/apps/vespa-fileheader-inspect/vespa-fileheader-inspect.cpp
index 349064eb2a8..eb5b4cba342 100644
--- a/searchlib/src/apps/vespa-fileheader-inspect/vespa-fileheader-inspect.cpp
+++ b/searchlib/src/apps/vespa-fileheader-inspect/vespa-fileheader-inspect.cpp
@@ -1,6 +1,6 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-#include <vespa/fastos/app.h>
+#include <vespa/vespalib/util/signalhandler.h>
#include <vespa/fastos/file.h>
#include <iomanip>
#include <iostream>
@@ -12,14 +12,14 @@ LOG_SETUP("vespa-fileheader-inspect");
using namespace vespalib;
-class Application : public FastOS_Application {
+class Application {
private:
vespalib::string _fileName;
char _delimiter;
bool _quiet;
- int parseOpts();
- void usage();
+ int parseOpts(int argc, char **argv);
+ void usage(const char *self);
void printQuiet(FileHeader &header);
void printVerbose(FileHeader &header);
vespalib::string escape(const vespalib::string &str, char quote = '\0');
@@ -29,7 +29,7 @@ private:
public:
Application();
~Application();
- int Main() override;
+ int main(int argc, char **argv);
};
Application::Application() :
@@ -42,10 +42,10 @@ Application::~Application() {}
void
-Application::usage()
+Application::usage(const char *self)
{
printf("Tool for inspecting the headers of files used by Vespa.\n");
- printf("Usage: %s [options] filename\n", _argv[0]);
+ printf("Usage: %s [options] filename\n", self);
printf("\n");
printf("The options are:\n");
printf("-d delimiter The delimiter to use to separate values in quiet output.\n");
@@ -56,10 +56,10 @@ Application::usage()
int
-Application::parseOpts()
+Application::parseOpts(int argc, char **argv)
{
int c = '?';
- while ((c = getopt(_argc, _argv, "d:f:qh")) != -1) {
+ while ((c = getopt(argc, argv, "d:f:qh")) != -1) {
switch (c) {
case 'd':
_delimiter = optarg[0];
@@ -71,15 +71,15 @@ Application::parseOpts()
_quiet = true;
break;
case 'h':
- usage();
+ usage(argv[0]);
return EXIT_SUCCESS;
default:
- usage();
+ usage(argv[0]);
return EXIT_FAILURE;
}
}
- if (_argc == optind + 1) {
- _fileName = _argv[optind];
+ if (argc == optind + 1) {
+ _fileName = argv[optind];
}
if (_fileName.empty()) {
std::cerr << "No filename given." << std::endl;
@@ -89,9 +89,9 @@ Application::parseOpts()
}
int
-Application::Main()
+Application::main(int argc, char **argv)
{
- int ret = parseOpts();
+ int ret = parseOpts(argc, argv);
if (ret == EXIT_FAILURE || ret == EXIT_SUCCESS) {
return ret;
}
@@ -218,6 +218,7 @@ Application::getValueString(const FileHeader::Tag &tag)
int
main(int argc, char** argv)
{
+ vespalib::SignalHandler::PIPE.ignore();
Application app;
- return app.Entry(argc, argv);
+ return app.main(argc, argv);
}
diff --git a/searchlib/src/apps/vespa-index-inspect/vespa-index-inspect.cpp b/searchlib/src/apps/vespa-index-inspect/vespa-index-inspect.cpp
index 79d205d7ad6..073a5d2884d 100644
--- a/searchlib/src/apps/vespa-index-inspect/vespa-index-inspect.cpp
+++ b/searchlib/src/apps/vespa-index-inspect/vespa-index-inspect.cpp
@@ -12,7 +12,7 @@
#include <vespa/searchlib/index/dummyfileheadercontext.h>
#include <vespa/searchlib/queryeval/searchiterator.h>
#include <vespa/searchlib/fef/termfieldmatchdata.h>
-#include <vespa/fastos/app.h>
+#include <vespa/vespalib/util/signalhandler.h>
#include <iostream>
#include <getopt.h>
#include <cstdlib>
@@ -167,18 +167,10 @@ FieldOptions::validateFields(const Schema &schema)
class SubApp
{
-protected:
- FastOS_Application &_app;
-
public:
- SubApp(FastOS_Application &app)
- : _app(app)
- {
- }
-
virtual ~SubApp() { }
virtual void usage(bool showHeader) = 0;
- virtual bool getOptions() = 0;
+ virtual bool getOptions(int argc, char **argv) = 0;
virtual int run() = 0;
};
@@ -202,10 +194,10 @@ class ShowPostingListSubApp : public SubApp
static uint64_t noWordNumHigh() { return std::numeric_limits<uint64_t>::max(); }
static uint64_t noWordNum() { return 0u; }
public:
- ShowPostingListSubApp(FastOS_Application &app);
+ ShowPostingListSubApp();
virtual ~ShowPostingListSubApp();
virtual void usage(bool showHeader) override;
- virtual bool getOptions() override;
+ virtual bool getOptions(int argc, char **argv) override;
virtual int run() override;
void showPostingList();
bool readDocIdLimit(const Schema &schema);
@@ -216,9 +208,8 @@ public:
};
-ShowPostingListSubApp::ShowPostingListSubApp(FastOS_Application &app)
- : SubApp(app),
- _indexDir("."),
+ShowPostingListSubApp::ShowPostingListSubApp()
+ : _indexDir("."),
_fieldOptions(),
_word(),
_verbose(false),
@@ -260,7 +251,7 @@ ShowPostingListSubApp::usage(bool showHeader)
bool
-ShowPostingListSubApp::getOptions()
+ShowPostingListSubApp::getOptions(int argc, char **argv)
{
int c;
int longopt_index = 0;
@@ -280,7 +271,7 @@ ShowPostingListSubApp::getOptions()
LONGOPT_MINDOCID
};
optind = 2;
- while ((c = getopt_long(_app._argc, _app._argv, "di:mv",
+ while ((c = getopt_long(argc, argv, "di:mv",
longopts,
&longopt_index)) != -1) {
switch (c) {
@@ -339,10 +330,10 @@ ShowPostingListSubApp::getOptions()
_optIndex = optind;
if (_transpose) {
} else {
- if (_optIndex >= _app._argc) {
+ if (_optIndex >= argc) {
return false;
}
- _word = _app._argv[optind];
+ _word = argv[optind];
}
return true;
}
@@ -673,18 +664,17 @@ class DumpWordsSubApp : public SubApp
bool _showWordNum;
public:
- DumpWordsSubApp(FastOS_Application &app);
+ DumpWordsSubApp();
virtual ~DumpWordsSubApp();
virtual void usage(bool showHeader) override;
- virtual bool getOptions() override;
+ virtual bool getOptions(int argc, char **argv) override;
virtual int run() override;
void dumpWords();
};
-DumpWordsSubApp::DumpWordsSubApp(FastOS_Application &app)
- : SubApp(app),
- _indexDir("."),
+DumpWordsSubApp::DumpWordsSubApp()
+ : _indexDir("."),
_fieldOptions(),
_minNumDocs(0u),
_verbose(false),
@@ -713,7 +703,7 @@ DumpWordsSubApp::usage(bool showHeader)
bool
-DumpWordsSubApp::getOptions()
+DumpWordsSubApp::getOptions(int argc, char **argv)
{
int c;
int longopt_index = 0;
@@ -733,7 +723,7 @@ DumpWordsSubApp::getOptions()
LONGOPT_WORDNUM
};
optind = 2;
- while ((c = getopt_long(_app._argc, _app._argv, "i:",
+ while ((c = getopt_long(argc, argv, "i:",
longopts,
&longopt_index)) != -1) {
switch (c) {
@@ -835,43 +825,36 @@ DumpWordsSubApp::run()
}
-class VespaIndexInspectApp : public FastOS_Application
+class VespaIndexInspectApp
{
public:
- VespaIndexInspectApp();
void usage();
- int Main() override;
+ int main(int argc, char **argv);
};
-VespaIndexInspectApp::VespaIndexInspectApp()
- : FastOS_Application()
-{
-}
-
-
void
VespaIndexInspectApp::usage()
{
- ShowPostingListSubApp(*this).usage(true);
- DumpWordsSubApp(*this).usage(false);
+ ShowPostingListSubApp().usage(true);
+ DumpWordsSubApp().usage(false);
}
int
-VespaIndexInspectApp::Main()
+VespaIndexInspectApp::main(int argc, char **argv)
{
- if (_argc < 2) {
+ if (argc < 2) {
usage();
return 1;
}
std::unique_ptr<SubApp> subApp;
- if (strcmp(_argv[1], "showpostings") == 0)
- subApp.reset(new ShowPostingListSubApp(*this));
- else if (strcmp(_argv[1], "dumpwords") == 0)
- subApp.reset(new DumpWordsSubApp(*this));
- if (subApp.get() != NULL) {
- if (!subApp->getOptions()) {
+ if (strcmp(argv[1], "showpostings") == 0)
+ subApp = std::make_unique<ShowPostingListSubApp>();
+ else if (strcmp(argv[1], "dumpwords") == 0)
+ subApp = std::make_unique<DumpWordsSubApp>();
+ if (subApp.get() != nullptr) {
+ if (!subApp->getOptions(argc, argv)) {
subApp->usage(true);
return 1;
}
@@ -881,4 +864,8 @@ VespaIndexInspectApp::Main()
return 1;
}
-FASTOS_MAIN(VespaIndexInspectApp);
+int main(int argc, char **argv) {
+ vespalib::SignalHandler::PIPE.ignore();
+ VespaIndexInspectApp app;
+ return app.main(argc, argv);
+}
diff --git a/searchlib/src/apps/vespa-ranking-expression-analyzer/vespa-ranking-expression-analyzer.cpp b/searchlib/src/apps/vespa-ranking-expression-analyzer/vespa-ranking-expression-analyzer.cpp
index d4c11d5ac2f..dee7d6f650d 100644
--- a/searchlib/src/apps/vespa-ranking-expression-analyzer/vespa-ranking-expression-analyzer.cpp
+++ b/searchlib/src/apps/vespa-ranking-expression-analyzer/vespa-ranking-expression-analyzer.cpp
@@ -12,7 +12,7 @@
#include <vespa/eval/eval/llvm/deinline_forest.h>
#include <vespa/vespalib/io/mapped_file_input.h>
#include <vespa/eval/eval/param_usage.h>
-#include <vespa/fastos/app.h>
+#include <vespa/vespalib/util/signalhandler.h>
//-----------------------------------------------------------------------------
@@ -328,27 +328,27 @@ State::~State() {}
//-----------------------------------------------------------------------------
-struct MyApp : public FastOS_Application {
- int Main() override;
- int usage();
+struct MyApp {
+ int main(int argc, char **argv);
+ int usage(const char *self);
};
int
-MyApp::usage() {
- fprintf(stderr, "usage: %s [-v] <expression-file>\n", _argv[0]);
+MyApp::usage(const char *self) {
+ fprintf(stderr, "usage: %s [-v] <expression-file>\n", self);
fprintf(stderr, " analyze/benchmark vespa ranking expression\n");
fprintf(stderr, " -v: more verbose output\n");
return 1;
}
int
-MyApp::Main()
+MyApp::main(int argc, char **argv)
{
- bool verbose = (_argc == 3) && (strcmp(_argv[1], "-v") == 0);
- if (!(verbose || (_argc == 2))) {
- return usage();
+ bool verbose = (argc == 3) && (strcmp(argv[1], "-v") == 0);
+ if (!(verbose || (argc == 2))) {
+ return usage(argv[0]);
}
- vespalib::string file_name(verbose ? _argv[2] : _argv[1]);
+ vespalib::string file_name(verbose ? argv[2] : argv[1]);
vespalib::MappedFileInput file(file_name);
if (!file.valid()) {
fprintf(stderr, "could not read input file: '%s'\n",
@@ -369,8 +369,9 @@ MyApp::Main()
}
int main(int argc, char **argv) {
+ vespalib::SignalHandler::PIPE.ignore();
MyApp my_app;
- return my_app.Entry(argc, argv);
+ return my_app.main(argc, argv);
}
//-----------------------------------------------------------------------------
diff --git a/searchlib/src/tests/attribute/benchmark/attributebenchmark.cpp b/searchlib/src/tests/attribute/benchmark/attributebenchmark.cpp
index 4a690a28cc8..abdcd27b09a 100644
--- a/searchlib/src/tests/attribute/benchmark/attributebenchmark.cpp
+++ b/searchlib/src/tests/attribute/benchmark/attributebenchmark.cpp
@@ -5,7 +5,7 @@
#include <vespa/searchlib/attribute/attributeguard.h>
#include <vespa/searchlib/attribute/attributefactory.h>
#include <vespa/fastos/thread.h>
-#include <vespa/fastos/app.h>
+#include <vespa/vespalib/util/signalhandler.h>
#include <iostream>
#include <fstream>
#include "attributesearcher.h"
@@ -29,7 +29,7 @@ namespace search {
using AttributePtr = AttributeVector::SP;
using DocId = AttributeVector::DocId;
-class AttributeBenchmark : public FastOS_Application
+class AttributeBenchmark
{
private:
class Config {
@@ -135,7 +135,7 @@ public:
delete _threadPool;
}
}
- int Main() override;
+ int main(int argc, char **argv);
};
@@ -460,7 +460,7 @@ AttributeBenchmark::usage()
}
int
-AttributeBenchmark::Main()
+AttributeBenchmark::main(int argc, char **argv)
{
Config dc;
dc._numDocs = 50000;
@@ -488,7 +488,7 @@ AttributeBenchmark::Main()
int opt;
bool optError = false;
- while ((opt = getopt(_argc, _argv, "n:u:v:s:q:p:r:c:l:h:i:a:e:S:E:D:L:bRPtw")) != -1) {
+ while ((opt = getopt(argc, argv, "n:u:v:s:q:p:r:c:l:h:i:a:e:S:E:D:L:bRPtw")) != -1) {
switch (opt) {
case 'n':
dc._numDocs = atoi(optarg);
@@ -562,12 +562,12 @@ AttributeBenchmark::Main()
}
}
- if (_argc != (optind + 1) || optError) {
+ if (argc != (optind + 1) || optError) {
usage();
return -1;
}
- dc._attribute = vespalib::string(_argv[optind]);
+ dc._attribute = vespalib::string(argv[optind]);
_threadPool = new FastOS_ThreadPool(256000);
@@ -662,9 +662,9 @@ AttributeBenchmark::Main()
}
}
-int main(int argc, char ** argv)
-{
+int main(int argc, char **argv) {
+ vespalib::SignalHandler::PIPE.ignore();
search::AttributeBenchmark myapp;
- return myapp.Entry(argc, argv);
+ return myapp.main(argc, argv);
}
diff --git a/searchlib/src/tests/bitvector/bitvectorbenchmark.cpp b/searchlib/src/tests/bitvector/bitvectorbenchmark.cpp
index e140814a5ad..26b0ccff656 100644
--- a/searchlib/src/tests/bitvector/bitvectorbenchmark.cpp
+++ b/searchlib/src/tests/bitvector/bitvectorbenchmark.cpp
@@ -1,7 +1,7 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include <vespa/log/log.h>
#include <vespa/searchlib/common/bitvector.h>
-#include <vespa/fastos/app.h>
+#include <vespa/vespalib/util/signalhandler.h>
#include <iostream>
#include <string>
#include <vector>
@@ -12,7 +12,7 @@ LOG_SETUP("bitvectorbenchmark");
namespace search {
-class BitVectorBenchmark : public FastOS_Application
+class BitVectorBenchmark
{
private:
std::vector<BitVector *> _bv;
@@ -27,7 +27,7 @@ private:
public:
BitVectorBenchmark();
~BitVectorBenchmark();
- int Main() override;
+ int main(int argc, char **argv);
};
BitVectorBenchmark::BitVectorBenchmark() :
@@ -164,13 +164,13 @@ void BitVectorBenchmark::testOrSpeed2()
}
}
-int BitVectorBenchmark::Main()
+int BitVectorBenchmark::main(int argc, char **argv)
{
std::string operation;
size_t numBits(8*1000000);
int opt;
bool optError = false;
- while ((opt = getopt(_argc, _argv, "n:t:")) != -1) {
+ while ((opt = getopt(argc, argv, "n:t:")) != -1) {
switch (opt) {
case 'n':
numBits = strtoll(optarg, NULL, 10);
@@ -184,7 +184,7 @@ int BitVectorBenchmark::Main()
}
}
- if ((_argc != optind ) || optError) {
+ if ((argc != optind ) || optError) {
usage();
return -1;
}
@@ -217,9 +217,9 @@ int BitVectorBenchmark::Main()
}
}
-int main(int argc, char ** argv)
-{
+int main(int argc, char ** argv) {
+ vespalib::SignalHandler::PIPE.ignore();
search::BitVectorBenchmark myapp;
- return myapp.Entry(argc, argv);
+ return myapp.main(argc, argv);
}
diff --git a/searchlib/src/tests/diskindex/fieldwriter/fieldwriter_test.cpp b/searchlib/src/tests/diskindex/fieldwriter/fieldwriter_test.cpp
index aa5f9a13e7d..47725d7306d 100644
--- a/searchlib/src/tests/diskindex/fieldwriter/fieldwriter_test.cpp
+++ b/searchlib/src/tests/diskindex/fieldwriter/fieldwriter_test.cpp
@@ -20,7 +20,7 @@
#include <vespa/vespalib/util/time.h>
#include <openssl/evp.h>
#include <vespa/fastos/file.h>
-#include <vespa/fastos/app.h>
+#include <vespa/vespalib/util/signalhandler.h>
#include <unistd.h>
#include <vespa/log/log.h>
LOG_SETUP("fieldwriter_test");
@@ -104,7 +104,7 @@ makeWordString(uint64_t wordNum)
}
-class FieldWriterTest : public FastOS_Application
+class FieldWriterTest
{
private:
bool _verbose;
@@ -122,7 +122,7 @@ private:
public:
FieldWriterTest();
~FieldWriterTest();
- int Main() override;
+ int main(int argc, char **argv);
};
@@ -664,15 +664,15 @@ testFieldWriterVariantsWithHighLids(FakeWordSet &wordSet, uint32_t docIdLimit,
}
int
-FieldWriterTest::Main()
+FieldWriterTest::main(int argc, char **argv)
{
int c;
- if (_argc > 0) {
- DummyFileHeaderContext::setCreator(_argv[0]);
+ if (argc > 0) {
+ DummyFileHeaderContext::setCreator(argv[0]);
}
- while ((c = getopt(_argc, _argv, "c:d:vw:")) != -1) {
+ while ((c = getopt(argc, argv, "c:d:vw:")) != -1) {
switch(c) {
case 'c':
_commonDocFreq = atoi(optarg);
@@ -718,11 +718,11 @@ FieldWriterTest::Main()
} // namespace fieldwriter
int
-main(int argc, char **argv)
-{
+main(int argc, char **argv) {
+ vespalib::SignalHandler::PIPE.ignore();
fieldwriter::FieldWriterTest app;
setvbuf(stdout, nullptr, _IOLBF, 32_Ki);
app._rnd.srand48(32);
- return app.Entry(argc, argv);
+ return app.main(argc, argv);
}
diff --git a/searchlib/src/tests/diskindex/pagedict4/pagedict4test.cpp b/searchlib/src/tests/diskindex/pagedict4/pagedict4test.cpp
index 05fdf4b70f9..f1729f21f39 100644
--- a/searchlib/src/tests/diskindex/pagedict4/pagedict4test.cpp
+++ b/searchlib/src/tests/diskindex/pagedict4/pagedict4test.cpp
@@ -14,7 +14,7 @@
#include <vespa/searchlib/diskindex/pagedict4file.h>
#include <vespa/searchlib/diskindex/pagedict4randread.h>
#include <vespa/searchlib/common/tunefileinfo.h>
-#include <vespa/fastos/app.h>
+#include <vespa/vespalib/util/signalhandler.h>
#include <sstream>
#include <vespa/log/log.h>
@@ -51,7 +51,7 @@ using Writer = search::diskindex::test::PageDict4MemWriter;
using SeqReader = search::diskindex::test::PageDict4MemSeqReader;
using RandReader = search::diskindex::test::PageDict4MemRandReader;
-class PageDict4TestApp : public FastOS_Application
+class PageDict4TestApp
{
public:
vespalib::Rand48 _rnd;
@@ -61,7 +61,7 @@ public:
bool _lastWordForcedCommon;
void usage();
- int Main() override;
+ int main(int argc, char **argv);
void testWords();
PageDict4TestApp()
: _rnd(),
@@ -83,20 +83,20 @@ PageDict4TestApp::usage()
int
-PageDict4TestApp::Main()
+PageDict4TestApp::main(int argc, char **argv)
{
- if (_argc > 0) {
- DummyFileHeaderContext::setCreator(_argv[0]);
+ if (argc > 0) {
+ DummyFileHeaderContext::setCreator(argv[0]);
}
_rnd.srand48(32);
- for (int32_t i = 1; i < _argc; ++i) {
- if (strcmp(_argv[i], "stress") == 0)
+ for (int32_t i = 1; i < argc; ++i) {
+ if (strcmp(argv[i], "stress") == 0)
_stress = true;
- if (strcmp(_argv[i], "emptyword") == 0)
+ if (strcmp(argv[i], "emptyword") == 0)
_emptyWord = true;
- if (strcmp(_argv[i], "firstwordforcedcommon") == 0)
+ if (strcmp(argv[i], "firstwordforcedcommon") == 0)
_firstWordForcedCommon = true;
- if (strcmp(_argv[i], "lastwordforcedcommon") == 0)
+ if (strcmp(argv[i], "lastwordforcedcommon") == 0)
_lastWordForcedCommon = true;
}
testWords();
@@ -690,4 +690,8 @@ PageDict4TestApp::testWords()
#endif
}
-FASTOS_MAIN(PageDict4TestApp);
+int main(int argc, char **argv) {
+ vespalib::SignalHandler::PIPE.ignore();
+ PageDict4TestApp app;
+ return app.main(argc, argv);
+}
diff --git a/searchlib/src/tests/postinglistbm/postinglistbm.cpp b/searchlib/src/tests/postinglistbm/postinglistbm.cpp
index d0552958611..6155ef88ef3 100644
--- a/searchlib/src/tests/postinglistbm/postinglistbm.cpp
+++ b/searchlib/src/tests/postinglistbm/postinglistbm.cpp
@@ -1,7 +1,7 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "stress_runner.h"
-#include <vespa/fastos/app.h>
+#include <vespa/vespalib/util/signalhandler.h>
#include <vespa/searchlib/common/bitvector.h>
#include <vespa/searchlib/common/resultset.h>
#include <vespa/searchlib/index/docidandfeatures.h>
@@ -28,7 +28,7 @@ using namespace search::fakedata;
namespace postinglistbm {
-class PostingListBM : public FastOS_Application {
+class PostingListBM {
private:
uint32_t _numDocs;
uint32_t _commonDocFreq;
@@ -49,7 +49,7 @@ public:
public:
PostingListBM();
~PostingListBM();
- int Main() override;
+ int main(int argc, char **argv);
};
void
@@ -108,14 +108,14 @@ PostingListBM::PostingListBM()
PostingListBM::~PostingListBM() = default;
int
-PostingListBM::Main()
+PostingListBM::main(int argc, char **argv)
{
int c;
bool hasElements = false;
bool hasElementWeights = false;
- while ((c = getopt(_argc, _argv, "C:c:m:r:d:l:s:t:o:uw:T:q")) != -1) {
+ while ((c = getopt(argc, argv, "C:c:m:r:d:l:s:t:o:uw:T:q")) != -1) {
switch(c) {
case 'C':
_skipCommonPairsRate = atoi(optarg);
@@ -226,12 +226,11 @@ PostingListBM::Main()
}
-int
-main(int argc, char **argv)
-{
+int main(int argc, char **argv) {
+ vespalib::SignalHandler::PIPE.ignore();
postinglistbm::PostingListBM app;
setvbuf(stdout, nullptr, _IOLBF, 32_Ki);
app._rnd.srand48(32);
- return app.Entry(argc, argv);
+ return app.main(argc, argv);
}
diff --git a/searchlib/src/tests/transactionlogstress/translogstress.cpp b/searchlib/src/tests/transactionlogstress/translogstress.cpp
index cfd2138f2e8..9988f3e171a 100644
--- a/searchlib/src/tests/transactionlogstress/translogstress.cpp
+++ b/searchlib/src/tests/transactionlogstress/translogstress.cpp
@@ -8,7 +8,7 @@
#include <vespa/searchlib/util/runnable.h>
#include <vespa/searchlib/index/dummyfileheadercontext.h>
#include <vespa/fnet/transport.h>
-#include <vespa/fastos/app.h>
+#include <vespa/vespalib/util/signalhandler.h>
#include <iostream>
#include <sstream>
#include <thread>
@@ -563,7 +563,7 @@ ControllerThread::doRun()
//-----------------------------------------------------------------------------
// TransLogStress
//-----------------------------------------------------------------------------
-class TransLogStress : public FastOS_Application
+class TransLogStress
{
private:
class Config {
@@ -593,7 +593,7 @@ private:
void usage();
public:
- int Main() override;
+ int main(int argc, char **argv);
};
void
@@ -623,7 +623,7 @@ TransLogStress::usage()
}
int
-TransLogStress::Main()
+TransLogStress::main(int argc, char **argv)
{
std::string tlsSpec("tcp/localhost:17897");
std::string domain("translogstress");
@@ -645,7 +645,7 @@ TransLogStress::Main()
int opt;
bool optError = false;
- while ((opt = getopt(_argc, _argv, "d:p:t:f:s:v:c:e:g:i:a:b:h")) != -1) {
+ while ((opt = getopt(argc, argv, "d:p:t:f:s:v:c:e:g:i:a:b:h")) != -1) {
switch (opt) {
case 'd':
_cfg.domainPartSize = atol(optarg);
@@ -692,7 +692,7 @@ TransLogStress::Main()
printConfig();
std::this_thread::sleep_for(sleepTime);
- if (_argc != optind || optError) {
+ if (argc != optind || optError) {
usage();
return -1;
}
@@ -758,8 +758,8 @@ TransLogStress::Main()
}
-int main(int argc, char ** argv)
-{
+int main(int argc, char **argv) {
+ vespalib::SignalHandler::PIPE.ignore();
search::transactionlog::TransLogStress myApp;
- return myApp.Entry(argc, argv);
+ return myApp.main(argc, argv);
}