forked from duckdb/duckdb
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ed60e92
commit 44667af
Showing
10 changed files
with
115 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -255,6 +255,8 @@ io_file | |
|
||
# Visual Studio | ||
.vs | ||
settings.json | ||
.vscode | ||
|
||
# QtCreator files | ||
*.user | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#include "common/fstream_util.hpp" | ||
|
||
using namespace std; | ||
using namespace duckdb; | ||
|
||
fstream FstreamUtil::OpenFile(const string &file_path) { | ||
fstream new_file; | ||
new_file.open(file_path, ios::in | ios::out | ios::binary); | ||
if (!new_file.good()) { | ||
throw IOException("Could not open File!"); | ||
} | ||
|
||
return new_file; | ||
} | ||
|
||
size_t FstreamUtil::GetFileSize(fstream &file) { | ||
file.seekg(0, ios::end); | ||
return file.tellg(); | ||
} | ||
|
||
unique_ptr<char[]> FstreamUtil::ReadBinary(fstream &file) { | ||
size_t file_size = GetFileSize(file); | ||
file.seekg(0, ios::beg); | ||
auto result = unique_ptr<char[]>(new char[file_size]); | ||
file.read(result.get(), file_size); | ||
|
||
return result; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
//===----------------------------------------------------------------------===// | ||
// DuckDB | ||
// | ||
// common/fstream_util.hpp | ||
// | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#pragma once | ||
|
||
#include "common/constants.hpp" | ||
#include "common/exception.hpp" | ||
|
||
#include <fstream> | ||
#include <iostream> | ||
|
||
namespace duckdb { | ||
/** | ||
* Fstream Utility Functions | ||
*/ | ||
class FstreamUtil { | ||
public: | ||
/** | ||
* Returns true if the needle string exists in the haystack | ||
*/ | ||
std::fstream OpenFile(const string &file_path); | ||
size_t GetFileSize(std::fstream &file); | ||
unique_ptr<char[]> ReadBinary(std::fstream &file); | ||
}; | ||
} // namespace duckdb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
|
||
|
||
|
||
[duckdb] | ||
duckdb.wal | ||
main.duck [VERSION_NUMBER, schemas] | ||
|
||
|
||
[sys] <- schema name | ||
tables.duck | ||
|
||
|
||
[integers] <- table name | ||
columns.duckdb | ||
|
||
[i] | ||
chunk-1.data | ||
chunk-2.data | ||
|
||
|
||
|
||
|
||
INSERT INTO integers VALUES (22); | ||
|
||
|
||
|
||
[i.tmp] | ||
chunk-1.data | ||
|
||
mv i.tmp i | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters