This repository has been archived by the owner on Dec 27, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
DummyOperation.java
64 lines (51 loc) · 2.13 KB
/
DummyOperation.java
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
/**
* Copyright (C) 2020 Locomizer team and Contributors
* This project uses New BSD license with do no evil clause. For full text, check the LICENSE file in the root directory.
*/
package ash.nazg.commons.operations;
import ash.nazg.config.InvalidConfigValueException;
import ash.nazg.config.tdl.StreamType;
import ash.nazg.config.tdl.metadata.OperationMeta;
import ash.nazg.config.tdl.metadata.PositionalStreamsMetaBuilder;
import ash.nazg.spark.Operation;
import org.apache.spark.api.java.JavaRDDLike;
import java.util.HashMap;
import java.util.Map;
@SuppressWarnings("unused")
public class DummyOperation extends Operation {
private String[] inputNames;
private String[] outputNames;
@Override
public OperationMeta meta() {
return new OperationMeta("nop", "This operation does nothing, just passes all its inputs as all outputs",
new PositionalStreamsMetaBuilder()
.ds("Any number of inputs to be renamed",
new StreamType[]{StreamType.Plain, StreamType.KeyValue, StreamType.CSV}
)
.build(),
null,
new PositionalStreamsMetaBuilder()
.ds("Newly named inputs (must be same count as inputs)",
new StreamType[]{StreamType.Passthru}
)
.build()
);
}
@Override
public void configure() throws InvalidConfigValueException {
inputNames = opResolver.positionalInputs();
outputNames = opResolver.positionalOutputs();
if (inputNames.length != outputNames.length) {
throw new InvalidConfigValueException("Operation '" + name + "' must have equal number of inputs and outputs");
}
}
@SuppressWarnings("rawtypes")
@Override
public Map<String, JavaRDDLike> getResult(Map<String, JavaRDDLike> input) {
Map<String, JavaRDDLike> outs = new HashMap<>();
for (int i = 0; i < inputNames.length; i++) {
outs.put(outputNames[i], input.get(inputNames[i]));
}
return outs;
}
}