/usr/include/jellyfish/text_dumper.hpp is in libjellyfish-2.0-dev 2.1.4-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 | /* This file is part of Jellyfish.
Jellyfish is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Jellyfish is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Jellyfish. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __JELLYFISH_TEXT_DUMPER_HPP__
#define __JELLYFISH_TEXT_DUMPER_HPP__
#include <jellyfish/sorted_dumper.hpp>
namespace jellyfish {
template<typename Key, typename Val>
class text_writer {
public:
void write(std::ostream& out, const Key& key, const Val val) {
out << key << " " << val << "\n";
}
};
template<typename storage_t>
class text_dumper : public sorted_dumper<text_dumper<storage_t>, storage_t> {
typedef sorted_dumper<text_dumper<storage_t>, storage_t> super;
text_writer<typename super::key_type, uint64_t> writer;
public:
static const char* format;
text_dumper(int nb_threads, const char* file_prefix, file_header* header = 0) :
super(nb_threads, file_prefix, header)
{ }
virtual void _dump(storage_t* ary) {
if(super::header_) {
super::header_->update_from_ary(*ary);
super::header_->format(format);
}
super::_dump(ary);
}
void write_key_value_pair(std::ostream& out, typename super::heap_item item) {
writer.write(out, item->key_, item->val_);
}
};
template<typename storage_t>
const char* jellyfish::text_dumper<storage_t>::format = "text/sorted";
template<typename Key, typename Val>
class text_reader {
std::istream& is_;
char* buffer_;
Key key_;
Val val_;
const RectangularBinaryMatrix m_;
const size_t size_mask_;
public:
text_reader(std::istream& is,
file_header* header) :
is_(is),
buffer_(new char[header->key_len() / 2 + 1]),
key_(header->key_len() / 2),
m_(header->matrix()),
size_mask_(header->size() - 1)
{ }
const Key& key() const { return key_; }
const Val& val() const { return val_; }
size_t pos() const { return m_.times(key()) & size_mask_; }
bool next() {
is_ >> key_ >> val_;
return is_.good();
}
};
}
#endif /* __JELLYFISH_TEXT_DUMPER_HPP__ */
|