However they are converted to nanoseconds when being written to the InfluxDB service. This means you're always paying for nanosecond precision when you don't need it.
private StringBuilder formatedTime() { final StringBuilder sb = new StringBuilder(); if (null == this.time) { this.time = this.precision.convert(System.currentTimeMillis(),TimeUnit.MILLISECONDS); } sb.append(" ").append(TimeUnit.NANOSECONDS.convert(this.time, this.precision)); return sb; } Andrew Feller 8400 Metronome Dr Raleigh, NC 27613 andrew.fel...@gmail.com (225) 802-6868 On Wed, Oct 19, 2016 at 9:38 AM, 'Larry Walker' via InfluxData < influxdb@googlegroups.com> wrote: > When you create your Point to be written, you can specify the precision. > > Builder dataEvBldr = Point.measurement(evtGroupMeasurement > .getMeasurementName()) > > .time(time, TimeUnit.MILLISECONDS) > > .tag("groupname", group) > > .addField("F1", f1) > > .addField("F2", f2) > > .addField("F3", f3); > > On Tuesday, October 18, 2016 at 1:38:26 PM UTC-4, andrew...@gmail.com > wrote: >> >> On Tuesday, October 18, 2016 at 1:17:22 PM UTC-4, ma...@influxdb.com >> wrote: >> > The precision as specified in the query string[1] is treated as truth. >> If you provide a timestamp at millisecond resolution, but don't specify the >> precision or specify it as nanoseconds, the timestamp will be interpreted >> as nanoseconds. (The current unix time in milliseconds, interpreted as >> nanoseconds, will be about 24 minutes into Jan 1 1970.) >> > >> > A couple relevant places in the code are setting the precision of a >> point [2] and handling precision and writing points in the HTTP handler [3]. >> > >> > [1] https://docs.influxdata.com/influxdb/v1.0/tools/api/#query- >> string-parameters-1 >> > [2] https://github.com/influxdata/influxdb/blob/cea7690b728a23a7 >> a196020ea411707d2807d176/models/points.go#L1364-L1378 >> > [3] https://github.com/influxdata/influxdb/blob/cea7690b728a23a7 >> a196020ea411707d2807d176/services/httpd/handler.go#L645-L692 >> > >> > On Tuesday, October 18, 2016 at 10:02:15 AM UTC-7, andrew...@gmail.com >> wrote: >> > > I'm looking to fix the influxdb-java client library as it forces all >> point timestamps to nanosecond precision, which is a waste of space and hit >> in performance when only captured in millisecond precision. One of the >> questions however is understanding what InfluxDB does whenever the >> measurement timestamp precision doesn't match what was specified in the >> /write. >> > > >> > > Any clarity and links to code base would be very welcome! >> >> Thanks for the links and clarification; makes sense. >> >> Since one of the best practices I've heard regarding InfluxDB is having >> lower precision as needed. The two issues I was alluding to were: >> >> 1) influxdb-java library org.influxdb.dto.Point.formatedTime() converts >> all timestamps to nanoseconds >> >> Source: https://github.com/influxdata/influxdb-java/blob/master/src/ >> main/java/org/influxdb/dto/Point.java >> >> private StringBuilder formatedTime() { >> final StringBuilder sb = new StringBuilder(); >> if (null == this.time) { >> this.time = this.precision.convert(System. >> currentTimeMillis(),TimeUnit.MILLISECONDS); >> } >> sb.append(" ").append(TimeUnit.NANOSECONDS.convert(this.time, >> this.precision)); >> return sb; >> } >> >> >> 2) influxdb-java library org.influxdb.impl.InfluxDBImpl.write() methods >> forces nanosecond precision >> >> Source: https://github.com/influxdata/influxdb-java/blob/master/src/ >> main/java/org/influxdb/impl/InfluxDBImpl.java >> >> execute(this.influxDBService.writePoints( >> this.username, >> this.password, >> batchPoints.getDatabase(), >> batchPoints.getRetentionPolicy(), >> TimeUtil.toTimePrecision(TimeUnit.NANOSECONDS), >> batchPoints.getConsistency().value(), >> lineProtocol)); >> >> >> Thanks again Sean / Mark! >> >> -- > Remember to include the version number! > --- > You received this message because you are subscribed to a topic in the > Google Groups "InfluxData" group. > To unsubscribe from this topic, visit https://groups.google.com/d/ > topic/influxdb/tF_xhtQxc5o/unsubscribe. > To unsubscribe from this group and all its topics, send an email to > influxdb+unsubscr...@googlegroups.com. > To post to this group, send email to influxdb@googlegroups.com. > Visit this group at https://groups.google.com/group/influxdb. > To view this discussion on the web visit https://groups.google.com/d/ > msgid/influxdb/579430d6-df68-42ff-9780-13f72a421beb%40googlegroups.com > <https://groups.google.com/d/msgid/influxdb/579430d6-df68-42ff-9780-13f72a421beb%40googlegroups.com?utm_medium=email&utm_source=footer> > . > > For more options, visit https://groups.google.com/d/optout. > -- Remember to include the version number! --- You received this message because you are subscribed to the Google Groups "InfluxData" group. To unsubscribe from this group and stop receiving emails from it, send an email to influxdb+unsubscr...@googlegroups.com. To post to this group, send email to influxdb@googlegroups.com. Visit this group at https://groups.google.com/group/influxdb. To view this discussion on the web visit https://groups.google.com/d/msgid/influxdb/CAMcshKbhWgCJck0adaLuZnTGCSAQ_yjUk6rrJmK4dm%2BqEc5Rmg%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.