Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Let InfluxDB handle the timestamp if none provided. #350

Merged
merged 3 commits into from
Jul 5, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
#### Fixes

- InfluxDBResultMapper now is able to process QueryResult created when a GROUP BY clause was used [PR #345](https://github.com/influxdata/influxdb-java/pull/345)
- InfluxDB will now handle the timestamp on its own if none is provided [PR#350](https://github.com/influxdata/influxdb-java/pull/350)


## v2.7 [2017-06-26]

Expand Down
20 changes: 12 additions & 8 deletions src/main/java/org/influxdb/dto/Point.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public static final class Builder {
private final String measurement;
private final Map<String, String> tags = new TreeMap<>();
private Long time;
private TimeUnit precision = TimeUnit.NANOSECONDS;
private TimeUnit precision;
private final Map<String, Object> fields = new TreeMap<>();

/**
Expand Down Expand Up @@ -207,9 +207,6 @@ public Point build() {
if (this.time != null) {
point.setTime(this.time);
point.setPrecision(this.precision);
} else {
point.setTime(System.currentTimeMillis());
point.setPrecision(TimeUnit.MILLISECONDS);
}
point.setTags(this.tags);
return point;
Expand Down Expand Up @@ -292,12 +289,16 @@ public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("Point [name=");
builder.append(this.measurement);
builder.append(", time=");
builder.append(this.time);
if (this.time != null) {
builder.append(", time=");
builder.append(this.time);
}
builder.append(", tags=");
builder.append(this.tags);
builder.append(", precision=");
builder.append(this.precision);
if (this.precision != null) {
builder.append(", precision=");
builder.append(this.precision);
}
builder.append(", fields=");
builder.append(this.fields);
builder.append("]");
Expand Down Expand Up @@ -368,6 +369,9 @@ private void concatenatedFields(final StringBuilder sb) {
}

private void formatedTime(final StringBuilder sb) {
if (this.time == null || this.precision == null) {
return;
}
sb.append(' ').append(TimeUnit.NANOSECONDS.convert(this.time, this.precision));
}

Expand Down