Skip to content

Commit b1a92a2

Browse files
authored
Merge pull request #116 from retronym/topic/javaVersionField-fixup
Retain timestamp of migrated data points!
2 parents 7981813 + 23d47ff commit b1a92a2

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

infrastructure/src/main/java/scala/bench/DataMigrator.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import org.influxdb.dto.QueryResult;
88

99
import java.io.IOException;
10+
import java.time.Instant;
1011
import java.util.*;
1112
import java.util.concurrent.TimeUnit;
1213

@@ -40,10 +41,13 @@ public static void main(String[] args) {
4041
List<String> newFieldNames = new ArrayList<>(series.getColumns());
4142
int javaVersionIndex = newFieldNames.indexOf(JAVA_VERSION_TAG_NAME);
4243
newFieldNames.remove(javaVersionIndex);
44+
assert (newFieldNames.get(0).equals("time"));
45+
newFieldNames.remove(0);
4346
Point.Builder builder = Point.measurement(newMeasure);
4447
Map<String, String> newTags = new HashMap<>(series.getTags());
4548
List<Object> newValues = new ArrayList<>(series.getValues().get(0));
4649
Object removed = newValues.remove(javaVersionIndex);
50+
String time = (String) newValues.remove(0);
4751
newTags.put(JAVA_VERSION_TAG_NAME, (String) removed);
4852
newTags.entrySet().removeIf(x -> x.getValue() == null || x.getValue().equals(""));
4953
builder.tag(newTags);
@@ -53,6 +57,8 @@ public static void main(String[] args) {
5357
newFieldsMap.put(newFieldNames.get(i), newValues.get(i));
5458
}
5559
builder.fields(newFieldsMap);
60+
Instant parse = Instant.parse(time);
61+
builder.time(parse.toEpochMilli(), TimeUnit.MILLISECONDS);
5662
Point point = builder.build();
5763
batchPoints.point(point);
5864
}

0 commit comments

Comments
 (0)