Elffuss BraidHub

kikocis/java-driver public

Use Long.MIN_VALUE to represent unset timestamp.
Changesete24e5cd01927f95befaf5e35322038fa7509e1ecf55b1d55284f3b8e5fda44d2
Authorolim7t <omichallat+github@gmail.com> · 2014-10-07 18:14 +02:00
Committerolim7t <omichallat+github@gmail.com> · 2014-10-08 10:45 +02:00
Parents19ceb74cd6c4

Browse the files at this changeset

6 files changed

modified driver-core/src/main/java/com/datastax/driver/core/Requests.java +3 −3
@@ -206,7 +206,7 @@
206206 -1,
207207 null,
208208 ConsistencyLevel.SERIAL,
209- 0);
209+ Long.MIN_VALUE);
210210
211211 private final EnumSet<QueryFlag> flags = EnumSet.noneOf(QueryFlag.class);
212212 public final ConsistencyLevel consistency;
@@ -244,7 +244,7 @@
244244 flags.add(QueryFlag.PAGING_STATE);
245245 if (serialConsistency != ConsistencyLevel.SERIAL)
246246 flags.add(QueryFlag.SERIAL_CONSISTENCY);
247- if (defaultTimestamp != 0L)
247+ if (defaultTimestamp != Long.MIN_VALUE)
248248 flags.add(QueryFlag.DEFAULT_TIMESTAMP);
249249 }
250250
@@ -394,7 +394,7 @@
394394
395395 if (serialConsistency != ConsistencyLevel.SERIAL)
396396 flags.add(QueryFlag.SERIAL_CONSISTENCY);
397- if (defaultTimestamp != 0L)
397+ if (defaultTimestamp != Long.MIN_VALUE)
398398 flags.add(QueryFlag.DEFAULT_TIMESTAMP);
399399 }
400400
modified driver-core/src/main/java/com/datastax/driver/core/ServerSideTimestampGenerator.java +3 −3
@@ -16,8 +16,8 @@
1616 package com.datastax.driver.core;
1717
1818 /**
19- * A timestamp generator that always returns 0, in order to let Cassandra assign
20- * server-side timestamps.
19+ * A timestamp generator that always returns {@link Long#MIN_VALUE}, in order to let Cassandra
20+ * assign server-side timestamps.
2121 */
2222 public class ServerSideTimestampGenerator implements TimestampGenerator {
2323 /**
@@ -27,7 +27,7 @@
2727
2828 @Override
2929 public long next() {
30- return 0;
30+ return Long.MIN_VALUE;
3131 }
3232
3333 private ServerSideTimestampGenerator() {
modified driver-core/src/main/java/com/datastax/driver/core/SessionManager.java +2 −2
@@ -378,10 +378,10 @@
378378 } else if (serialConsistency == null)
379379 serialConsistency = configuration().getQueryOptions().getSerialConsistencyLevel();
380380
381- long defaultTimestamp = 0;
381+ long defaultTimestamp = Long.MIN_VALUE;
382382 if (cluster.manager.protocolVersion().compareTo(ProtocolVersion.V3) >= 0) {
383383 defaultTimestamp = statement.getDefaultTimestamp();
384- if (defaultTimestamp <= 0)
384+ if (defaultTimestamp == Long.MIN_VALUE)
385385 defaultTimestamp = cluster.getConfiguration().getPolicies().getTimestampGenerator().next();
386386 }
387387
modified driver-core/src/main/java/com/datastax/driver/core/Statement.java +4 −3
@@ -42,7 +42,7 @@
4242 private volatile ConsistencyLevel serialConsistency;
4343 private volatile boolean traceQuery;
4444 private volatile int fetchSize;
45- private volatile long defaultTimestamp;
45+ private volatile long defaultTimestamp = Long.MIN_VALUE;
4646
4747 private volatile RetryPolicy retryPolicy;
4848
@@ -266,9 +266,10 @@
266266 * <ul>
267267 * <li>the timestamp specified directly in the CQL query string (using the
268268 * {@code USING TIMESTAMP} syntax);</li>
269- * <li>the timestamp specified through this method, if strictly positive;</li>
269+ * <li>the timestamp specified through this method, if different from
270+ * {@link Long#MIN_VALUE};</li>
270271 * <li>the timestamp returned by the {@link TimestampGenerator} currently in use,
271- * if strictly positive.</li>
272+ * if different from {@link Long#MIN_VALUE}.</li>
272273 * </ul>
273274 * If none of these apply, no timestamp will be sent with the query and Cassandra
274275 * will generate a server-side one (similar to the pre-V3 behavior).
modified driver-core/src/main/java/com/datastax/driver/core/TimestampGenerator.java +2 −2
@@ -25,8 +25,8 @@
2525 /**
2626 * Returns the next timestamp.
2727 *
28- * @return the next timestamp (in microseconds). If this is 0, it won't be sent by the driver,
29- * letting Cassandra generate a server-side timestamp.
28+ * @return the next timestamp (in microseconds). If it equals {@link Long#MIN_VALUE}, it won't be
29+ * sent by the driver, letting Cassandra generate a server-side timestamp.
3030 */
3131 long next();
3232 }
modified driver-core/src/test/java/com/datastax/driver/core/QueryTimestampTest.java +2 −2
@@ -77,7 +77,7 @@
7777
7878 @Test(groups = "short")
7979 public void should_use_server_side_timestamp_if_none_specified() {
80- timestampFromGenerator = 0;
80+ timestampFromGenerator = Long.MIN_VALUE;
8181 long clientTime = System.currentTimeMillis() * 1000;
8282 String query = "INSERT INTO foo (k, v) VALUES (1, 1)";
8383 session.execute(query);
@@ -116,7 +116,7 @@
116116
117117 @Test(groups = "short")
118118 public void should_apply_server_side_timestamp_only_to_batched_queries_without_timestamp() {
119- timestampFromGenerator = 0;
119+ timestampFromGenerator = Long.MIN_VALUE;
120120 long clientTime = System.currentTimeMillis() * 1000;
121121 BatchStatement batch = new BatchStatement();
122122 batch.add(new SimpleStatement("INSERT INTO foo (k, v) VALUES (1, 1)"));