IODA Bundle
TestSelectDataHandle.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
/// \file UnitTest.h
12
///
13
/// @author Piotr Kuchta, ECMWF, Jan 2010
14
15
#include "eckit/io/FileHandle.h"
16
#include "eckit/log/Timer.h"
17
#include "
odc/Select.h
"
18
19
#include "
TestCase.h
"
20
21
using namespace
std
;
22
using namespace
eckit
;
23
using namespace
odc
;
24
25
/// UnitTest syntax 'select lat, lon' (no file name)
26
///
27
static
void
test
()
28
{
29
string
sql =
"select * where obstype = 7;"
;
30
//string sql = "select * where obstype = 7;";
31
//string sql = "select obstype from \"input.oda\";";
32
33
const
string
fileName =
"2000010106.odb"
;
34
FileHandle fh(fileName);
35
fh.openForRead();
36
odc::Select
oda
(sql, fh);
37
38
Log::info() <<
"test: Execute '"
<< sql <<
"'"
<< std::endl;
39
long
n = 0;
40
{
41
Timer t(
"test: selecting rows using SQL"
);
42
43
odc::Select::iterator
it =
oda
.begin();
44
odc::Select::iterator
end =
oda
.end();
45
46
for
( ; it != end; ++it)
47
++n;
48
}
49
Log::info() <<
"test: selected "
<< n <<
" rows."
<< std::endl;
50
ASSERT(n == 3134386);
51
fh.close();
52
}
53
54
static
void
setUp
()
55
{
56
#if 0
57
string
s =
"Data to be saved"
;
58
59
TemporaryFile
tmp;
60
ofstream os(tmp.c_str());
61
os << s;
62
os.close();
63
if
(!os)
throw
WriteError(tmp);
64
65
string
cmd =
"ls -l "
;
66
cmd += tmp;
67
system(cmd.c_str());
68
69
cmd =
"cat "
;
70
cmd += tmp;
71
system(cmd.c_str());
72
#endif
73
}
74
75
76
static
void
tearDown
(){}
77
78
SIMPLE_TEST
(SelectDataHandle)
oda
void oda
Definition:
ReaderIterator.h:27
Select.h
TestCase.h
SIMPLE_TEST
#define SIMPLE_TEST(name)
Definition:
TestCase.h:66
tearDown
static void tearDown()
Definition:
TestSelectDataHandle.cc:76
test
static void test()
Definition:
TestSelectDataHandle.cc:27
setUp
static void setUp()
Definition:
TestSelectDataHandle.cc:54
TemporaryFile
Definition:
TemporaryFiles.h:25
odc::IteratorProxy< SelectIterator, Select, const double >
odc::Select
Definition:
Select.h:34
eckit
Definition:
DistributionUtils.h:15
odc
Definition:
ColumnInfo.h:23
std
Definition:
encode.cc:30
odc
src
odc
tools
TestSelectDataHandle.cc
Generated on Fri Aug 20 2021 11:49:12 for IODA Bundle by
1.9.1