You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kudu.apache.org by mp...@apache.org on 2016/09/09 21:25:57 UTC
[1/2] kudu git commit: KUDU-1594. Rename TIMESTAMP to UNIXTIME_MICROS
Repository: kudu
Updated Branches:
refs/heads/master be719edc3 -> c386f73a9
KUDU-1594. Rename TIMESTAMP to UNIXTIME_MICROS
As described in the JIRA, this is to reduce confusion between Kudu's
timestamp (which is just an int64 since the unix UTC epoch) vs the
TIMESTAMP type in other systems.
Change-Id: Ia2c76ade3c82bc7c413aebdb2a09a26a70b47c62
Reviewed-on: http://gerrit.cloudera.org:8080/4343
Reviewed-by: David Ribeiro Alves <dr...@apache.org>
Tested-by: Kudu Jenkins
Project: http://git-wip-us.apache.org/repos/asf/kudu/repo
Commit: http://git-wip-us.apache.org/repos/asf/kudu/commit/7eaeb6d9
Tree: http://git-wip-us.apache.org/repos/asf/kudu/tree/7eaeb6d9
Diff: http://git-wip-us.apache.org/repos/asf/kudu/diff/7eaeb6d9
Branch: refs/heads/master
Commit: 7eaeb6d902a59428780a91a460ded537afe3c4d4
Parents: be719ed
Author: Todd Lipcon <to...@apache.org>
Authored: Fri Sep 9 01:35:39 2016 -0700
Committer: Todd Lipcon <to...@apache.org>
Committed: Fri Sep 9 20:34:37 2016 +0000
----------------------------------------------------------------------
.../scan-optimization-partition-pruning.md | 2 +-
docs/release_notes.adoc | 11 ++++++++
docs/schema_design.adoc | 14 +++++-----
.../src/main/java/org/apache/kudu/Type.java | 7 ++---
.../kudu/client/ColumnRangePredicate.java | 6 ++--
.../java/org/apache/kudu/client/KeyEncoder.java | 2 +-
.../org/apache/kudu/client/KuduPredicate.java | 14 +++++-----
.../java/org/apache/kudu/client/PartialRow.java | 12 ++++----
.../org/apache/kudu/client/ProtobufHelper.java | 4 +--
.../java/org/apache/kudu/client/RowResult.java | 6 ++--
.../org/apache/kudu/client/BaseKuduTest.java | 2 +-
.../org/apache/kudu/client/TestKuduClient.java | 6 ++--
.../org/apache/kudu/client/TestKuduTable.java | 2 +-
.../org/apache/kudu/client/TestOperation.java | 6 ++--
.../apache/kudu/client/TestPartitionPruner.java | 4 +--
.../org/apache/kudu/client/TestRowResult.java | 2 +-
.../flume/sink/AvroKuduOperationsProducer.java | 2 +-
.../apache/kudu/spark/kudu/DefaultSource.scala | 2 +-
.../apache/kudu/spark/kudu/KuduContext.scala | 2 +-
.../org/apache/kudu/spark/kudu/KuduRDD.scala | 2 +-
.../kudu/spark/kudu/KuduContextTest.scala | 4 +--
.../apache/kudu/spark/kudu/TestContext.scala | 4 +--
python/kudu/__init__.py | 2 +-
python/kudu/libkudu_client.pxd | 14 +++++-----
python/kudu/schema.pyx | 8 +++---
src/kudu/client/predicate-test.cc | 4 +--
src/kudu/client/scan_batch.cc | 12 ++++----
src/kudu/client/scan_batch.h | 4 +--
src/kudu/client/schema.cc | 4 +--
src/kudu/client/schema.h | 3 +-
src/kudu/common/common.proto | 2 +-
src/kudu/common/key_util.cc | 2 +-
src/kudu/common/partial_row.cc | 29 ++++++++++----------
src/kudu/common/partial_row.h | 9 +++---
src/kudu/common/partition.cc | 4 +--
src/kudu/common/partition_pruner-test.cc | 6 ++--
src/kudu/common/row.h | 2 +-
src/kudu/common/row_operations-test.cc | 4 +--
src/kudu/common/types-test.cc | 2 +-
src/kudu/common/types.cc | 2 +-
src/kudu/common/types.h | 6 ++--
src/kudu/integration-tests/all_types-itest.cc | 8 +++---
src/kudu/server/webui_util.cc | 4 +--
43 files changed, 130 insertions(+), 117 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/kudu/blob/7eaeb6d9/docs/design-docs/scan-optimization-partition-pruning.md
----------------------------------------------------------------------
diff --git a/docs/design-docs/scan-optimization-partition-pruning.md b/docs/design-docs/scan-optimization-partition-pruning.md
index 75f0e3b..5311728 100644
--- a/docs/design-docs/scan-optimization-partition-pruning.md
+++ b/docs/design-docs/scan-optimization-partition-pruning.md
@@ -50,7 +50,7 @@ The following sections will reference two example table schemas:
```sql
CREATE TABLE 'machine_metrics'
-(STRING host, STRING metric, TIMESTAMP time, DOUBLE value)
+(STRING host, STRING metric, UNIXTIME_MICROS time, DOUBLE value)
PRIMARY KEY (host, metric, time)
DISTRIBUTE BY
HASH (host, metric) INTO 2 BUCKETS
http://git-wip-us.apache.org/repos/asf/kudu/blob/7eaeb6d9/docs/release_notes.adoc
----------------------------------------------------------------------
diff --git a/docs/release_notes.adoc b/docs/release_notes.adoc
index fc947b4..9a431fc 100644
--- a/docs/release_notes.adoc
+++ b/docs/release_notes.adoc
@@ -78,6 +78,17 @@ Kudu 1.0.0 are not supported.
The existing KuduEventProducers have been updated for the new interface, and have
been renamed similarly.
+- The `TIMESTAMP` column type has been renamed to `UNIXTIME_MICROS` in order to
+ reduce confusion between Kudu's timestamp support and the timestamps supported
+ by other systems such as Apache Hive and Apache Impala (incubating). Existing
+ tables will automatically be updated to use the new name for the type.
++
+Clients upgrading to the new client libraries must move to the new name for
+ the type. Clients using old client libraries will continue to operate using
+ the old type name, even when connected to clusters that have been
+ upgraded. Similarly, if clients are upgraded before servers, existing
+ timestamp columns will be available using the new type name.
+
[[rn_1.0.0_new_features]]
=== New features
http://git-wip-us.apache.org/repos/asf/kudu/blob/7eaeb6d9/docs/schema_design.adoc
----------------------------------------------------------------------
diff --git a/docs/schema_design.adoc b/docs/schema_design.adoc
index 54134d9..3b000ba 100644
--- a/docs/schema_design.adoc
+++ b/docs/schema_design.adoc
@@ -176,7 +176,7 @@ Consider the following table schema.
CREATE TABLE metrics (
host STRING NOT NULL,
metric STRING,
- time TIMESTAMP NOT NULL,
+ time UNIXTIME_MICROS NOT NULL,
measurement DOUBLE,
PRIMARY KEY (time, metric, host),
)
@@ -233,7 +233,7 @@ Supported column types include:
* 16-bit signed integer
* 32-bit signed integer
* 64-bit signed integer
-* timestamp
+* unixtime_micros (64-bit microseconds since the Unix epoch)
* single-precision (32-bit) IEEE-754 floating-point number
* double-precision (64-bit) IEEE-754 floating-point number
* UTF-8 encoded string
@@ -255,11 +255,11 @@ of the column. Columns use plain encoding by default.
.Encoding Types
[options="header"]
|===
-| Column Type | Encoding
-| integer, timestamp | plain, bitshuffle, run length (except for 64-bit)
-| float, double | plain, bitshuffle
-| bool | plain, run length
-| string, binary | plain, prefix, dictionary
+| Column Type | Encoding
+| integer, unix_microtime | plain, bitshuffle, run length (except for 64-bit)
+| float, double | plain, bitshuffle
+| bool | plain, run length
+| string, binary | plain, prefix, dictionary
|===
[[plain]]
http://git-wip-us.apache.org/repos/asf/kudu/blob/7eaeb6d9/java/kudu-client/src/main/java/org/apache/kudu/Type.java
----------------------------------------------------------------------
diff --git a/java/kudu-client/src/main/java/org/apache/kudu/Type.java b/java/kudu-client/src/main/java/org/apache/kudu/Type.java
index fed9dbb..400555d 100644
--- a/java/kudu-client/src/main/java/org/apache/kudu/Type.java
+++ b/java/kudu-client/src/main/java/org/apache/kudu/Type.java
@@ -40,8 +40,7 @@ public enum Type {
BOOL (DataType.BOOL, "bool"),
FLOAT (DataType.FLOAT, "float"),
DOUBLE (DataType.DOUBLE, "double"),
- TIMESTAMP (DataType.TIMESTAMP, "timestamp");
-
+ UNIXTIME_MICROS (DataType.UNIXTIME_MICROS, "unixtime_micros");
private final DataType dataType;
private final String name;
@@ -103,7 +102,7 @@ public enum Type {
case FLOAT: return Ints.BYTES;
case INT64:
case DOUBLE:
- case TIMESTAMP: return Longs.BYTES;
+ case UNIXTIME_MICROS: return Longs.BYTES;
default: throw new IllegalArgumentException("The provided data type doesn't map" +
" to know any known one.");
}
@@ -123,7 +122,7 @@ public enum Type {
case INT16: return INT16;
case INT32: return INT32;
case INT64: return INT64;
- case TIMESTAMP: return TIMESTAMP;
+ case UNIXTIME_MICROS: return UNIXTIME_MICROS;
case FLOAT: return FLOAT;
case DOUBLE: return DOUBLE;
default:
http://git-wip-us.apache.org/repos/asf/kudu/blob/7eaeb6d9/java/kudu-client/src/main/java/org/apache/kudu/client/ColumnRangePredicate.java
----------------------------------------------------------------------
diff --git a/java/kudu-client/src/main/java/org/apache/kudu/client/ColumnRangePredicate.java b/java/kudu-client/src/main/java/org/apache/kudu/client/ColumnRangePredicate.java
index e643c81..f67204e 100644
--- a/java/kudu-client/src/main/java/org/apache/kudu/client/ColumnRangePredicate.java
+++ b/java/kudu-client/src/main/java/org/apache/kudu/client/ColumnRangePredicate.java
@@ -78,7 +78,7 @@ public class ColumnRangePredicate {
case INT16: return KuduPredicate.newComparisonPredicate(column, op, Bytes.getShort(bound));
case INT32: return KuduPredicate.newComparisonPredicate(column, op, Bytes.getInt(bound));
case INT64:
- case TIMESTAMP: return KuduPredicate.newComparisonPredicate(column, op, Bytes.getLong(bound));
+ case UNIXTIME_MICROS: return KuduPredicate.newComparisonPredicate(column, op, Bytes.getLong(bound));
case FLOAT: return KuduPredicate.newComparisonPredicate(column, op, Bytes.getFloat(bound));
case DOUBLE: return KuduPredicate.newComparisonPredicate(column, op, Bytes.getDouble(bound));
case STRING: return KuduPredicate.newComparisonPredicate(column, op, Bytes.getString(bound));
@@ -152,7 +152,7 @@ public class ColumnRangePredicate {
* @param lowerBound value for the lower bound
*/
public void setLowerBound(long lowerBound) {
- checkColumn(Type.INT64, Type.TIMESTAMP);
+ checkColumn(Type.INT64, Type.UNIXTIME_MICROS);
setLowerBoundInternal(Bytes.fromLong(lowerBound));
}
@@ -237,7 +237,7 @@ public class ColumnRangePredicate {
* @param upperBound value for the upper bound
*/
public void setUpperBound(long upperBound) {
- checkColumn(Type.INT64, Type.TIMESTAMP);
+ checkColumn(Type.INT64, Type.UNIXTIME_MICROS);
setUpperBoundInternal(Bytes.fromLong(upperBound));
}
http://git-wip-us.apache.org/repos/asf/kudu/blob/7eaeb6d9/java/kudu-client/src/main/java/org/apache/kudu/client/KeyEncoder.java
----------------------------------------------------------------------
diff --git a/java/kudu-client/src/main/java/org/apache/kudu/client/KeyEncoder.java b/java/kudu-client/src/main/java/org/apache/kudu/client/KeyEncoder.java
index 6f358a6..10e4355 100644
--- a/java/kudu-client/src/main/java/org/apache/kudu/client/KeyEncoder.java
+++ b/java/kudu-client/src/main/java/org/apache/kudu/client/KeyEncoder.java
@@ -289,7 +289,7 @@ class KeyEncoder {
case INT16: row.addShort(idx, (short) (buf.getShort() ^ Short.MIN_VALUE)); break;
case INT32: row.addInt(idx, buf.getInt() ^ Integer.MIN_VALUE); break;
case INT64:
- case TIMESTAMP: row.addLong(idx, buf.getLong() ^ Long.MIN_VALUE); break;
+ case UNIXTIME_MICROS: row.addLong(idx, buf.getLong() ^ Long.MIN_VALUE); break;
case BINARY: {
byte[] binary = decodeBinaryColumn(buf, isLast);
row.addBinary(idx, binary);
http://git-wip-us.apache.org/repos/asf/kudu/blob/7eaeb6d9/java/kudu-client/src/main/java/org/apache/kudu/client/KuduPredicate.java
----------------------------------------------------------------------
diff --git a/java/kudu-client/src/main/java/org/apache/kudu/client/KuduPredicate.java b/java/kudu-client/src/main/java/org/apache/kudu/client/KuduPredicate.java
index 965a1e7..76c7594 100644
--- a/java/kudu-client/src/main/java/org/apache/kudu/client/KuduPredicate.java
+++ b/java/kudu-client/src/main/java/org/apache/kudu/client/KuduPredicate.java
@@ -143,7 +143,7 @@ public class KuduPredicate {
public static KuduPredicate newComparisonPredicate(ColumnSchema column,
ComparisonOp op,
long value) {
- checkColumn(column, Type.INT8, Type.INT16, Type.INT32, Type.INT64, Type.TIMESTAMP);
+ checkColumn(column, Type.INT8, Type.INT16, Type.INT32, Type.INT64, Type.UNIXTIME_MICROS);
Preconditions.checkArgument(value <= maxIntValue(column.getType()) &&
value >= minIntValue(column.getType()),
"integer value out of range for %s column: %s",
@@ -181,7 +181,7 @@ public class KuduPredicate {
break;
}
case INT64:
- case TIMESTAMP: {
+ case UNIXTIME_MICROS: {
bytes = Bytes.fromLong(value);
break;
}
@@ -499,7 +499,7 @@ public class KuduPredicate {
case INT32:
return Integer.compare(Bytes.getInt(a), Bytes.getInt(b));
case INT64:
- case TIMESTAMP:
+ case UNIXTIME_MICROS:
return Long.compare(Bytes.getLong(a), Bytes.getLong(b));
case FLOAT:
return Float.compare(Bytes.getFloat(a), Bytes.getFloat(b));
@@ -538,7 +538,7 @@ public class KuduPredicate {
return m < n && m + 1 == n;
}
case INT64:
- case TIMESTAMP: {
+ case UNIXTIME_MICROS: {
long m = Bytes.getLong(a);
long n = Bytes.getLong(b);
return m < n && m + 1 == n;
@@ -591,7 +591,7 @@ public class KuduPredicate {
case INT8: return Byte.MAX_VALUE;
case INT16: return Short.MAX_VALUE;
case INT32: return Integer.MAX_VALUE;
- case TIMESTAMP:
+ case UNIXTIME_MICROS:
case INT64: return Long.MAX_VALUE;
default: throw new IllegalArgumentException("type must be an integer type");
}
@@ -608,7 +608,7 @@ public class KuduPredicate {
case INT8: return Byte.MIN_VALUE;
case INT16: return Short.MIN_VALUE;
case INT32: return Integer.MIN_VALUE;
- case TIMESTAMP:
+ case UNIXTIME_MICROS:
case INT64: return Long.MIN_VALUE;
default: throw new IllegalArgumentException("type must be an integer type");
}
@@ -641,7 +641,7 @@ public class KuduPredicate {
case INT16: return Short.toString(Bytes.getShort(value));
case INT32: return Integer.toString(Bytes.getInt(value));
case INT64: return Long.toString(Bytes.getLong(value));
- case TIMESTAMP: return RowResult.timestampToString(Bytes.getLong(value));
+ case UNIXTIME_MICROS: return RowResult.timestampToString(Bytes.getLong(value));
case FLOAT: return Float.toString(Bytes.getFloat(value));
case DOUBLE: return Double.toString(Bytes.getDouble(value));
case STRING: {
http://git-wip-us.apache.org/repos/asf/kudu/blob/7eaeb6d9/java/kudu-client/src/main/java/org/apache/kudu/client/PartialRow.java
----------------------------------------------------------------------
diff --git a/java/kudu-client/src/main/java/org/apache/kudu/client/PartialRow.java b/java/kudu-client/src/main/java/org/apache/kudu/client/PartialRow.java
index a59bf9f..b012bfc 100644
--- a/java/kudu-client/src/main/java/org/apache/kudu/client/PartialRow.java
+++ b/java/kudu-client/src/main/java/org/apache/kudu/client/PartialRow.java
@@ -211,14 +211,14 @@ public class PartialRow {
* @throws IllegalStateException if the row was already applied
*/
public void addLong(int columnIndex, long val) {
- checkColumn(schema.getColumnByIndex(columnIndex), Type.INT64, Type.TIMESTAMP);
+ checkColumn(schema.getColumnByIndex(columnIndex), Type.INT64, Type.UNIXTIME_MICROS);
Bytes.setLong(rowAlloc, val, getPositionInRowAllocAndSetBitSet(columnIndex));
}
/**
* Add an long for the specified column.
*
- * If this is a TIMESTAMP column, the long value provided should be the number of microseconds
+ * If this is a UNIXTIME_MICROS column, the long value provided should be the number of microseconds
* between a given time and January 1, 1970 UTC.
* For example, to encode the current time, use setLong(System.currentTimeMillis() * 1000);
*
@@ -579,7 +579,7 @@ public class PartialRow {
case INT64:
sb.append(Bytes.getLong(rowAlloc, schema.getColumnOffset(idx)));
break;
- case TIMESTAMP:
+ case UNIXTIME_MICROS:
sb.append(RowResult.timestampToString(
Bytes.getLong(rowAlloc, schema.getColumnOffset(idx))));
break;
@@ -616,7 +616,7 @@ public class PartialRow {
case INT16: addShort(index, Short.MIN_VALUE); break;
case INT32: addInt(index, Integer.MIN_VALUE); break;
case INT64:
- case TIMESTAMP: addLong(index, Integer.MIN_VALUE); break;
+ case UNIXTIME_MICROS: addLong(index, Integer.MIN_VALUE); break;
case FLOAT: addFloat(index, -Float.MAX_VALUE); break;
case DOUBLE: addDouble(index, -Double.MAX_VALUE); break;
case STRING: addStringUtf8(index, AsyncKuduClient.EMPTY_ARRAY); break;
@@ -637,7 +637,7 @@ public class PartialRow {
case INT16:
case INT32:
case INT64:
- case TIMESTAMP:
+ case UNIXTIME_MICROS:
case FLOAT:
case DOUBLE: {
Preconditions.checkArgument(value.length == type.getSize());
@@ -689,7 +689,7 @@ public class PartialRow {
return true;
}
case INT64:
- case TIMESTAMP: {
+ case UNIXTIME_MICROS: {
long existing = Bytes.getLong(rowAlloc, offset);
if (existing == Long.MAX_VALUE) return false;
Bytes.setLong(rowAlloc, existing + 1, offset);
http://git-wip-us.apache.org/repos/asf/kudu/blob/7eaeb6d9/java/kudu-client/src/main/java/org/apache/kudu/client/ProtobufHelper.java
----------------------------------------------------------------------
diff --git a/java/kudu-client/src/main/java/org/apache/kudu/client/ProtobufHelper.java b/java/kudu-client/src/main/java/org/apache/kudu/client/ProtobufHelper.java
index ef31d6d..174cdb3 100644
--- a/java/kudu-client/src/main/java/org/apache/kudu/client/ProtobufHelper.java
+++ b/java/kudu-client/src/main/java/org/apache/kudu/client/ProtobufHelper.java
@@ -185,7 +185,7 @@ public class ProtobufHelper {
case INT32:
return Bytes.fromInt((Integer) value);
case INT64:
- case TIMESTAMP:
+ case UNIXTIME_MICROS:
return Bytes.fromLong((Long) value);
case STRING:
return ((String) value).getBytes(Charsets.UTF_8);
@@ -213,7 +213,7 @@ public class ProtobufHelper {
case INT32:
return Bytes.getInt(buf);
case INT64:
- case TIMESTAMP:
+ case UNIXTIME_MICROS:
return Bytes.getLong(buf);
case FLOAT:
return Bytes.getFloat(buf);
http://git-wip-us.apache.org/repos/asf/kudu/blob/7eaeb6d9/java/kudu-client/src/main/java/org/apache/kudu/client/RowResult.java
----------------------------------------------------------------------
diff --git a/java/kudu-client/src/main/java/org/apache/kudu/client/RowResult.java b/java/kudu-client/src/main/java/org/apache/kudu/client/RowResult.java
index 7afc1b4..0ef3e03 100644
--- a/java/kudu-client/src/main/java/org/apache/kudu/client/RowResult.java
+++ b/java/kudu-client/src/main/java/org/apache/kudu/client/RowResult.java
@@ -219,7 +219,7 @@ public class RowResult {
/**
* Get the specified column's long
*
- * If this is a TIMESTAMP column, the long value corresponds to a number of microseconds
+ * If this is a UNIXTIME_MICROS column, the long value corresponds to a number of microseconds
* since midnight, January 1, 1970 UTC.
*
* @param columnName name of the column to get data for
@@ -233,7 +233,7 @@ public class RowResult {
/**
* Get the specified column's long
*
- * If this is a TIMESTAMP column, the long value corresponds to a number of microseconds
+ * If this is a UNIXTIME_MICROS column, the long value corresponds to a number of microseconds
* since midnight, January 1, 1970 UTC.
*
* @param columnIndex Column index in the schema
@@ -540,7 +540,7 @@ public class RowResult {
break;
case INT32: buf.append(getInt(i)); break;
case INT64: buf.append(getLong(i)); break;
- case TIMESTAMP: {
+ case UNIXTIME_MICROS: {
buf.append(timestampToString(getLong(i)));
} break;
case STRING: buf.append(getString(i)); break;
http://git-wip-us.apache.org/repos/asf/kudu/blob/7eaeb6d9/java/kudu-client/src/test/java/org/apache/kudu/client/BaseKuduTest.java
----------------------------------------------------------------------
diff --git a/java/kudu-client/src/test/java/org/apache/kudu/client/BaseKuduTest.java b/java/kudu-client/src/test/java/org/apache/kudu/client/BaseKuduTest.java
index 99b5127..967c735 100644
--- a/java/kudu-client/src/test/java/org/apache/kudu/client/BaseKuduTest.java
+++ b/java/kudu-client/src/test/java/org/apache/kudu/client/BaseKuduTest.java
@@ -229,7 +229,7 @@ public class BaseKuduTest {
new ColumnSchema.ColumnSchemaBuilder("binary-array", Type.BINARY).build(),
new ColumnSchema.ColumnSchemaBuilder("binary-bytebuffer", Type.BINARY).build(),
new ColumnSchema.ColumnSchemaBuilder("null", Type.STRING).nullable(true).build(),
- new ColumnSchema.ColumnSchemaBuilder("timestamp", Type.TIMESTAMP).build());
+ new ColumnSchema.ColumnSchemaBuilder("timestamp", Type.UNIXTIME_MICROS).build());
return new Schema(columns);
}
http://git-wip-us.apache.org/repos/asf/kudu/blob/7eaeb6d9/java/kudu-client/src/test/java/org/apache/kudu/client/TestKuduClient.java
----------------------------------------------------------------------
diff --git a/java/kudu-client/src/test/java/org/apache/kudu/client/TestKuduClient.java b/java/kudu-client/src/test/java/org/apache/kudu/client/TestKuduClient.java
index 20d801f..0ae3727 100644
--- a/java/kudu-client/src/test/java/org/apache/kudu/client/TestKuduClient.java
+++ b/java/kudu-client/src/test/java/org/apache/kudu/client/TestKuduClient.java
@@ -72,8 +72,8 @@ public class TestKuduClient extends BaseKuduTest {
private Schema createSchemaWithTimestampColumns() {
ArrayList<ColumnSchema> columns = new ArrayList<ColumnSchema>();
- columns.add(new ColumnSchema.ColumnSchemaBuilder("key", Type.TIMESTAMP).key(true).build());
- columns.add(new ColumnSchema.ColumnSchemaBuilder("c1", Type.TIMESTAMP).nullable(true).build());
+ columns.add(new ColumnSchema.ColumnSchemaBuilder("key", Type.UNIXTIME_MICROS).key(true).build());
+ columns.add(new ColumnSchema.ColumnSchemaBuilder("c1", Type.UNIXTIME_MICROS).nullable(true).build());
return new Schema(columns);
}
@@ -275,7 +275,7 @@ public class TestKuduClient extends BaseKuduTest {
assertEquals(100, rowStrings.size());
for (int i = 0; i < rowStrings.size(); i++) {
StringBuilder expectedRow = new StringBuilder();
- expectedRow.append(String.format("TIMESTAMP key=%s, TIMESTAMP c1=",
+ expectedRow.append(String.format("UNIXTIME_MICROS key=%s, UNIXTIME_MICROS c1=",
timestampToString(timestamps.get(i))));
if (i % 2 == 1) {
expectedRow.append(timestampToString(timestamps.get(i)));
http://git-wip-us.apache.org/repos/asf/kudu/blob/7eaeb6d9/java/kudu-client/src/test/java/org/apache/kudu/client/TestKuduTable.java
----------------------------------------------------------------------
diff --git a/java/kudu-client/src/test/java/org/apache/kudu/client/TestKuduTable.java b/java/kudu-client/src/test/java/org/apache/kudu/client/TestKuduTable.java
index 7983b53..b2a4d01 100644
--- a/java/kudu-client/src/test/java/org/apache/kudu/client/TestKuduTable.java
+++ b/java/kudu-client/src/test/java/org/apache/kudu/client/TestKuduTable.java
@@ -76,7 +76,7 @@ public class TestKuduTable extends BaseKuduTest {
ato = new AlterTableOptions()
.addColumn("testaddmulticolnotnull", Type.INT32, 4)
.addNullableColumn("testaddmulticolnull", Type.STRING)
- .addColumn("testaddmulticolTimestampcol", Type.TIMESTAMP,
+ .addColumn("testaddmulticolTimestampcol", Type.UNIXTIME_MICROS,
(System.currentTimeMillis() * 1000));
submitAlterAndCheck(ato, tableName);
http://git-wip-us.apache.org/repos/asf/kudu/blob/7eaeb6d9/java/kudu-client/src/test/java/org/apache/kudu/client/TestOperation.java
----------------------------------------------------------------------
diff --git a/java/kudu-client/src/test/java/org/apache/kudu/client/TestOperation.java b/java/kudu-client/src/test/java/org/apache/kudu/client/TestOperation.java
index 77baf81..edc06c2 100644
--- a/java/kudu-client/src/test/java/org/apache/kudu/client/TestOperation.java
+++ b/java/kudu-client/src/test/java/org/apache/kudu/client/TestOperation.java
@@ -128,7 +128,7 @@ public class TestOperation {
columns.add(new ColumnSchema.ColumnSchemaBuilder("c1", Type.INT16).key(true).build());
columns.add(new ColumnSchema.ColumnSchemaBuilder("c2", Type.INT32).key(true).build());
columns.add(new ColumnSchema.ColumnSchemaBuilder("c3", Type.INT64).key(true).build());
- columns.add(new ColumnSchema.ColumnSchemaBuilder("c4", Type.TIMESTAMP).key(true).build());
+ columns.add(new ColumnSchema.ColumnSchemaBuilder("c4", Type.UNIXTIME_MICROS).key(true).build());
columns.add(new ColumnSchema.ColumnSchemaBuilder("c5", Type.STRING).key(true).build());
columns.add(new ColumnSchema.ColumnSchemaBuilder("c6", Type.BINARY).key(true).build());
return new Schema(columns);
@@ -149,8 +149,8 @@ public class TestOperation {
row.addBinary("c6", Bytes.fromString("c6_val"));
assertEquals("(int8 c0=1, int16 c1=2, int32 c2=3, int64 c3=4, " +
- "timestamp c4=1970-01-01T00:00:00.000005Z, string c5=c5_val, " +
- "binary c6=\"c6_val\")",
+ "unixtime_micros c4=1970-01-01T00:00:00.000005Z, string c5=c5_val, " +
+ "binary c6=\"c6_val\")",
insert.getRow().stringifyRowKey());
// Test an incomplete row key.
http://git-wip-us.apache.org/repos/asf/kudu/blob/7eaeb6d9/java/kudu-client/src/test/java/org/apache/kudu/client/TestPartitionPruner.java
----------------------------------------------------------------------
diff --git a/java/kudu-client/src/test/java/org/apache/kudu/client/TestPartitionPruner.java b/java/kudu-client/src/test/java/org/apache/kudu/client/TestPartitionPruner.java
index b065cdb..6c3faff 100644
--- a/java/kudu-client/src/test/java/org/apache/kudu/client/TestPartitionPruner.java
+++ b/java/kudu-client/src/test/java/org/apache/kudu/client/TestPartitionPruner.java
@@ -465,7 +465,7 @@ public class TestPartitionPruner extends BaseKuduTest {
@Test
public void testPruning() throws Exception {
// CREATE TABLE timeseries
- // (host STRING, metric STRING, timestamp TIMESTAMP, value DOUBLE)
+ // (host STRING, metric STRING, timestamp UNIXTIME_MICROS, value DOUBLE)
// PRIMARY KEY (host, metric, time)
// DISTRIBUTE BY
// RANGE(time) SPLIT ROWS [(10)],
@@ -475,7 +475,7 @@ public class TestPartitionPruner extends BaseKuduTest {
ColumnSchema host = new ColumnSchema.ColumnSchemaBuilder("host", Type.STRING).key(true).build();
ColumnSchema metric = new ColumnSchema.ColumnSchemaBuilder("metric", Type.STRING).key(true).build();
- ColumnSchema timestamp = new ColumnSchema.ColumnSchemaBuilder("timestamp", Type.TIMESTAMP).key(true).build();
+ ColumnSchema timestamp = new ColumnSchema.ColumnSchemaBuilder("timestamp", Type.UNIXTIME_MICROS).key(true).build();
ColumnSchema value = new ColumnSchema.ColumnSchemaBuilder("value", Type.DOUBLE).build();
Schema schema = new Schema(ImmutableList.of(host, metric, timestamp, value));
http://git-wip-us.apache.org/repos/asf/kudu/blob/7eaeb6d9/java/kudu-client/src/test/java/org/apache/kudu/client/TestRowResult.java
----------------------------------------------------------------------
diff --git a/java/kudu-client/src/test/java/org/apache/kudu/client/TestRowResult.java b/java/kudu-client/src/test/java/org/apache/kudu/client/TestRowResult.java
index 0daf3f3..0db5b44 100644
--- a/java/kudu-client/src/test/java/org/apache/kudu/client/TestRowResult.java
+++ b/java/kudu-client/src/test/java/org/apache/kudu/client/TestRowResult.java
@@ -123,7 +123,7 @@ public class TestRowResult extends BaseKuduTest {
assertEquals(Type.DOUBLE, rr.getColumnType(6));
assertEquals(Type.STRING, rr.getColumnType(7));
assertEquals(Type.BINARY, rr.getColumnType(8));
- assertEquals(Type.TIMESTAMP, rr.getColumnType(11));
+ assertEquals(Type.UNIXTIME_MICROS, rr.getColumnType(11));
}
}
}
http://git-wip-us.apache.org/repos/asf/kudu/blob/7eaeb6d9/java/kudu-flume-sink/src/main/java/org/apache/kudu/flume/sink/AvroKuduOperationsProducer.java
----------------------------------------------------------------------
diff --git a/java/kudu-flume-sink/src/main/java/org/apache/kudu/flume/sink/AvroKuduOperationsProducer.java b/java/kudu-flume-sink/src/main/java/org/apache/kudu/flume/sink/AvroKuduOperationsProducer.java
index f799162..a3d6021 100644
--- a/java/kudu-flume-sink/src/main/java/org/apache/kudu/flume/sink/AvroKuduOperationsProducer.java
+++ b/java/kudu-flume-sink/src/main/java/org/apache/kudu/flume/sink/AvroKuduOperationsProducer.java
@@ -219,7 +219,7 @@ public class AvroKuduOperationsProducer implements KuduOperationsProducer {
row.addInt(name, (int) value);
break;
case INT64: // Fall through
- case TIMESTAMP:
+ case UNIXTIME_MICROS:
row.addLong(name, (long) value);
break;
case FLOAT:
http://git-wip-us.apache.org/repos/asf/kudu/blob/7eaeb6d9/java/kudu-spark/src/main/scala/org/apache/kudu/spark/kudu/DefaultSource.scala
----------------------------------------------------------------------
diff --git a/java/kudu-spark/src/main/scala/org/apache/kudu/spark/kudu/DefaultSource.scala b/java/kudu-spark/src/main/scala/org/apache/kudu/spark/kudu/DefaultSource.scala
index 286a75c..3bf152b 100644
--- a/java/kudu-spark/src/main/scala/org/apache/kudu/spark/kudu/DefaultSource.scala
+++ b/java/kudu-spark/src/main/scala/org/apache/kudu/spark/kudu/DefaultSource.scala
@@ -229,7 +229,7 @@ private[spark] object KuduRelation {
case Type.INT16 => ShortType
case Type.INT32 => IntegerType
case Type.INT64 => LongType
- case Type.TIMESTAMP => TimestampType
+ case Type.UNIXTIME_MICROS => TimestampType
case Type.FLOAT => FloatType
case Type.DOUBLE => DoubleType
case Type.STRING => StringType
http://git-wip-us.apache.org/repos/asf/kudu/blob/7eaeb6d9/java/kudu-spark/src/main/scala/org/apache/kudu/spark/kudu/KuduContext.scala
----------------------------------------------------------------------
diff --git a/java/kudu-spark/src/main/scala/org/apache/kudu/spark/kudu/KuduContext.scala b/java/kudu-spark/src/main/scala/org/apache/kudu/spark/kudu/KuduContext.scala
index 0fa9df9..1293901 100644
--- a/java/kudu-spark/src/main/scala/org/apache/kudu/spark/kudu/KuduContext.scala
+++ b/java/kudu-spark/src/main/scala/org/apache/kudu/spark/kudu/KuduContext.scala
@@ -112,7 +112,7 @@ class KuduContext(kuduMaster: String) extends Serializable {
case DataTypes.BinaryType => Type.BINARY
case DataTypes.BooleanType => Type.BOOL
case DataTypes.StringType => Type.STRING
- case DataTypes.TimestampType => Type.TIMESTAMP
+ case DataTypes.TimestampType => Type.UNIXTIME_MICROS
case DataTypes.ByteType => Type.INT8
case DataTypes.ShortType => Type.INT16
case DataTypes.IntegerType => Type.INT32
http://git-wip-us.apache.org/repos/asf/kudu/blob/7eaeb6d9/java/kudu-spark/src/main/scala/org/apache/kudu/spark/kudu/KuduRDD.scala
----------------------------------------------------------------------
diff --git a/java/kudu-spark/src/main/scala/org/apache/kudu/spark/kudu/KuduRDD.scala b/java/kudu-spark/src/main/scala/org/apache/kudu/spark/kudu/KuduRDD.scala
index 763ec96..33b23a4 100644
--- a/java/kudu-spark/src/main/scala/org/apache/kudu/spark/kudu/KuduRDD.scala
+++ b/java/kudu-spark/src/main/scala/org/apache/kudu/spark/kudu/KuduRDD.scala
@@ -119,7 +119,7 @@ private[spark] class KuduRow(private val rowResult: RowResult) extends Row {
case Type.INT16 => rowResult.getShort(i)
case Type.INT32 => rowResult.getInt(i)
case Type.INT64 => rowResult.getLong(i)
- case Type.TIMESTAMP => KuduRelation.microsToTimestamp(rowResult.getLong(i))
+ case Type.UNIXTIME_MICROS => KuduRelation.microsToTimestamp(rowResult.getLong(i))
case Type.FLOAT => rowResult.getFloat(i)
case Type.DOUBLE => rowResult.getDouble(i)
case Type.STRING => rowResult.getString(i)
http://git-wip-us.apache.org/repos/asf/kudu/blob/7eaeb6d9/java/kudu-spark/src/test/scala/org/apache/kudu/spark/kudu/KuduContextTest.scala
----------------------------------------------------------------------
diff --git a/java/kudu-spark/src/test/scala/org/apache/kudu/spark/kudu/KuduContextTest.scala b/java/kudu-spark/src/test/scala/org/apache/kudu/spark/kudu/KuduContextTest.scala
index 484e8f2..be0ed57 100644
--- a/java/kudu-spark/src/test/scala/org/apache/kudu/spark/kudu/KuduContextTest.scala
+++ b/java/kudu-spark/src/test/scala/org/apache/kudu/spark/kudu/KuduContextTest.scala
@@ -31,7 +31,7 @@ class KuduContextTest extends FunSuite with TestContext with Matchers {
test("Test basic kuduRDD") {
val rows = insertRows(rowCount)
val scanList = kuduContext.kuduRDD(sc, "test", Seq("key", "c1_i", "c2_s", "c3_double",
- "c4_long", "c5_bool", "c6_short", "c7_float", "c8_binary", "c9_timestamp", "c10_byte"))
+ "c4_long", "c5_bool", "c6_short", "c7_float", "c8_binary", "c9_unixtime_micros", "c10_byte"))
.map(r => r.toSeq).collect()
scanList.foreach(r => {
val index = r.apply(0).asInstanceOf[Int]
@@ -62,4 +62,4 @@ class KuduContextTest extends FunSuite with TestContext with Matchers {
dataDF.sort("key").withColumn("c8_binary", decode(dataDF("c8_binary"), "UTF-8"))
.select("c8_binary").first.get(0).shouldBe("bytes 0")
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/kudu/blob/7eaeb6d9/java/kudu-spark/src/test/scala/org/apache/kudu/spark/kudu/TestContext.scala
----------------------------------------------------------------------
diff --git a/java/kudu-spark/src/test/scala/org/apache/kudu/spark/kudu/TestContext.scala b/java/kudu-spark/src/test/scala/org/apache/kudu/spark/kudu/TestContext.scala
index 47aba37..ebd09bf 100644
--- a/java/kudu-spark/src/test/scala/org/apache/kudu/spark/kudu/TestContext.scala
+++ b/java/kudu-spark/src/test/scala/org/apache/kudu/spark/kudu/TestContext.scala
@@ -51,7 +51,7 @@ trait TestContext extends BeforeAndAfterAll { self: Suite =>
new ColumnSchemaBuilder("c6_short", Type.INT16).build(),
new ColumnSchemaBuilder("c7_float", Type.FLOAT).build(),
new ColumnSchemaBuilder("c8_binary", Type.BINARY).build(),
- new ColumnSchemaBuilder("c9_timestamp", Type.TIMESTAMP).build(),
+ new ColumnSchemaBuilder("c9_unixtime_micros", Type.UNIXTIME_MICROS).build(),
new ColumnSchemaBuilder("c10_byte", Type.INT8).build())
new Schema(columns)
}
@@ -128,4 +128,4 @@ trait TestContext extends BeforeAndAfterAll { self: Suite =>
}
rows
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/kudu/blob/7eaeb6d9/python/kudu/__init__.py
----------------------------------------------------------------------
diff --git a/python/kudu/__init__.py b/python/kudu/__init__.py
index e51f90f..155f2e5 100644
--- a/python/kudu/__init__.py
+++ b/python/kudu/__init__.py
@@ -28,7 +28,7 @@ from kudu.errors import (KuduException, KuduBadStatus, KuduNotFound, # noqa
from kudu.schema import (int8, int16, int32, int64, string_ as string, # noqa
double_ as double, float_, binary,
- timestamp,
+ unixtime_micros,
KuduType,
SchemaBuilder, ColumnSpec, Schema, ColumnSchema,
COMPRESSION_DEFAULT,
http://git-wip-us.apache.org/repos/asf/kudu/blob/7eaeb6d9/python/kudu/libkudu_client.pxd
----------------------------------------------------------------------
diff --git a/python/kudu/libkudu_client.pxd b/python/kudu/libkudu_client.pxd
index a10f601..74ae80e 100644
--- a/python/kudu/libkudu_client.pxd
+++ b/python/kudu/libkudu_client.pxd
@@ -117,7 +117,7 @@ cdef extern from "kudu/client/schema.h" namespace "kudu::client" nogil:
KUDU_FLOAT " kudu::client::KuduColumnSchema::FLOAT"
KUDU_DOUBLE " kudu::client::KuduColumnSchema::DOUBLE"
KUDU_BINARY " kudu::client::KuduColumnSchema::BINARY"
- KUDU_TIMESTAMP " kudu::client::KuduColumnSchema::TIMESTAMP"
+ KUDU_UNIXTIME_MICROS " kudu::client::KuduColumnSchema::UNIXTIME_MICROS"
enum EncodingType" kudu::client::KuduColumnStorageAttributes::EncodingType":
EncodingType_AUTO " kudu::client::KuduColumnStorageAttributes::AUTO_ENCODING"
@@ -211,7 +211,7 @@ cdef extern from "kudu/client/scan_batch.h" namespace "kudu::client" nogil:
Status GetInt32(Slice& col_name, int32_t* val)
Status GetInt64(Slice& col_name, int64_t* val)
- Status GetTimestamp(const Slice& col_name,
+ Status GetUnixTimeMicros(const Slice& col_name,
int64_t* micros_since_utc_epoch)
Status GetBool(int col_idx, c_bool* val)
@@ -293,9 +293,9 @@ cdef extern from "kudu/common/partial_row.h" namespace "kudu" nogil:
Status SetInt32(Slice& col_name, int32_t val)
Status SetInt64(Slice& col_name, int64_t val)
- Status SetTimestamp(const Slice& col_name,
- int64_t micros_since_utc_epoch)
- Status SetTimestamp(int col_idx, int64_t micros_since_utc_epoch)
+ Status SetUnixTimeMicros(const Slice& col_name,
+ int64_t micros_since_utc_epoch)
+ Status SetUnixTimeMicros(int col_idx, int64_t micros_since_utc_epoch)
Status SetDouble(Slice& col_name, double val)
Status SetFloat(Slice& col_name, float val)
@@ -351,9 +351,9 @@ cdef extern from "kudu/common/partial_row.h" namespace "kudu" nogil:
Status GetInt64(Slice& col_name, int64_t* val)
Status GetInt64(int col_idx, int64_t* val)
- Status GetTimestamp(const Slice& col_name,
+ Status GetUnixTimeMicros(const Slice& col_name,
int64_t* micros_since_utc_epoch)
- Status GetTimestamp(int col_idx, int64_t* micros_since_utc_epoch)
+ Status GetUnixTimeMicros(int col_idx, int64_t* micros_since_utc_epoch)
Status GetDouble(Slice& col_name, double* val)
Status GetDouble(int col_idx, double* val)
http://git-wip-us.apache.org/repos/asf/kudu/blob/7eaeb6d9/python/kudu/schema.pyx
----------------------------------------------------------------------
diff --git a/python/kudu/schema.pyx b/python/kudu/schema.pyx
index f02d0e4..375d8f2 100644
--- a/python/kudu/schema.pyx
+++ b/python/kudu/schema.pyx
@@ -39,7 +39,7 @@ INT64 = KUDU_INT64
FLOAT = KUDU_FLOAT
DOUBLE = KUDU_DOUBLE
-TIMESTAMP = KUDU_TIMESTAMP
+UNIXTIME_MICROS = KUDU_UNIXTIME_MICROS
BINARY = KUDU_BINARY
@@ -110,7 +110,7 @@ bool_ = KuduType(KUDU_BOOL)
float_ = KuduType(KUDU_FLOAT)
double_ = KuduType(KUDU_DOUBLE)
binary = KuduType(KUDU_BINARY)
-timestamp = KuduType(KUDU_TIMESTAMP)
+unixtime_micros = KuduType(KUDU_UNIXTIME_MICROS)
cdef dict _type_names = {
@@ -123,7 +123,7 @@ cdef dict _type_names = {
FLOAT: 'float',
DOUBLE: 'double',
BINARY: 'binary',
- TIMESTAMP: 'timestamp'
+ UNIXTIME_MICROS: 'unixtime_micros'
}
@@ -139,7 +139,7 @@ cdef dict _type_to_obj = {
FLOAT: float_,
DOUBLE: double_,
BINARY: binary,
- TIMESTAMP: timestamp
+ UNIXTIME_MICROS: unixtime_micros
}
http://git-wip-us.apache.org/repos/asf/kudu/blob/7eaeb6d9/src/kudu/client/predicate-test.cc
----------------------------------------------------------------------
diff --git a/src/kudu/client/predicate-test.cc b/src/kudu/client/predicate-test.cc
index 72013be..3be0939 100644
--- a/src/kudu/client/predicate-test.cc
+++ b/src/kudu/client/predicate-test.cc
@@ -561,14 +561,14 @@ TEST_F(PredicateTest, TestInt64Predicates) {
}
TEST_F(PredicateTest, TestTimestampPredicates) {
- shared_ptr<KuduTable> table = CreateAndOpenTable(KuduColumnSchema::TIMESTAMP);
+ shared_ptr<KuduTable> table = CreateAndOpenTable(KuduColumnSchema::UNIXTIME_MICROS);
shared_ptr<KuduSession> session = CreateSession();
int i = 0;
for (int64_t value : CreateIntValues<int64_t>()) {
unique_ptr<KuduInsert> insert(table->NewInsert());
ASSERT_OK(insert->mutable_row()->SetInt64("key", i++));
- ASSERT_OK(insert->mutable_row()->SetTimestamp("value", value));
+ ASSERT_OK(insert->mutable_row()->SetUnixTimeMicros("value", value));
ASSERT_OK(session->Apply(insert.release()));
}
unique_ptr<KuduInsert> null_insert(table->NewInsert());
http://git-wip-us.apache.org/repos/asf/kudu/blob/7eaeb6d9/src/kudu/client/scan_batch.cc
----------------------------------------------------------------------
diff --git a/src/kudu/client/scan_batch.cc b/src/kudu/client/scan_batch.cc
index f2ad8ce..14d1784 100644
--- a/src/kudu/client/scan_batch.cc
+++ b/src/kudu/client/scan_batch.cc
@@ -127,8 +127,8 @@ Status KuduScanBatch::RowPtr::GetInt64(const Slice& col_name, int64_t* val) cons
return Get<TypeTraits<INT64> >(col_name, val);
}
-Status KuduScanBatch::RowPtr::GetTimestamp(const Slice& col_name, int64_t* val) const {
- return Get<TypeTraits<TIMESTAMP> >(col_name, val);
+Status KuduScanBatch::RowPtr::GetUnixTimeMicros(const Slice& col_name, int64_t* val) const {
+ return Get<TypeTraits<UNIXTIME_MICROS> >(col_name, val);
}
Status KuduScanBatch::RowPtr::GetFloat(const Slice& col_name, float* val) const {
@@ -167,8 +167,8 @@ Status KuduScanBatch::RowPtr::GetInt64(int col_idx, int64_t* val) const {
return Get<TypeTraits<INT64> >(col_idx, val);
}
-Status KuduScanBatch::RowPtr::GetTimestamp(int col_idx, int64_t* val) const {
- return Get<TypeTraits<TIMESTAMP> >(col_idx, val);
+Status KuduScanBatch::RowPtr::GetUnixTimeMicros(int col_idx, int64_t* val) const {
+ return Get<TypeTraits<UNIXTIME_MICROS> >(col_idx, val);
}
Status KuduScanBatch::RowPtr::GetFloat(int col_idx, float* val) const {
@@ -239,7 +239,7 @@ template
Status KuduScanBatch::RowPtr::Get<TypeTraits<INT64> >(const Slice& col_name, int64_t* val) const;
template
-Status KuduScanBatch::RowPtr::Get<TypeTraits<TIMESTAMP> >(
+Status KuduScanBatch::RowPtr::Get<TypeTraits<UNIXTIME_MICROS> >(
const Slice& col_name, int64_t* val) const;
template
@@ -270,7 +270,7 @@ template
Status KuduScanBatch::RowPtr::Get<TypeTraits<INT64> >(int col_idx, int64_t* val) const;
template
-Status KuduScanBatch::RowPtr::Get<TypeTraits<TIMESTAMP> >(int col_idx, int64_t* val) const;
+Status KuduScanBatch::RowPtr::Get<TypeTraits<UNIXTIME_MICROS> >(int col_idx, int64_t* val) const;
template
Status KuduScanBatch::RowPtr::Get<TypeTraits<FLOAT> >(int col_idx, float* val) const;
http://git-wip-us.apache.org/repos/asf/kudu/blob/7eaeb6d9/src/kudu/client/scan_batch.h
----------------------------------------------------------------------
diff --git a/src/kudu/client/scan_batch.h b/src/kudu/client/scan_batch.h
index f3b0ea0..9b1433d 100644
--- a/src/kudu/client/scan_batch.h
+++ b/src/kudu/client/scan_batch.h
@@ -160,7 +160,7 @@ class KUDU_EXPORT KuduScanBatch::RowPtr {
Status GetInt16(const Slice& col_name, int16_t* val) const WARN_UNUSED_RESULT;
Status GetInt32(const Slice& col_name, int32_t* val) const WARN_UNUSED_RESULT;
Status GetInt64(const Slice& col_name, int64_t* val) const WARN_UNUSED_RESULT;
- Status GetTimestamp(const Slice& col_name, int64_t* micros_since_utc_epoch)
+ Status GetUnixTimeMicros(const Slice& col_name, int64_t* micros_since_utc_epoch)
const WARN_UNUSED_RESULT;
Status GetFloat(const Slice& col_name, float* val) const WARN_UNUSED_RESULT;
@@ -191,7 +191,7 @@ class KUDU_EXPORT KuduScanBatch::RowPtr {
Status GetInt16(int col_idx, int16_t* val) const WARN_UNUSED_RESULT;
Status GetInt32(int col_idx, int32_t* val) const WARN_UNUSED_RESULT;
Status GetInt64(int col_idx, int64_t* val) const WARN_UNUSED_RESULT;
- Status GetTimestamp(int col_idx, int64_t* micros_since_utc_epoch) const WARN_UNUSED_RESULT;
+ Status GetUnixTimeMicros(int col_idx, int64_t* micros_since_utc_epoch) const WARN_UNUSED_RESULT;
Status GetFloat(int col_idx, float* val) const WARN_UNUSED_RESULT;
Status GetDouble(int col_idx, double* val) const WARN_UNUSED_RESULT;
http://git-wip-us.apache.org/repos/asf/kudu/blob/7eaeb6d9/src/kudu/client/schema.cc
----------------------------------------------------------------------
diff --git a/src/kudu/client/schema.cc b/src/kudu/client/schema.cc
index ef5f5e3..516dfcd 100644
--- a/src/kudu/client/schema.cc
+++ b/src/kudu/client/schema.cc
@@ -101,7 +101,7 @@ kudu::DataType ToInternalDataType(KuduColumnSchema::DataType type) {
case KuduColumnSchema::INT16: return kudu::INT16;
case KuduColumnSchema::INT32: return kudu::INT32;
case KuduColumnSchema::INT64: return kudu::INT64;
- case KuduColumnSchema::TIMESTAMP: return kudu::TIMESTAMP;
+ case KuduColumnSchema::UNIXTIME_MICROS: return kudu::UNIXTIME_MICROS;
case KuduColumnSchema::FLOAT: return kudu::FLOAT;
case KuduColumnSchema::DOUBLE: return kudu::DOUBLE;
case KuduColumnSchema::STRING: return kudu::STRING;
@@ -117,7 +117,7 @@ KuduColumnSchema::DataType FromInternalDataType(kudu::DataType type) {
case kudu::INT16: return KuduColumnSchema::INT16;
case kudu::INT32: return KuduColumnSchema::INT32;
case kudu::INT64: return KuduColumnSchema::INT64;
- case kudu::TIMESTAMP: return KuduColumnSchema::TIMESTAMP;
+ case kudu::UNIXTIME_MICROS: return KuduColumnSchema::UNIXTIME_MICROS;
case kudu::FLOAT: return KuduColumnSchema::FLOAT;
case kudu::DOUBLE: return KuduColumnSchema::DOUBLE;
case kudu::STRING: return KuduColumnSchema::STRING;
http://git-wip-us.apache.org/repos/asf/kudu/blob/7eaeb6d9/src/kudu/client/schema.h
----------------------------------------------------------------------
diff --git a/src/kudu/client/schema.h b/src/kudu/client/schema.h
index 2f85c56..70ba676 100644
--- a/src/kudu/client/schema.h
+++ b/src/kudu/client/schema.h
@@ -126,7 +126,8 @@ class KUDU_EXPORT KuduColumnSchema {
FLOAT = 6,
DOUBLE = 7,
BINARY = 8,
- TIMESTAMP = 9
+ UNIXTIME_MICROS = 9,
+ TIMESTAMP = UNIXTIME_MICROS //!< deprecated, use UNIXTIME_MICROS
};
/// @param [in] type
http://git-wip-us.apache.org/repos/asf/kudu/blob/7eaeb6d9/src/kudu/common/common.proto
----------------------------------------------------------------------
diff --git a/src/kudu/common/common.proto b/src/kudu/common/common.proto
index e5ce03c..2e4914f 100644
--- a/src/kudu/common/common.proto
+++ b/src/kudu/common/common.proto
@@ -45,7 +45,7 @@ enum DataType {
FLOAT = 10;
DOUBLE = 11;
BINARY = 12;
- TIMESTAMP = 13;
+ UNIXTIME_MICROS = 13;
}
enum EncodingType {
http://git-wip-us.apache.org/repos/asf/kudu/blob/7eaeb6d9/src/kudu/common/key_util.cc
----------------------------------------------------------------------
diff --git a/src/kudu/common/key_util.cc b/src/kudu/common/key_util.cc
index df45516..f62caba 100644
--- a/src/kudu/common/key_util.cc
+++ b/src/kudu/common/key_util.cc
@@ -250,7 +250,7 @@ bool IncrementCell(const ColumnSchema& col, void* cell_ptr, Arena* arena) {
HANDLE_TYPE(INT8);
HANDLE_TYPE(INT16);
HANDLE_TYPE(INT32);
- HANDLE_TYPE(TIMESTAMP);
+ HANDLE_TYPE(UNIXTIME_MICROS);
HANDLE_TYPE(INT64);
case FLOAT:
return IncrementFloatingPointCell<FLOAT>(cell_ptr);
http://git-wip-us.apache.org/repos/asf/kudu/blob/7eaeb6d9/src/kudu/common/partial_row.cc
----------------------------------------------------------------------
diff --git a/src/kudu/common/partial_row.cc b/src/kudu/common/partial_row.cc
index cfecdc7..a3e54d6 100644
--- a/src/kudu/common/partial_row.cc
+++ b/src/kudu/common/partial_row.cc
@@ -187,8 +187,8 @@ Status KuduPartialRow::Set(int32_t column_idx, const uint8_t* val) {
RETURN_NOT_OK(SetBinaryCopy(column_idx, *reinterpret_cast<const Slice*>(val)));
break;
};
- case TIMESTAMP: {
- RETURN_NOT_OK(SetTimestamp(column_idx, *reinterpret_cast<const int64_t*>(val)));
+ case UNIXTIME_MICROS: {
+ RETURN_NOT_OK(SetUnixTimeMicros(column_idx, *reinterpret_cast<const int64_t*>(val)));
break;
};
default: {
@@ -239,8 +239,8 @@ Status KuduPartialRow::SetInt32(const Slice& col_name, int32_t val) {
Status KuduPartialRow::SetInt64(const Slice& col_name, int64_t val) {
return Set<TypeTraits<INT64> >(col_name, val);
}
-Status KuduPartialRow::SetTimestamp(const Slice& col_name, int64_t val) {
- return Set<TypeTraits<TIMESTAMP> >(col_name, val);
+Status KuduPartialRow::SetUnixTimeMicros(const Slice& col_name, int64_t val) {
+ return Set<TypeTraits<UNIXTIME_MICROS> >(col_name, val);
}
Status KuduPartialRow::SetFloat(const Slice& col_name, float val) {
return Set<TypeTraits<FLOAT> >(col_name, val);
@@ -263,8 +263,8 @@ Status KuduPartialRow::SetInt32(int col_idx, int32_t val) {
Status KuduPartialRow::SetInt64(int col_idx, int64_t val) {
return Set<TypeTraits<INT64> >(col_idx, val);
}
-Status KuduPartialRow::SetTimestamp(int col_idx, int64_t val) {
- return Set<TypeTraits<TIMESTAMP> >(col_idx, val);
+Status KuduPartialRow::SetUnixTimeMicros(int col_idx, int64_t val) {
+ return Set<TypeTraits<UNIXTIME_MICROS> >(col_idx, val);
}
Status KuduPartialRow::SetFloat(int col_idx, float val) {
return Set<TypeTraits<FLOAT> >(col_idx, val);
@@ -410,9 +410,9 @@ Status KuduPartialRow::Set<TypeTraits<INT64> >(int col_idx,
bool owned);
template
-Status KuduPartialRow::Set<TypeTraits<TIMESTAMP> >(
+Status KuduPartialRow::Set<TypeTraits<UNIXTIME_MICROS> >(
int col_idx,
- const TypeTraits<TIMESTAMP>::cpp_type& val,
+ const TypeTraits<UNIXTIME_MICROS>::cpp_type& val,
bool owned);
template
@@ -461,9 +461,9 @@ Status KuduPartialRow::Set<TypeTraits<INT64> >(const Slice& col_name,
bool owned);
template
-Status KuduPartialRow::Set<TypeTraits<TIMESTAMP> >(
+Status KuduPartialRow::Set<TypeTraits<UNIXTIME_MICROS> >(
const Slice& col_name,
- const TypeTraits<TIMESTAMP>::cpp_type& val,
+ const TypeTraits<UNIXTIME_MICROS>::cpp_type& val,
bool owned);
template
@@ -539,8 +539,9 @@ Status KuduPartialRow::GetInt32(const Slice& col_name, int32_t* val) const {
Status KuduPartialRow::GetInt64(const Slice& col_name, int64_t* val) const {
return Get<TypeTraits<INT64> >(col_name, val);
}
-Status KuduPartialRow::GetTimestamp(const Slice& col_name, int64_t* micros_since_utc_epoch) const {
- return Get<TypeTraits<TIMESTAMP> >(col_name, micros_since_utc_epoch);
+Status KuduPartialRow::GetUnixTimeMicros(const Slice& col_name,
+ int64_t* micros_since_utc_epoch) const {
+ return Get<TypeTraits<UNIXTIME_MICROS> >(col_name, micros_since_utc_epoch);
}
Status KuduPartialRow::GetFloat(const Slice& col_name, float* val) const {
return Get<TypeTraits<FLOAT> >(col_name, val);
@@ -570,8 +571,8 @@ Status KuduPartialRow::GetInt32(int col_idx, int32_t* val) const {
Status KuduPartialRow::GetInt64(int col_idx, int64_t* val) const {
return Get<TypeTraits<INT64> >(col_idx, val);
}
-Status KuduPartialRow::GetTimestamp(int col_idx, int64_t* micros_since_utc_epoch) const {
- return Get<TypeTraits<TIMESTAMP> >(col_idx, micros_since_utc_epoch);
+Status KuduPartialRow::GetUnixTimeMicros(int col_idx, int64_t* micros_since_utc_epoch) const {
+ return Get<TypeTraits<UNIXTIME_MICROS> >(col_idx, micros_since_utc_epoch);
}
Status KuduPartialRow::GetFloat(int col_idx, float* val) const {
return Get<TypeTraits<FLOAT> >(col_idx, val);
http://git-wip-us.apache.org/repos/asf/kudu/blob/7eaeb6d9/src/kudu/common/partial_row.h
----------------------------------------------------------------------
diff --git a/src/kudu/common/partial_row.h b/src/kudu/common/partial_row.h
index 452aba8..22c71dc 100644
--- a/src/kudu/common/partial_row.h
+++ b/src/kudu/common/partial_row.h
@@ -89,7 +89,8 @@ class KUDU_EXPORT KuduPartialRow {
Status SetInt16(const Slice& col_name, int16_t val) WARN_UNUSED_RESULT;
Status SetInt32(const Slice& col_name, int32_t val) WARN_UNUSED_RESULT;
Status SetInt64(const Slice& col_name, int64_t val) WARN_UNUSED_RESULT;
- Status SetTimestamp(const Slice& col_name, int64_t micros_since_utc_epoch) WARN_UNUSED_RESULT;
+ Status SetUnixTimeMicros(const Slice& col_name,
+ int64_t micros_since_utc_epoch) WARN_UNUSED_RESULT;
Status SetFloat(const Slice& col_name, float val) WARN_UNUSED_RESULT;
Status SetDouble(const Slice& col_name, double val) WARN_UNUSED_RESULT;
@@ -117,7 +118,7 @@ class KUDU_EXPORT KuduPartialRow {
Status SetInt16(int col_idx, int16_t val) WARN_UNUSED_RESULT;
Status SetInt32(int col_idx, int32_t val) WARN_UNUSED_RESULT;
Status SetInt64(int col_idx, int64_t val) WARN_UNUSED_RESULT;
- Status SetTimestamp(int col_idx, int64_t micros_since_utc_epoch) WARN_UNUSED_RESULT;
+ Status SetUnixTimeMicros(int col_idx, int64_t micros_since_utc_epoch) WARN_UNUSED_RESULT;
Status SetFloat(int col_idx, float val) WARN_UNUSED_RESULT;
Status SetDouble(int col_idx, double val) WARN_UNUSED_RESULT;
@@ -337,7 +338,7 @@ class KUDU_EXPORT KuduPartialRow {
Status GetInt16(const Slice& col_name, int16_t* val) const WARN_UNUSED_RESULT;
Status GetInt32(const Slice& col_name, int32_t* val) const WARN_UNUSED_RESULT;
Status GetInt64(const Slice& col_name, int64_t* val) const WARN_UNUSED_RESULT;
- Status GetTimestamp(const Slice& col_name,
+ Status GetUnixTimeMicros(const Slice& col_name,
int64_t* micros_since_utc_epoch) const WARN_UNUSED_RESULT;
Status GetFloat(const Slice& col_name, float* val) const WARN_UNUSED_RESULT;
@@ -368,7 +369,7 @@ class KUDU_EXPORT KuduPartialRow {
Status GetInt16(int col_idx, int16_t* val) const WARN_UNUSED_RESULT;
Status GetInt32(int col_idx, int32_t* val) const WARN_UNUSED_RESULT;
Status GetInt64(int col_idx, int64_t* val) const WARN_UNUSED_RESULT;
- Status GetTimestamp(int col_idx, int64_t* micros_since_utc_epoch) const WARN_UNUSED_RESULT;
+ Status GetUnixTimeMicros(int col_idx, int64_t* micros_since_utc_epoch) const WARN_UNUSED_RESULT;
Status GetFloat(int col_idx, float* val) const WARN_UNUSED_RESULT;
Status GetDouble(int col_idx, double* val) const WARN_UNUSED_RESULT;
http://git-wip-us.apache.org/repos/asf/kudu/blob/7eaeb6d9/src/kudu/common/partition.cc
----------------------------------------------------------------------
diff --git a/src/kudu/common/partition.cc b/src/kudu/common/partition.cc
index 5a24228..6a9cf81 100644
--- a/src/kudu/common/partition.cc
+++ b/src/kudu/common/partition.cc
@@ -951,7 +951,7 @@ namespace {
RETURN_NOT_OK(row->SetInt32(idx, INT32_MIN + 1));
break;
case INT64:
- case TIMESTAMP:
+ case UNIXTIME_MICROS:
RETURN_NOT_OK(row->SetInt64(idx, INT64_MIN + 1));
break;
case STRING:
@@ -1004,7 +1004,7 @@ namespace {
break;
}
case INT64:
- case TIMESTAMP: {
+ case UNIXTIME_MICROS: {
int64_t value;
RETURN_NOT_OK(row->GetInt64(idx, &value));
if (value < INT64_MAX) {
http://git-wip-us.apache.org/repos/asf/kudu/blob/7eaeb6d9/src/kudu/common/partition_pruner-test.cc
----------------------------------------------------------------------
diff --git a/src/kudu/common/partition_pruner-test.cc b/src/kudu/common/partition_pruner-test.cc
index 9957ee0..889ebaa 100644
--- a/src/kudu/common/partition_pruner-test.cc
+++ b/src/kudu/common/partition_pruner-test.cc
@@ -517,13 +517,13 @@ TEST(TestPartitionPruner, TestHashPruning) {
TEST(TestPartitionPruner, TestPruning) {
// CREATE TABLE timeseries
- // (host STRING, metric STRING, time TIMESTAMP, value DOUBLE)
+ // (host STRING, metric STRING, time UNIXTIME_MICROS, value DOUBLE)
// PRIMARY KEY (host, metric, time)
// DISTRIBUTE BY RANGE(time) SPLIT ROWS [(10)],
// HASH(host, metric) INTO 2 BUCKETS;
Schema schema({ ColumnSchema("host", STRING),
ColumnSchema("metric", STRING),
- ColumnSchema("time", TIMESTAMP),
+ ColumnSchema("time", UNIXTIME_MICROS),
ColumnSchema("value", DOUBLE) },
{ ColumnId(0), ColumnId(1), ColumnId(2), ColumnId(3) },
3);
@@ -540,7 +540,7 @@ TEST(TestPartitionPruner, TestPruning) {
ASSERT_OK(PartitionSchema::FromPB(pb, schema, &partition_schema));
KuduPartialRow split(&schema);
- ASSERT_OK(split.SetTimestamp("time", 10));
+ ASSERT_OK(split.SetUnixTimeMicros("time", 10));
vector<Partition> partitions;
ASSERT_OK(partition_schema.CreatePartitions(vector<KuduPartialRow>{ move(split) },
http://git-wip-us.apache.org/repos/asf/kudu/blob/7eaeb6d9/src/kudu/common/row.h
----------------------------------------------------------------------
diff --git a/src/kudu/common/row.h b/src/kudu/common/row.h
index 7d82336..88b5d55 100644
--- a/src/kudu/common/row.h
+++ b/src/kudu/common/row.h
@@ -627,7 +627,7 @@ class RowBuilder {
}
void AddTimestamp(int64_t micros_utc_since_epoch) {
- CheckNextType(TIMESTAMP);
+ CheckNextType(UNIXTIME_MICROS);
*reinterpret_cast<int64_t *>(&buf_[byte_idx_]) = micros_utc_since_epoch;
Advance();
}
http://git-wip-us.apache.org/repos/asf/kudu/blob/7eaeb6d9/src/kudu/common/row_operations-test.cc
----------------------------------------------------------------------
diff --git a/src/kudu/common/row_operations-test.cc b/src/kudu/common/row_operations-test.cc
index 2c61261..3c7ce6a 100644
--- a/src/kudu/common/row_operations-test.cc
+++ b/src/kudu/common/row_operations-test.cc
@@ -626,7 +626,7 @@ TEST_F(RowOperationsTest, SplitKeyRoundTrip) {
ColumnSchema("int64", INT64),
ColumnSchema("string", STRING),
ColumnSchema("binary", BINARY),
- ColumnSchema("timestamp", TIMESTAMP),
+ ColumnSchema("timestamp", UNIXTIME_MICROS),
ColumnSchema("missing", STRING) },
8);
@@ -643,7 +643,7 @@ TEST_F(RowOperationsTest, SplitKeyRoundTrip) {
ASSERT_OK(row.SetInt64("int64", int64_expected));
ASSERT_OK(row.SetStringNoCopy("string", "string-value"));
ASSERT_OK(row.SetBinaryNoCopy("binary", "binary-value"));
- ASSERT_OK(row.SetTimestamp("timestamp", 9));
+ ASSERT_OK(row.SetUnixTimeMicros("timestamp", 9));
RowOperationsPB pb;
RowOperationsPBEncoder(&pb).Add(RowOperationsPB::SPLIT_ROW, row);
http://git-wip-us.apache.org/repos/asf/kudu/blob/7eaeb6d9/src/kudu/common/types-test.cc
----------------------------------------------------------------------
diff --git a/src/kudu/common/types-test.cc b/src/kudu/common/types-test.cc
index 49280d5..51eedf0 100644
--- a/src/kudu/common/types-test.cc
+++ b/src/kudu/common/types-test.cc
@@ -34,7 +34,7 @@ using std::vector;
namespace kudu {
TEST(TestTypes, TestTimestampPrinting) {
- const TypeInfo* info = GetTypeInfo(TIMESTAMP);
+ const TypeInfo* info = GetTypeInfo(UNIXTIME_MICROS);
// Test the minimum value
int64 time;
http://git-wip-us.apache.org/repos/asf/kudu/blob/7eaeb6d9/src/kudu/common/types.cc
----------------------------------------------------------------------
diff --git a/src/kudu/common/types.cc b/src/kudu/common/types.cc
index 7c1277d..9101353 100644
--- a/src/kudu/common/types.cc
+++ b/src/kudu/common/types.cc
@@ -70,7 +70,7 @@ class TypeInfoResolver {
AddMapping<INT32>();
AddMapping<UINT64>();
AddMapping<INT64>();
- AddMapping<TIMESTAMP>();
+ AddMapping<UNIXTIME_MICROS>();
AddMapping<STRING>();
AddMapping<BOOL>();
AddMapping<FLOAT>();
http://git-wip-us.apache.org/repos/asf/kudu/blob/7eaeb6d9/src/kudu/common/types.h
----------------------------------------------------------------------
diff --git a/src/kudu/common/types.h b/src/kudu/common/types.h
index 670206a..d768b79 100644
--- a/src/kudu/common/types.h
+++ b/src/kudu/common/types.h
@@ -420,7 +420,7 @@ static const char* kDateFormat = "%Y-%m-%d %H:%M:%S";
static const char* kDateMicrosAndTzFormat = "%s.%06d GMT";
template<>
-struct DataTypeTraits<TIMESTAMP> : public DerivedTypeTraits<INT64>{
+struct DataTypeTraits<UNIXTIME_MICROS> : public DerivedTypeTraits<INT64>{
static const int US_TO_S = 1000L * 1000L;
static const char* name() {
@@ -509,7 +509,7 @@ class Variant {
case UINT32:
numeric_.u32 = *static_cast<const uint32_t *>(value);
break;
- case TIMESTAMP:
+ case UNIXTIME_MICROS:
case INT64:
numeric_.i64 = *static_cast<const int64_t *>(value);
break;
@@ -579,7 +579,7 @@ class Variant {
case INT32: return &(numeric_.i32);
case UINT32: return &(numeric_.u32);
case INT64: return &(numeric_.i64);
- case TIMESTAMP: return &(numeric_.i64);
+ case UNIXTIME_MICROS: return &(numeric_.i64);
case UINT64: return &(numeric_.u64);
case FLOAT: return (&numeric_.float_val);
case DOUBLE: return (&numeric_.double_val);
http://git-wip-us.apache.org/repos/asf/kudu/blob/7eaeb6d9/src/kudu/integration-tests/all_types-itest.cc
----------------------------------------------------------------------
diff --git a/src/kudu/integration-tests/all_types-itest.cc b/src/kudu/integration-tests/all_types-itest.cc
index 76d9fa1..6dbfe36 100644
--- a/src/kudu/integration-tests/all_types-itest.cc
+++ b/src/kudu/integration-tests/all_types-itest.cc
@@ -202,7 +202,7 @@ class AllTypesItest : public KuduTest {
builder.AddColumn("int16_val")->Type(KuduColumnSchema::INT16);
builder.AddColumn("int32_val")->Type(KuduColumnSchema::INT32);
builder.AddColumn("int64_val")->Type(KuduColumnSchema::INT64);
- builder.AddColumn("timestamp_val")->Type(KuduColumnSchema::TIMESTAMP);
+ builder.AddColumn("timestamp_val")->Type(KuduColumnSchema::UNIXTIME_MICROS);
builder.AddColumn("string_val")->Type(KuduColumnSchema::STRING);
builder.AddColumn("bool_val")->Type(KuduColumnSchema::BOOL);
builder.AddColumn("float_val")->Type(KuduColumnSchema::FLOAT);
@@ -257,7 +257,7 @@ class AllTypesItest : public KuduTest {
RETURN_NOT_OK(row->SetInt16("int16_val", int_val));
RETURN_NOT_OK(row->SetInt32("int32_val", int_val));
RETURN_NOT_OK(row->SetInt64("int64_val", int_val));
- RETURN_NOT_OK(row->SetTimestamp("timestamp_val", int_val));
+ RETURN_NOT_OK(row->SetUnixTimeMicros("timestamp_val", int_val));
string content = strings::Substitute("hello $0", int_val);
Slice slice_val(content);
RETURN_NOT_OK(row->SetStringCopy("string_val", slice_val));
@@ -324,7 +324,7 @@ class AllTypesItest : public KuduTest {
ASSERT_OK(row.GetInt64("int64_val", &int64_val));
ASSERT_EQ(int64_val, expected_int_val);
int64_t timestamp_val;
- ASSERT_OK(row.GetTimestamp("timestamp_val", ×tamp_val));
+ ASSERT_OK(row.GetUnixTimeMicros("timestamp_val", ×tamp_val));
ASSERT_EQ(timestamp_val, expected_int_val);
string content = strings::Substitute("hello $0", expected_int_val);
@@ -434,7 +434,7 @@ typedef ::testing::Types<IntKeysTestSetup<KeyTypeWrapper<INT8> >,
IntKeysTestSetup<KeyTypeWrapper<INT16> >,
IntKeysTestSetup<KeyTypeWrapper<INT32> >,
IntKeysTestSetup<KeyTypeWrapper<INT64> >,
- IntKeysTestSetup<KeyTypeWrapper<TIMESTAMP> >,
+ IntKeysTestSetup<KeyTypeWrapper<UNIXTIME_MICROS> >,
SliceKeysTestSetup<KeyTypeWrapper<STRING> >,
SliceKeysTestSetup<KeyTypeWrapper<BINARY> >
> KeyTypes;
http://git-wip-us.apache.org/repos/asf/kudu/blob/7eaeb6d9/src/kudu/server/webui_util.cc
----------------------------------------------------------------------
diff --git a/src/kudu/server/webui_util.cc b/src/kudu/server/webui_util.cc
index b7aaefb..6e3ca4f 100644
--- a/src/kudu/server/webui_util.cc
+++ b/src/kudu/server/webui_util.cc
@@ -105,8 +105,8 @@ void HtmlOutputImpalaSchema(const std::string& table_name,
case INT64:
*output << "BIGINT";
break;
- case TIMESTAMP:
- *output << "TIMESTAMP";
+ case UNIXTIME_MICROS:
+ *output << "INT64";
break;
case FLOAT:
*output << "FLOAT";
[2/2] kudu git commit: KUDU-1500: Data race in
RaftConsensusITest.TestCorruptReplicaMetadata
Posted by mp...@apache.org.
KUDU-1500: Data race in RaftConsensusITest.TestCorruptReplicaMetadata
The test intends to corrupt the metadata of one of the tserver tablets.
While the cluster is in the process of resurrecting the failed tserver,
the Partition and PartitionSchema on that tserver is accessed using
TabletPeer in an unguarded manner via ListTablets RPCs.
The proposed fix here keeps the Partition and PartitionSchema immutable
after it is loaded for the very first time. These fields are never
overwritten again during tablet-copy or any other workflow.
Also a unit test is added to exercise this data race window. i.e,
the unit test aims to issue ListTablets RPCs during a follower's
tablet copy stage and provides an optimistic coverage for the fix.
DCHECKs are added to make sure the oncoming protobuf fields
match the immutable fields not updated during tablet-copy.
Testing: Spun a test TabletCopyITest.TestDeleteTabletDuringTabletCopy
which exercises this data race window, also ran original test which
caught the race in raft_consensus-itest.TestCorruptReplicaMetadata.
Change-Id: If57617e22b41296b8d4e8ad131220f1ebb235019
Reviewed-on: http://gerrit.cloudera.org:8080/3823
Tested-by: Kudu Jenkins
Reviewed-by: Mike Percy <mp...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/kudu/repo
Commit: http://git-wip-us.apache.org/repos/asf/kudu/commit/c386f73a
Tree: http://git-wip-us.apache.org/repos/asf/kudu/tree/c386f73a
Diff: http://git-wip-us.apache.org/repos/asf/kudu/diff/c386f73a
Branch: refs/heads/master
Commit: c386f73a979c06eea0a9944ce8544c7d1dcb566a
Parents: 7eaeb6d
Author: Dinesh Bhat <di...@cloudera.com>
Authored: Fri Aug 12 01:40:25 2016 -0700
Committer: Mike Percy <mp...@apache.org>
Committed: Fri Sep 9 21:25:29 2016 +0000
----------------------------------------------------------------------
src/kudu/common/partition.cc | 8 ++
src/kudu/common/partition.h | 3 +
src/kudu/integration-tests/tablet_copy-itest.cc | 94 ++++++++++++++++++++
src/kudu/tablet/tablet_metadata.cc | 40 +++++----
4 files changed, 129 insertions(+), 16 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/kudu/blob/c386f73a/src/kudu/common/partition.cc
----------------------------------------------------------------------
diff --git a/src/kudu/common/partition.cc b/src/kudu/common/partition.cc
index 6a9cf81..5b47a36 100644
--- a/src/kudu/common/partition.cc
+++ b/src/kudu/common/partition.cc
@@ -64,6 +64,14 @@ Slice Partition::range_key(const string& partition_key) const {
}
}
+bool Partition::Equals(const Partition& other) const {
+ if (this == &other) return true;
+ if (partition_key_start().compare(other.partition_key_start()) != 0) return false;
+ if (partition_key_end().compare(other.partition_key_end()) != 0) return false;
+ if (hash_buckets_ != other.hash_buckets_) return false;
+ return true;
+}
+
void Partition::ToPB(PartitionPB* pb) const {
pb->Clear();
pb->mutable_hash_buckets()->Reserve(hash_buckets_.size());
http://git-wip-us.apache.org/repos/asf/kudu/blob/c386f73a/src/kudu/common/partition.h
----------------------------------------------------------------------
diff --git a/src/kudu/common/partition.h b/src/kudu/common/partition.h
index 41a6c24..bd88978 100644
--- a/src/kudu/common/partition.h
+++ b/src/kudu/common/partition.h
@@ -66,6 +66,9 @@ class Partition {
return partition_key_end_;
}
+ // Returns true if the other partition is equivalent to this one.
+ bool Equals(const Partition& other) const;
+
// Serializes a partition into a protobuf message.
void ToPB(PartitionPB* pb) const;
http://git-wip-us.apache.org/repos/asf/kudu/blob/c386f73a/src/kudu/integration-tests/tablet_copy-itest.cc
----------------------------------------------------------------------
diff --git a/src/kudu/integration-tests/tablet_copy-itest.cc b/src/kudu/integration-tests/tablet_copy-itest.cc
index 3d85aa6..2a76d10 100644
--- a/src/kudu/integration-tests/tablet_copy-itest.cc
+++ b/src/kudu/integration-tests/tablet_copy-itest.cc
@@ -15,10 +15,12 @@
// specific language governing permissions and limitations
// under the License.
+#include <atomic>
#include <boost/optional.hpp>
#include <gflags/gflags.h>
#include <gtest/gtest.h>
#include <string>
+#include <thread>
#include <unordered_map>
#include "kudu/client/client-test-util.h"
@@ -35,10 +37,13 @@
#include "kudu/tablet/tablet_bootstrap.h"
#include "kudu/tablet/tablet_metadata.h"
#include "kudu/tserver/tablet_copy_client.h"
+#include "kudu/util/barrier.h"
#include "kudu/util/metrics.h"
#include "kudu/util/pstack_watcher.h"
#include "kudu/util/test_util.h"
+DEFINE_int32(test_num_threads, 16,
+ "Number of test threads to launch");
DEFINE_int32(test_delete_leader_num_iters, 3,
"Number of iterations to run in TestDeleteLeaderDuringTabletCopyStressTest.");
DEFINE_int32(test_delete_leader_min_rows_per_iter, 20,
@@ -247,6 +252,95 @@ TEST_F(TabletCopyITest, TestRejectRogueLeader) {
}
}
+// Perform ListTablets on a peer while peer is going through tablet copy.
+// This serves as a unit test for a tsan data race fix (KUDU-1500).
+// This test is only optimistic in that, we hope to catch the
+// state transition on the follower during the tablet-copy and thereby
+// exercising the data races observed by tsan earlier.
+//
+// Step 1: Start the cluster and pump some workload.
+// Step 2: Tombstone the tablet on a selected follower.
+// Step 3: Create some threads which issue ListTablets to that follower
+// in a loop until the follower finishes tablet copy.
+TEST_F(TabletCopyITest, TestListTabletsDuringTabletCopy) {
+ MonoDelta kTimeout = MonoDelta::FromSeconds(30);
+ const int kTsIndex = 1; // Pick a random TS.
+ NO_FATALS(StartCluster());
+
+ // Populate a tablet with some data.
+ TestWorkload workload(cluster_.get());
+ workload.Setup();
+ workload.Start();
+ while (workload.rows_inserted() < 1000) {
+ SleepFor(MonoDelta::FromMilliseconds(10));
+ }
+
+ TServerDetails* ts = ts_map_[cluster_->tablet_server(kTsIndex)->uuid()];
+ vector<ListTabletsResponsePB::StatusAndSchemaPB> tablets;
+ ASSERT_OK(WaitForNumTabletsOnTS(ts, 1, kTimeout, &tablets));
+ string tablet_id = tablets[0].tablet_status().tablet_id();
+
+ // Ensure all the servers agree before we proceed.
+ workload.StopAndJoin();
+ ASSERT_OK(WaitForServersToAgree(kTimeout, ts_map_, tablet_id,
+ workload.batches_completed()));
+
+ int leader_index;
+ int follower_index;
+ TServerDetails* leader_ts;
+ TServerDetails* follower_ts;
+
+ // Find out who is leader so that we can tombstone a follower
+ // and let the tablet copy be kicked off by the leader.
+ // We could have tombstoned the leader too and let the election ensue
+ // followed by tablet copy of the tombstoned replica. But, we can keep
+ // the test more focused this way by not triggering any election thereby
+ // reducing overall test time as well.
+ ASSERT_OK(FindTabletLeader(ts_map_, tablet_id, kTimeout, &leader_ts));
+ leader_index = cluster_->tablet_server_index_by_uuid(leader_ts->uuid());
+ follower_index = (leader_index + 1) % cluster_->num_tablet_servers();
+ follower_ts = ts_map_[cluster_->tablet_server(follower_index)->uuid()];
+
+ vector<std::thread> threads;
+ std::atomic<bool> finish(false);
+ Barrier barrier(FLAGS_test_num_threads + 1); // include main thread
+
+ // Threads to issue ListTablets RPCs to follower.
+ for (int i = 0; i < FLAGS_test_num_threads; i++) {
+ threads.emplace_back([&]() {
+ barrier.Wait();
+ do {
+ vector<ListTabletsResponsePB::StatusAndSchemaPB> tablets;
+ CHECK_OK(ListTablets(ts, MonoDelta::FromSeconds(30), &tablets));
+ } while (!finish.load(std::memory_order_relaxed));
+ });
+ }
+
+ // Wait until all ListTablets RPC threads are fired up.
+ barrier.Wait();
+
+ // Tombstone the tablet on the follower.
+ LOG(INFO) << "Tombstoning follower tablet " << tablet_id
+ << " on TS " << follower_ts->uuid();
+ ASSERT_OK(itest::DeleteTablet(follower_ts, tablet_id,
+ TABLET_DATA_TOMBSTONED,
+ boost::none, kTimeout));
+
+ // A new good copy should automatically get created via tablet copy.
+ ASSERT_OK(inspect_->WaitForTabletDataStateOnTS(
+ follower_index, tablet_id,
+ { tablet::TABLET_DATA_READY },
+ kTimeout));
+
+ // Wait for all threads to finish.
+ finish.store(true, std::memory_order_relaxed);
+ for (auto& t : threads) {
+ t.join();
+ }
+
+ NO_FATALS(cluster_->AssertNoCrashes());
+}
+
// Start tablet copy session and delete the tablet in the middle.
// It should actually be possible to complete copying in such a case, because
// when a Tablet Copy session is started on the "source" server, all of
http://git-wip-us.apache.org/repos/asf/kudu/blob/c386f73a/src/kudu/tablet/tablet_metadata.cc
----------------------------------------------------------------------
diff --git a/src/kudu/tablet/tablet_metadata.cc b/src/kudu/tablet/tablet_metadata.cc
index 71ec4a3..d3599df 100644
--- a/src/kudu/tablet/tablet_metadata.cc
+++ b/src/kudu/tablet/tablet_metadata.cc
@@ -280,7 +280,6 @@ Status TabletMetadata::LoadFromSuperBlock(const TabletSuperBlockPB& superblock)
superblock.DebugString());
}
- table_id_ = superblock.table_id();
last_durable_mrs_id_ = superblock.last_durable_mrs_id();
table_name_ = superblock.table_name();
@@ -292,25 +291,34 @@ Status TabletMetadata::LoadFromSuperBlock(const TabletSuperBlockPB& superblock)
superblock.ShortDebugString());
SetSchemaUnlocked(std::move(schema), schema_version);
- // This check provides backwards compatibility with the
- // flexible-partitioning changes introduced in KUDU-818.
- if (superblock.has_partition()) {
+ if (!superblock.has_partition()) {
+ // KUDU-818: Possible backward compatibility issue with tables created
+ // with version <= 0.5, throw warning.
+ LOG_WITH_PREFIX(WARNING) << "Upgrading from Kudu 0.5.0 directly to this"
+ << " version is not supported. Please upgrade to 0.6.0 before"
+ << " moving to a higher version.";
+ return Status::NotFound("Missing partition in superblock "+
+ superblock.DebugString());
+ }
+
+ // Some metadata fields are assumed to be immutable and thus are
+ // only read from the protobuf when the tablet metadata is loaded
+ // for the very first time. See KUDU-1500 for more details.
+ if (state_ == kNotLoadedYet) {
+ table_id_ = superblock.table_id();
RETURN_NOT_OK(PartitionSchema::FromPB(superblock.partition_schema(),
*schema_, &partition_schema_));
Partition::FromPB(superblock.partition(), &partition_);
} else {
- // This clause may be removed after compatibility with tables created
- // before KUDU-818 is not needed.
- RETURN_NOT_OK(PartitionSchema::FromPB(PartitionSchemaPB(), *schema_, &partition_schema_));
- PartitionPB partition;
- if (!superblock.has_start_key() || !superblock.has_end_key()) {
- return Status::Corruption(
- "tablet superblock must contain either a partition or start and end primary keys",
- superblock.ShortDebugString());
- }
- partition.set_partition_key_start(superblock.start_key());
- partition.set_partition_key_end(superblock.end_key());
- Partition::FromPB(partition, &partition_);
+ CHECK_EQ(table_id_, superblock.table_id());
+ PartitionSchema partition_schema;
+ RETURN_NOT_OK(PartitionSchema::FromPB(superblock.partition_schema(),
+ *schema_, &partition_schema));
+ CHECK(partition_schema_.Equals(partition_schema));
+
+ Partition partition;
+ Partition::FromPB(superblock.partition(), &partition);
+ CHECK(partition_.Equals(partition));
}
tablet_data_state_ = superblock.tablet_data_state();