Data Pipeline Patterns
Batch Transform
A batch transform applies the same cleanup rule to each input value.
Batch Transform
BatchTransform.java
public class BatchTransform {
static int clamp(int value) {
if (value < 0) {
return 0;
}
return value;
}
public static void main(String[] args) {
int bonus = ;
int[] rawScores = {7, -1, 10};
StringBuilder cleaned = new StringBuilder();
for (int i = 0; i < rawScores.length; i++) {
int value = clamp(rawScores[i] + bonus);
if (i > 0) {
cleaned.append(",");
}
cleaned.append(value);
}
System.out.println("scores=" + cleaned);
}
}
public class BatchTransform {
static int clamp(int value) {
if (value < 0) {
return 0;
}
return value;
}
public static void main(String[] args) {
int bonus = ;
int[] rawScores = {7, -1, 10};
StringBuilder cleaned = new StringBuilder();
for (int i = 0; i < rawScores.length; i++) {
int value = clamp(rawScores[i] + bonus);
if (i > 0) {
cleaned.append(",");
}
cleaned.append(value);
}
System.out.println("scores=" + cleaned);
}
}
public class BatchTransform {
static int clamp(int value) {
if (value < 0) {
return 0;
}
return value;
}
public static void main(String[] args) {
int bonus = ;
int[] rawScores = {7, -1, 10};
StringBuilder cleaned = new StringBuilder();
for (int i = 0; i < rawScores.length; i++) {
int value = clamp(rawScores[i] + bonus);
if (i > 0) {
cleaned.append(",");
}
cleaned.append(value);
}
System.out.println("scores=" + cleaned);
}
}
batch transform
The loop applies one transformation to every value in the batch.
scalar output
Joining the cleaned values keeps the replay output compact and readable.