author | František Kučera <franta-hg@frantovo.cz> |
Sat, 18 Jan 2020 20:09:34 +0100 | |
branch | v_0 |
changeset 45 | f466b4c7d9b1 |
parent 35 | 926eb93c302f |
child 46 | b5ae61996281 |
permissions | -rw-r--r-- |
0 | 1 |
/** |
2 |
* Relational pipes |
|
4 | 3 |
* Copyright © 2019 František Kučera (Frantovo.cz, GlobalCode.info) |
0 | 4 |
* |
5 |
* This program is free software: you can redistribute it and/or modify |
|
6 |
* it under the terms of the GNU General Public License as published by |
|
24
4353cd19a6b5
fix license version: GNU GPLv3
František Kučera <franta-hg@frantovo.cz>
parents:
13
diff
changeset
|
7 |
* the Free Software Foundation, version 3 of the License. |
0 | 8 |
* |
9 |
* This program is distributed in the hope that it will be useful, |
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 |
* GNU General Public License for more details. |
|
13 |
* |
|
14 |
* You should have received a copy of the GNU General Public License |
|
15 |
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
16 |
*/ |
|
17 |
#pragma once |
|
18 |
||
19 |
#include <vector> |
|
2
f07ed604a0ab
read filenames separated by a null-byte; fetch their size, owner, group… and some xattr (extended attribute); a preview version
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
20 |
#include <filesystem> |
29
6f15f18d2abf
field group --exec, replaces --script and --hash, starts reusable sub-program that returns set of attributes for all records during its runtime
František Kučera <franta-hg@frantovo.cz>
parents:
28
diff
changeset
|
21 |
#include <regex> |
6f15f18d2abf
field group --exec, replaces --script and --hash, starts reusable sub-program that returns set of attributes for all records during its runtime
František Kučera <franta-hg@frantovo.cz>
parents:
28
diff
changeset
|
22 |
#include <memory> |
2
f07ed604a0ab
read filenames separated by a null-byte; fetch their size, owner, group… and some xattr (extended attribute); a preview version
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
23 |
|
4 | 24 |
#include <relpipe/writer/typedefs.h> |
25 |
#include <relpipe/writer/AttributeMetadata.h> |
|
26 |
#include <relpipe/writer/RelationalWriter.h> |
|
2
f07ed604a0ab
read filenames separated by a null-byte; fetch their size, owner, group… and some xattr (extended attribute); a preview version
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
27 |
|
4 | 28 |
#include "RequestedField.h" |
29
6f15f18d2abf
field group --exec, replaces --script and --hash, starts reusable sub-program that returns set of attributes for all records during its runtime
František Kučera <franta-hg@frantovo.cz>
parents:
28
diff
changeset
|
29 |
#include "SubProcess.h" |
27
532953173cd5
file hash: md5, sha1, sha256, sha512
František Kučera <franta-hg@frantovo.cz>
parents:
24
diff
changeset
|
30 |
#include "AttributeFinder.h" |
31
c64e1588f428
rename --exec to --streamlet
František Kučera <franta-hg@frantovo.cz>
parents:
29
diff
changeset
|
31 |
#include "StreamletMsg.h" |
0 | 32 |
|
33 |
namespace relpipe { |
|
34 |
namespace in { |
|
35 |
namespace filesystem { |
|
36 |
||
2
f07ed604a0ab
read filenames separated by a null-byte; fetch their size, owner, group… and some xattr (extended attribute); a preview version
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
37 |
namespace fs = std::filesystem; |
f07ed604a0ab
read filenames separated by a null-byte; fetch their size, owner, group… and some xattr (extended attribute); a preview version
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
38 |
using namespace relpipe::writer; |
f07ed604a0ab
read filenames separated by a null-byte; fetch their size, owner, group… and some xattr (extended attribute); a preview version
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
39 |
|
31
c64e1588f428
rename --exec to --streamlet
František Kučera <franta-hg@frantovo.cz>
parents:
29
diff
changeset
|
40 |
class StreamletAttributeFinder : public AttributeFinder { |
4 | 41 |
private: |
2
f07ed604a0ab
read filenames separated by a null-byte; fetch their size, owner, group… and some xattr (extended attribute); a preview version
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
42 |
std::wstring_convert<codecvt_utf8<wchar_t>> convertor; // TODO: support also other encodings. |
29
6f15f18d2abf
field group --exec, replaces --script and --hash, starts reusable sub-program that returns set of attributes for all records during its runtime
František Kučera <franta-hg@frantovo.cz>
parents:
28
diff
changeset
|
43 |
std::map<int, std::shared_ptr<SubProcess>> subProcesses; |
6f15f18d2abf
field group --exec, replaces --script and --hash, starts reusable sub-program that returns set of attributes for all records during its runtime
František Kučera <franta-hg@frantovo.cz>
parents:
28
diff
changeset
|
44 |
std::map<int, std::vector<AttributeMetadata>> cachedMetadata; |
28
9172bd97ae99
custom scripts for additional attributes
František Kučera <franta-hg@frantovo.cz>
parents:
27
diff
changeset
|
45 |
|
45
f466b4c7d9b1
streamlets: use $RELPIPE_IN_FILESYSTEM_STREAMLET_PATH variable instead of __relpipe_in_filesystem_script_ prefix
František Kučera <franta-hg@frantovo.cz>
parents:
35
diff
changeset
|
46 |
string_t getStreamletPath() { |
f466b4c7d9b1
streamlets: use $RELPIPE_IN_FILESYSTEM_STREAMLET_PATH variable instead of __relpipe_in_filesystem_script_ prefix
František Kučera <franta-hg@frantovo.cz>
parents:
35
diff
changeset
|
47 |
const char* originalPath = getenv("PATH"); |
f466b4c7d9b1
streamlets: use $RELPIPE_IN_FILESYSTEM_STREAMLET_PATH variable instead of __relpipe_in_filesystem_script_ prefix
František Kučera <franta-hg@frantovo.cz>
parents:
35
diff
changeset
|
48 |
const char* streamletPath = getenv("RELPIPE_IN_FILESYSTEM_STREAMLET_PATH"); |
f466b4c7d9b1
streamlets: use $RELPIPE_IN_FILESYSTEM_STREAMLET_PATH variable instead of __relpipe_in_filesystem_script_ prefix
František Kučera <franta-hg@frantovo.cz>
parents:
35
diff
changeset
|
49 |
|
f466b4c7d9b1
streamlets: use $RELPIPE_IN_FILESYSTEM_STREAMLET_PATH variable instead of __relpipe_in_filesystem_script_ prefix
František Kučera <franta-hg@frantovo.cz>
parents:
35
diff
changeset
|
50 |
if (originalPath && streamletPath) return convertor.from_bytes(std::string(streamletPath) + ":" + originalPath); |
f466b4c7d9b1
streamlets: use $RELPIPE_IN_FILESYSTEM_STREAMLET_PATH variable instead of __relpipe_in_filesystem_script_ prefix
František Kučera <franta-hg@frantovo.cz>
parents:
35
diff
changeset
|
51 |
else if (originalPath) return convertor.from_bytes(std::string(originalPath)); |
f466b4c7d9b1
streamlets: use $RELPIPE_IN_FILESYSTEM_STREAMLET_PATH variable instead of __relpipe_in_filesystem_script_ prefix
František Kučera <franta-hg@frantovo.cz>
parents:
35
diff
changeset
|
52 |
else if (streamletPath) return convertor.from_bytes(std::string(streamletPath)); |
f466b4c7d9b1
streamlets: use $RELPIPE_IN_FILESYSTEM_STREAMLET_PATH variable instead of __relpipe_in_filesystem_script_ prefix
František Kučera <franta-hg@frantovo.cz>
parents:
35
diff
changeset
|
53 |
else return L""; |
28
9172bd97ae99
custom scripts for additional attributes
František Kučera <franta-hg@frantovo.cz>
parents:
27
diff
changeset
|
54 |
} |
9
b4f29fb16159
process also links to non-existent files and non-readable links
František Kučera <franta-hg@frantovo.cz>
parents:
8
diff
changeset
|
55 |
protected: |
b4f29fb16159
process also links to non-existent files and non-readable links
František Kučera <franta-hg@frantovo.cz>
parents:
8
diff
changeset
|
56 |
|
35
926eb93c302f
streamlets: enable parallel processing
František Kučera <franta-hg@frantovo.cz>
parents:
32
diff
changeset
|
57 |
void startFile(const fs::path& file, const string& fileRaw, bool exists) override { |
926eb93c302f
streamlets: enable parallel processing
František Kučera <franta-hg@frantovo.cz>
parents:
32
diff
changeset
|
58 |
AttributeFinder::startFile(file, fileRaw, exists); |
926eb93c302f
streamlets: enable parallel processing
František Kučera <franta-hg@frantovo.cz>
parents:
32
diff
changeset
|
59 |
if (exists) { |
926eb93c302f
streamlets: enable parallel processing
František Kučera <franta-hg@frantovo.cz>
parents:
32
diff
changeset
|
60 |
for (auto subProcess : subProcesses) { |
926eb93c302f
streamlets: enable parallel processing
František Kučera <franta-hg@frantovo.cz>
parents:
32
diff
changeset
|
61 |
subProcess.second->write({StreamletMsg::INPUT_ATTRIBUTE, L"0", convertor.from_bytes(currentFileRaw), L"false"}); // index, value, isNull |
926eb93c302f
streamlets: enable parallel processing
František Kučera <franta-hg@frantovo.cz>
parents:
32
diff
changeset
|
62 |
subProcess.second->write({StreamletMsg::WAITING_FOR_OUTPUT_ATTRIBUTES}); |
926eb93c302f
streamlets: enable parallel processing
František Kučera <franta-hg@frantovo.cz>
parents:
32
diff
changeset
|
63 |
} |
926eb93c302f
streamlets: enable parallel processing
František Kučera <franta-hg@frantovo.cz>
parents:
32
diff
changeset
|
64 |
} |
926eb93c302f
streamlets: enable parallel processing
František Kučera <franta-hg@frantovo.cz>
parents:
32
diff
changeset
|
65 |
} |
926eb93c302f
streamlets: enable parallel processing
František Kučera <franta-hg@frantovo.cz>
parents:
32
diff
changeset
|
66 |
|
926eb93c302f
streamlets: enable parallel processing
František Kučera <franta-hg@frantovo.cz>
parents:
32
diff
changeset
|
67 |
virtual void writeFieldOfExistingFile(RelationalWriter* writer, const string_t& relationName, const RequestedField & field) override { |
29
6f15f18d2abf
field group --exec, replaces --script and --hash, starts reusable sub-program that returns set of attributes for all records during its runtime
František Kučera <franta-hg@frantovo.cz>
parents:
28
diff
changeset
|
68 |
// TODO: paralelize also over records → fork multiple processes and distribute records across them; then collect results (with a lock) |
31
c64e1588f428
rename --exec to --streamlet
František Kučera <franta-hg@frantovo.cz>
parents:
29
diff
changeset
|
69 |
if (field.group == RequestedField::GROUP_STREAMLET) { |
29
6f15f18d2abf
field group --exec, replaces --script and --hash, starts reusable sub-program that returns set of attributes for all records during its runtime
František Kučera <franta-hg@frantovo.cz>
parents:
28
diff
changeset
|
70 |
for (auto metadata : cachedMetadata[field.id]) { |
6f15f18d2abf
field group --exec, replaces --script and --hash, starts reusable sub-program that returns set of attributes for all records during its runtime
František Kučera <franta-hg@frantovo.cz>
parents:
28
diff
changeset
|
71 |
SubProcess::Message m = subProcesses[field.id]->read(); |
31
c64e1588f428
rename --exec to --streamlet
František Kučera <franta-hg@frantovo.cz>
parents:
29
diff
changeset
|
72 |
if (m.code == StreamletMsg::OUTPUT_ATTRIBUTE) writer->writeAttribute(m.parameters[0]); |
29
6f15f18d2abf
field group --exec, replaces --script and --hash, starts reusable sub-program that returns set of attributes for all records during its runtime
František Kučera <franta-hg@frantovo.cz>
parents:
28
diff
changeset
|
73 |
else throw RelpipeWriterException(L"Protocol violation from exec sub-process while reading: „" + metadata.attributeName + L"“. Expected OUTPUT_ATTRIBUTE but got: " + m.toString()); |
27
532953173cd5
file hash: md5, sha1, sha256, sha512
František Kučera <franta-hg@frantovo.cz>
parents:
24
diff
changeset
|
74 |
} |
29
6f15f18d2abf
field group --exec, replaces --script and --hash, starts reusable sub-program that returns set of attributes for all records during its runtime
František Kučera <franta-hg@frantovo.cz>
parents:
28
diff
changeset
|
75 |
|
6f15f18d2abf
field group --exec, replaces --script and --hash, starts reusable sub-program that returns set of attributes for all records during its runtime
František Kučera <franta-hg@frantovo.cz>
parents:
28
diff
changeset
|
76 |
SubProcess::Message m = subProcesses[field.id]->read(); |
31
c64e1588f428
rename --exec to --streamlet
František Kučera <franta-hg@frantovo.cz>
parents:
29
diff
changeset
|
77 |
if (m.code != StreamletMsg::WAITING_FOR_INPUT_ATTRIBUTES) throw RelpipeWriterException(L"Protocol violation from exec sub-process. Expected WAITING_FOR_INPUT_ATTRIBUTES but got: " + m.toString()); |
29
6f15f18d2abf
field group --exec, replaces --script and --hash, starts reusable sub-program that returns set of attributes for all records during its runtime
František Kučera <franta-hg@frantovo.cz>
parents:
28
diff
changeset
|
78 |
// TODO: generic protocol violation error messages / method for checking responses |
9
b4f29fb16159
process also links to non-existent files and non-readable links
František Kučera <franta-hg@frantovo.cz>
parents:
8
diff
changeset
|
79 |
} |
b4f29fb16159
process also links to non-existent files and non-readable links
František Kučera <franta-hg@frantovo.cz>
parents:
8
diff
changeset
|
80 |
} |
b4f29fb16159
process also links to non-existent files and non-readable links
František Kučera <franta-hg@frantovo.cz>
parents:
8
diff
changeset
|
81 |
|
0 | 82 |
public: |
83 |
||
29
6f15f18d2abf
field group --exec, replaces --script and --hash, starts reusable sub-program that returns set of attributes for all records during its runtime
František Kučera <franta-hg@frantovo.cz>
parents:
28
diff
changeset
|
84 |
static const string_t SCRIPT_PREFIX; |
6f15f18d2abf
field group --exec, replaces --script and --hash, starts reusable sub-program that returns set of attributes for all records during its runtime
František Kučera <franta-hg@frantovo.cz>
parents:
28
diff
changeset
|
85 |
|
32
bccda5688d71
propagate the relation name to the finders and streamlets
František Kučera <franta-hg@frantovo.cz>
parents:
31
diff
changeset
|
86 |
virtual vector<AttributeMetadata> toMetadata(RelationalWriter* writer, const string_t& relationName, const RequestedField& field) override { |
31
c64e1588f428
rename --exec to --streamlet
František Kučera <franta-hg@frantovo.cz>
parents:
29
diff
changeset
|
87 |
if (field.group == RequestedField::GROUP_STREAMLET) { |
29
6f15f18d2abf
field group --exec, replaces --script and --hash, starts reusable sub-program that returns set of attributes for all records during its runtime
František Kučera <franta-hg@frantovo.cz>
parents:
28
diff
changeset
|
88 |
|
6f15f18d2abf
field group --exec, replaces --script and --hash, starts reusable sub-program that returns set of attributes for all records during its runtime
František Kučera <franta-hg@frantovo.cz>
parents:
28
diff
changeset
|
89 |
if (cachedMetadata.count(field.id)) { |
6f15f18d2abf
field group --exec, replaces --script and --hash, starts reusable sub-program that returns set of attributes for all records during its runtime
František Kučera <franta-hg@frantovo.cz>
parents:
28
diff
changeset
|
90 |
return cachedMetadata[field.id]; |
6f15f18d2abf
field group --exec, replaces --script and --hash, starts reusable sub-program that returns set of attributes for all records during its runtime
František Kučera <franta-hg@frantovo.cz>
parents:
28
diff
changeset
|
91 |
} else { |
6f15f18d2abf
field group --exec, replaces --script and --hash, starts reusable sub-program that returns set of attributes for all records during its runtime
František Kučera <franta-hg@frantovo.cz>
parents:
28
diff
changeset
|
92 |
|
45
f466b4c7d9b1
streamlets: use $RELPIPE_IN_FILESYSTEM_STREAMLET_PATH variable instead of __relpipe_in_filesystem_script_ prefix
František Kučera <franta-hg@frantovo.cz>
parents:
35
diff
changeset
|
93 |
std::vector<string_t> commandLine = {field.name}; |
29
6f15f18d2abf
field group --exec, replaces --script and --hash, starts reusable sub-program that returns set of attributes for all records during its runtime
František Kučera <franta-hg@frantovo.cz>
parents:
28
diff
changeset
|
94 |
std::map<string_t, string_t> environment; |
6f15f18d2abf
field group --exec, replaces --script and --hash, starts reusable sub-program that returns set of attributes for all records during its runtime
František Kučera <franta-hg@frantovo.cz>
parents:
28
diff
changeset
|
95 |
|
31
c64e1588f428
rename --exec to --streamlet
František Kučera <franta-hg@frantovo.cz>
parents:
29
diff
changeset
|
96 |
for (auto mn : StreamletMsg::getMessageNames()) { |
29
6f15f18d2abf
field group --exec, replaces --script and --hash, starts reusable sub-program that returns set of attributes for all records during its runtime
František Kučera <franta-hg@frantovo.cz>
parents:
28
diff
changeset
|
97 |
environment[L"EXEC_MSG_" + mn.second] = std::to_wstring(mn.first); |
6f15f18d2abf
field group --exec, replaces --script and --hash, starts reusable sub-program that returns set of attributes for all records during its runtime
František Kučera <franta-hg@frantovo.cz>
parents:
28
diff
changeset
|
98 |
environment[L"EXEC_MSG_" + std::to_wstring(mn.first)] = mn.second; |
6f15f18d2abf
field group --exec, replaces --script and --hash, starts reusable sub-program that returns set of attributes for all records during its runtime
František Kučera <franta-hg@frantovo.cz>
parents:
28
diff
changeset
|
99 |
} |
6f15f18d2abf
field group --exec, replaces --script and --hash, starts reusable sub-program that returns set of attributes for all records during its runtime
František Kučera <franta-hg@frantovo.cz>
parents:
28
diff
changeset
|
100 |
|
45
f466b4c7d9b1
streamlets: use $RELPIPE_IN_FILESYSTEM_STREAMLET_PATH variable instead of __relpipe_in_filesystem_script_ prefix
František Kučera <franta-hg@frantovo.cz>
parents:
35
diff
changeset
|
101 |
environment[L"PATH"] = getStreamletPath(); |
f466b4c7d9b1
streamlets: use $RELPIPE_IN_FILESYSTEM_STREAMLET_PATH variable instead of __relpipe_in_filesystem_script_ prefix
František Kučera <franta-hg@frantovo.cz>
parents:
35
diff
changeset
|
102 |
|
31
c64e1588f428
rename --exec to --streamlet
František Kučera <franta-hg@frantovo.cz>
parents:
29
diff
changeset
|
103 |
shared_ptr<SubProcess> subProcess(SubProcess::create(commandLine, environment)); |
29
6f15f18d2abf
field group --exec, replaces --script and --hash, starts reusable sub-program that returns set of attributes for all records during its runtime
František Kučera <franta-hg@frantovo.cz>
parents:
28
diff
changeset
|
104 |
subProcesses[field.id] = subProcess; |
27
532953173cd5
file hash: md5, sha1, sha256, sha512
František Kučera <franta-hg@frantovo.cz>
parents:
24
diff
changeset
|
105 |
|
29
6f15f18d2abf
field group --exec, replaces --script and --hash, starts reusable sub-program that returns set of attributes for all records during its runtime
František Kučera <franta-hg@frantovo.cz>
parents:
28
diff
changeset
|
106 |
string_t version = L"1"; |
31
c64e1588f428
rename --exec to --streamlet
František Kučera <franta-hg@frantovo.cz>
parents:
29
diff
changeset
|
107 |
subProcess->write({StreamletMsg::VERSION_SUPPORTED, version}); |
c64e1588f428
rename --exec to --streamlet
František Kučera <franta-hg@frantovo.cz>
parents:
29
diff
changeset
|
108 |
subProcess->write({StreamletMsg::WAITING_FOR_VERSION}); |
29
6f15f18d2abf
field group --exec, replaces --script and --hash, starts reusable sub-program that returns set of attributes for all records during its runtime
František Kučera <franta-hg@frantovo.cz>
parents:
28
diff
changeset
|
109 |
SubProcess::Message versionMessage = subProcess->read(); |
31
c64e1588f428
rename --exec to --streamlet
František Kučera <franta-hg@frantovo.cz>
parents:
29
diff
changeset
|
110 |
if (versionMessage.code == StreamletMsg::VERSION_ACCEPTED && versionMessage.parameters[0] == version) { |
32
bccda5688d71
propagate the relation name to the finders and streamlets
František Kučera <franta-hg@frantovo.cz>
parents:
31
diff
changeset
|
111 |
subProcess->write({StreamletMsg::RELATION_START, relationName}); |
31
c64e1588f428
rename --exec to --streamlet
František Kučera <franta-hg@frantovo.cz>
parents:
29
diff
changeset
|
112 |
subProcess->write({StreamletMsg::INPUT_ATTRIBUTE_METADATA, L"path", L"string"}); |
c64e1588f428
rename --exec to --streamlet
František Kučera <franta-hg@frantovo.cz>
parents:
29
diff
changeset
|
113 |
for (string_t alias : field.getAliases()) subProcess->write({StreamletMsg::OUTPUT_ATTRIBUTE_ALIAS, alias}); |
c64e1588f428
rename --exec to --streamlet
František Kučera <franta-hg@frantovo.cz>
parents:
29
diff
changeset
|
114 |
for (int i = 0; i < field.options.size();) subProcess->write({StreamletMsg::OPTION, field.options[i++], field.options[i++]}); |
c64e1588f428
rename --exec to --streamlet
František Kučera <franta-hg@frantovo.cz>
parents:
29
diff
changeset
|
115 |
subProcess->write({StreamletMsg::WAITING_FOR_OUTPUT_ATTRIBUTES_METADATA}); |
29
6f15f18d2abf
field group --exec, replaces --script and --hash, starts reusable sub-program that returns set of attributes for all records during its runtime
František Kučera <franta-hg@frantovo.cz>
parents:
28
diff
changeset
|
116 |
|
6f15f18d2abf
field group --exec, replaces --script and --hash, starts reusable sub-program that returns set of attributes for all records during its runtime
František Kučera <franta-hg@frantovo.cz>
parents:
28
diff
changeset
|
117 |
vector<AttributeMetadata> metadata; |
6f15f18d2abf
field group --exec, replaces --script and --hash, starts reusable sub-program that returns set of attributes for all records during its runtime
František Kučera <franta-hg@frantovo.cz>
parents:
28
diff
changeset
|
118 |
while (true) { |
6f15f18d2abf
field group --exec, replaces --script and --hash, starts reusable sub-program that returns set of attributes for all records during its runtime
František Kučera <franta-hg@frantovo.cz>
parents:
28
diff
changeset
|
119 |
SubProcess::Message m = subProcess->read(); |
31
c64e1588f428
rename --exec to --streamlet
František Kučera <franta-hg@frantovo.cz>
parents:
29
diff
changeset
|
120 |
if (m.code == StreamletMsg::OUTPUT_ATTRIBUTE_METADATA) metadata.push_back({m.parameters[0], writer->toTypeId(m.parameters[1])}); |
c64e1588f428
rename --exec to --streamlet
František Kučera <franta-hg@frantovo.cz>
parents:
29
diff
changeset
|
121 |
else if (m.code == StreamletMsg::WAITING_FOR_INPUT_ATTRIBUTES) break; |
29
6f15f18d2abf
field group --exec, replaces --script and --hash, starts reusable sub-program that returns set of attributes for all records during its runtime
František Kučera <franta-hg@frantovo.cz>
parents:
28
diff
changeset
|
122 |
} |
6f15f18d2abf
field group --exec, replaces --script and --hash, starts reusable sub-program that returns set of attributes for all records during its runtime
František Kučera <franta-hg@frantovo.cz>
parents:
28
diff
changeset
|
123 |
|
6f15f18d2abf
field group --exec, replaces --script and --hash, starts reusable sub-program that returns set of attributes for all records during its runtime
František Kučera <franta-hg@frantovo.cz>
parents:
28
diff
changeset
|
124 |
cachedMetadata[field.id] = metadata; |
6f15f18d2abf
field group --exec, replaces --script and --hash, starts reusable sub-program that returns set of attributes for all records during its runtime
František Kučera <franta-hg@frantovo.cz>
parents:
28
diff
changeset
|
125 |
return metadata; |
6f15f18d2abf
field group --exec, replaces --script and --hash, starts reusable sub-program that returns set of attributes for all records during its runtime
František Kučera <franta-hg@frantovo.cz>
parents:
28
diff
changeset
|
126 |
} else { |
6f15f18d2abf
field group --exec, replaces --script and --hash, starts reusable sub-program that returns set of attributes for all records during its runtime
František Kučera <franta-hg@frantovo.cz>
parents:
28
diff
changeset
|
127 |
throw RelpipeWriterException(L"Incompatible exec sub-process version or message: " + versionMessage.toString()); |
6f15f18d2abf
field group --exec, replaces --script and --hash, starts reusable sub-program that returns set of attributes for all records during its runtime
František Kučera <franta-hg@frantovo.cz>
parents:
28
diff
changeset
|
128 |
} |
6f15f18d2abf
field group --exec, replaces --script and --hash, starts reusable sub-program that returns set of attributes for all records during its runtime
František Kučera <franta-hg@frantovo.cz>
parents:
28
diff
changeset
|
129 |
} |
5
ec661baf433a
support field aliases
František Kučera <franta-hg@frantovo.cz>
parents:
4
diff
changeset
|
130 |
} else { |
ec661baf433a
support field aliases
František Kučera <franta-hg@frantovo.cz>
parents:
4
diff
changeset
|
131 |
return {}; |
ec661baf433a
support field aliases
František Kučera <franta-hg@frantovo.cz>
parents:
4
diff
changeset
|
132 |
} |
4 | 133 |
} |
2
f07ed604a0ab
read filenames separated by a null-byte; fetch their size, owner, group… and some xattr (extended attribute); a preview version
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
134 |
|
31
c64e1588f428
rename --exec to --streamlet
František Kučera <franta-hg@frantovo.cz>
parents:
29
diff
changeset
|
135 |
virtual ~StreamletAttributeFinder() override { |
29
6f15f18d2abf
field group --exec, replaces --script and --hash, starts reusable sub-program that returns set of attributes for all records during its runtime
František Kučera <franta-hg@frantovo.cz>
parents:
28
diff
changeset
|
136 |
for (auto s : subProcesses) { |
6f15f18d2abf
field group --exec, replaces --script and --hash, starts reusable sub-program that returns set of attributes for all records during its runtime
František Kučera <franta-hg@frantovo.cz>
parents:
28
diff
changeset
|
137 |
try { |
31
c64e1588f428
rename --exec to --streamlet
František Kučera <franta-hg@frantovo.cz>
parents:
29
diff
changeset
|
138 |
s.second->write({StreamletMsg::RELATION_END}); |
29
6f15f18d2abf
field group --exec, replaces --script and --hash, starts reusable sub-program that returns set of attributes for all records during its runtime
František Kučera <franta-hg@frantovo.cz>
parents:
28
diff
changeset
|
139 |
s.second->wait(); |
6f15f18d2abf
field group --exec, replaces --script and --hash, starts reusable sub-program that returns set of attributes for all records during its runtime
František Kučera <franta-hg@frantovo.cz>
parents:
28
diff
changeset
|
140 |
} catch (...) { |
6f15f18d2abf
field group --exec, replaces --script and --hash, starts reusable sub-program that returns set of attributes for all records during its runtime
František Kučera <franta-hg@frantovo.cz>
parents:
28
diff
changeset
|
141 |
std::wcerr << L"Exception caught during closing sub-process #" + std::to_wstring(s.first) + L" and waiting for its end." << std::endl; |
6f15f18d2abf
field group --exec, replaces --script and --hash, starts reusable sub-program that returns set of attributes for all records during its runtime
František Kučera <franta-hg@frantovo.cz>
parents:
28
diff
changeset
|
142 |
} |
6f15f18d2abf
field group --exec, replaces --script and --hash, starts reusable sub-program that returns set of attributes for all records during its runtime
František Kučera <franta-hg@frantovo.cz>
parents:
28
diff
changeset
|
143 |
} |
0 | 144 |
} |
145 |
}; |
|
146 |
||
31
c64e1588f428
rename --exec to --streamlet
František Kučera <franta-hg@frantovo.cz>
parents:
29
diff
changeset
|
147 |
const relpipe::writer::string_t StreamletAttributeFinder::SCRIPT_PREFIX = L"__relpipe_in_filesystem_script_"; |
27
532953173cd5
file hash: md5, sha1, sha256, sha512
František Kučera <franta-hg@frantovo.cz>
parents:
24
diff
changeset
|
148 |
|
0 | 149 |
} |
150 |
} |
|
27
532953173cd5
file hash: md5, sha1, sha256, sha512
František Kučera <franta-hg@frantovo.cz>
parents:
24
diff
changeset
|
151 |
} |