IODA Bundle
IndexTool.cc
Go to the documentation of this file.
1 /*
2  * (C) Copyright 1996-2012 ECMWF.
3  *
4  * This software is licensed under the terms of the Apache Licence Version 2.0
5  * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
6  * In applying this licence, ECMWF does not waive the privileges and immunities
7  * granted to it by virtue of its status as an intergovernmental organisation nor
8  * does it submit to any jurisdiction.
9  */
10 
11 #include "eckit/eckit.h"
12 #include "odc/core/MetaData.h"
13 #include "odc/Reader.h"
14 #include "odc/Select.h"
15 #include "odc/Indexer.h"
16 #include "odc/tools/IndexTool.h"
17 #include "odc/tools/CountTool.h"
18 #include "eckit/io/PartFileHandle.h"
19 #include "eckit/io/Offset.h"
20 #include "eckit/io/Length.h"
21 
22 using namespace eckit;
23 
24 namespace odc {
25 namespace tool {
26 
27 IndexTool::IndexTool (int argc, char *argv[]) : Tool(argc, argv) { }
28 
29 void IndexTool::help(std::ostream &o) {
30  o << "Creates index of reports for a given file";
31 }
32 
33 
34 void IndexTool::usage(const std::string& name, std::ostream &o) {
35  o << name
36  << " <file.odb> [<file.odb.idx>] " << std::endl
37  << std::endl
38  << "\tSpecifically the index file is an ODB file with (INTEGER) columns: block_begin, block_length, seqno, n_rows"
39  << std::endl
40  << "\tOne entry is made for each unique seqno - block pair within the source ODB file." << std::endl;
41 }
42 
43 
45 {
46  if (! (parameters().size() == 2 || parameters().size() == 3))
47  {
48  Log::error() << "Usage: ";
50  Log::error() << std::endl;
51  return;
52  }
53 
54  PathName dataFile (parameters(1));
55  PathName indexFile (parameters().size() == 3
56  ? parameters(2)
57  : parameters(1) + ".idx");
58 
59  Indexer::createIndex(dataFile, indexFile);
60 }
61 
62 } // namespace tool
63 } // namespace odc
64 
static void createIndex(const eckit::PathName &, const eckit::PathName &)
const std::vector< std::string > parameters()
static void usage(const std::string &name, std::ostream &o)
Definition: IndexTool.cc:34
static void help(std::ostream &o)
Definition: IndexTool.cc:29
std::string name()
Definition: Tool.h:34
Definition: ColumnInfo.h:23