Skip to content
This repository was archived by the owner on Apr 19, 2020. It is now read-only.

Commit 1217c0d

Browse files
authored
Merge pull request #5 from p-ranav/improvements
Improvements based on Reddit feedback
2 parents c37ada0 + 1e5c00c commit 1217c0d

13 files changed

Lines changed: 1783 additions & 2437 deletions

README.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
* Header-only library
66
* Fast, asynchronous, multi-threaded processing using:
77
- [Lock-free Concurrent Queues](https://github.com/cameron314/concurrentqueue)
8-
- [Robin hood Hashing](https://github.com/Tessil/robin-map)
9-
* Requires C++11
8+
- [Robin hood Hashing](https://github.com/martinus/robin-hood-hashing)
9+
* Requires C++17
1010
* MIT License
1111

1212
## Table of Contents
@@ -29,7 +29,7 @@
2929
Simply include reader.hpp and you're good to go.
3030

3131
```cpp
32-
#include <reader.hpp>
32+
#include <csv/reader.hpp>
3333
```
3434
To start parsing CSV files, create a ```csv::Reader``` object and call ```.read(filename)```.
3535

@@ -43,8 +43,8 @@ This ```.read``` method is non-blocking. The reader spawns multiple threads to t
4343
```cpp
4444
while(foo.busy()) {
4545
if (foo.has_row()) {
46-
auto row = foo.next_row(); // Each row is a robin_map (https://github.com/Tessil/robin-map)
47-
auto foo = row["foo"] // You can use it just like an std::unordered_map
46+
auto row = foo.next_row(); // Each row is a csv::unordered_flat_map (github.com/martinus/robin-hood-hashing)
47+
auto foo = row["foo"] // You can use it just like an std::unordered_map
4848
auto bar = row["bar"];
4949
// do something
5050
}
@@ -256,7 +256,7 @@ Note: Do not provide num_rows greater than the actual number of rows in the file
256256
void parse(const std::string& filename) {
257257
csv::Reader foo;
258258
foo.read(filename);
259-
std::vector<csv::robin_map<std::string, std::string>> rows;
259+
std::vector<csv::unordered_flat_map<std::string_view, std::string>> rows;
260260
while (foo.busy()) {
261261
if (foo.ready()) {
262262
auto row = foo.next_row();
@@ -267,7 +267,7 @@ void parse(const std::string& filename) {
267267
```
268268
269269
```bash
270-
$ g++ -pthread -std=c++11 -O3 -Iinclude/ -o test benchmark.cpp
270+
$ g++ -pthread -std=c++17 -O3 -Iinclude/ -o test benchmark.cpp
271271
$ time ./test
272272
```
273273

@@ -289,7 +289,7 @@ Here are the average-case execution times:
289289
Simply include writer.hpp and you're good to go.
290290

291291
```cpp
292-
#include <writer.hpp>
292+
#include <csv/writer.hpp>
293293
```
294294
To start writing CSV files, create a ```csv::Writer``` object and provide a filename:
295295

@@ -308,13 +308,13 @@ foo.configure_dialect()
308308
Now it's time to write rows. You can do this in multiple ways:
309309

310310
```cpp
311-
foo.write_row("1", "2", "3"); // parameter packing
312-
foo.write_row({"4", "5", "6"}); // std::vector
313-
foo.write_row(std::map<std::string, std::string>{ // std::map
311+
foo.write_row("1", "2", "3"); // parameter packing
312+
foo.write_row({"4", "5", "6"}); // std::vector
313+
foo.write_row(std::map<std::string, std::string>{ // std::map
314314
{"a", "7"}, {"b", "8"}, {"c", "9"} });
315-
foo.write_row(std::unordered_map<std::string, std::string>{ // std::unordered_map
315+
foo.write_row(std::unordered_map<std::string, std::string>{ // std::unordered_map
316316
{"a", "7"}, {"b", "8"}, {"c", "9"} });
317-
foo.write_row(csv::robin_map<std::string, std::string>{ // robin_map
317+
foo.write_row(csv::unordered_flat_map<std::string, std::string>{ // csv::unordered_flat_map
318318
{"a", "7"}, {"b", "8"}, {"c", "9"} });
319319
```
320320
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2017 Tessil
3+
Copyright (c) 2018-2019 Martin Ankerl
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,10 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
3030
SOFTWARE.
3131
*/
3232
#pragma once
33+
#include <csv/robin_hood.hpp>
3334
#include <string>
3435
#include <vector>
35-
#include <robin_map.hpp>
36+
#include <string_view>
3637

3738
namespace csv {
3839

@@ -43,7 +44,7 @@ namespace csv {
4344
char line_terminator_;
4445
char quote_character_;
4546
bool double_quote_;
46-
robin_map<std::string, bool> ignore_columns_;
47+
unordered_flat_map<std::string_view, bool> ignore_columns_;
4748
std::vector<char> trim_characters_;
4849
std::vector<std::string> column_names_;
4950
bool header_;

0 commit comments

Comments
 (0)