Skip to content

Commit ab59f94

Browse files
[feat] Implement ParallaxNameBase and ParallaxArrayName helper classes for store integration
1 parent 18c7181 commit ab59f94

File tree

2 files changed

+108
-0
lines changed

2 files changed

+108
-0
lines changed
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
/*
2+
* (C) Copyright 1996- 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 "ParallaxNameBase.h"
12+
#include "eckit/exception/Exceptions.h"
13+
#include "eckit/filesystem/PathName.h"
14+
#include "eckit/io/Buffer.h"
15+
#include "eckit/io/FileHandle.h"
16+
#include "eckit/io/MemoryHandle.h"
17+
#include "eckit/utils/Tokenizer.h"
18+
#include <atomic>
19+
#include <iomanip>
20+
21+
#include "fdb5/parallax/ParallaxArrayPartHandle.h"
22+
23+
namespace fdb5
24+
{
25+
//===----------------------------------------------------------------------===//
26+
// ParallaxNameBase
27+
//===----------------------------------------------------------------------===//
28+
29+
ParallaxNameBase::ParallaxNameBase(const eckit::URI &uri)
30+
: uri_(uri)
31+
{
32+
ASSERT(uri.scheme() == "parallax");
33+
ASSERT(uri.query() == std::string());
34+
ASSERT(uri.fragment() == std::string());
35+
36+
eckit::Tokenizer parse("/");
37+
std::vector<std::string> bits;
38+
parse(uri.name(), bits);
39+
40+
ASSERT(bits.size() > 0);
41+
ASSERT(bits.size() < 4);
42+
43+
key_ = bits[0];
44+
}
45+
46+
std::string ParallaxNameBase::asString() const
47+
{
48+
return key_;
49+
}
50+
51+
//===----------------------------------------------------------------------===//
52+
// ParallaxArrayName
53+
//===----------------------------------------------------------------------===//
54+
55+
ParallaxArrayName::ParallaxArrayName(const eckit::URI &uri)
56+
: ParallaxNameBase(uri)
57+
{
58+
}
59+
60+
eckit::DataHandle *ParallaxArrayName::dataHandle(const eckit::Offset &offset, const eckit::Length &length) const
61+
{
62+
return new fdb5::ParallaxArrayPartHandle(*this, offset, length);
63+
}
64+
65+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
* (C) Copyright 1996- 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+
#pragma once
12+
13+
#include <memory>
14+
#include <string>
15+
16+
#include "eckit/filesystem/URI.h"
17+
#include "eckit/io/DataHandle.h"
18+
#include "eckit/utils/Optional.h"
19+
#include "fdb5/parallax/ParallaxArray.h"
20+
21+
namespace fdb5
22+
{
23+
class ParallaxNameBase {
24+
public:
25+
std::string asString() const;
26+
27+
protected:
28+
ParallaxNameBase(const eckit::URI &);
29+
30+
std::string key_;
31+
const eckit::URI uri_;
32+
};
33+
34+
class ParallaxArray;
35+
36+
class ParallaxArrayName : public ParallaxNameBase {
37+
public:
38+
ParallaxArrayName(const eckit::URI &);
39+
40+
eckit::DataHandle *dataHandle(const eckit::Offset &, const eckit::Length &) const;
41+
};
42+
43+
}

0 commit comments

Comments
 (0)