You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@phoenix.apache.org by ya...@apache.org on 2020/10/20 16:58:21 UTC
[phoenix] branch 4.x updated: PHOENIX-6170 PHOENIX_TTL spec should
be in seconds instead of milliseconds
This is an automated email from the ASF dual-hosted git repository.
yanxinyi pushed a commit to branch 4.x
in repository https://gitbox.apache.org/repos/asf/phoenix.git
The following commit(s) were added to refs/heads/4.x by this push:
new fe47d56 PHOENIX-6170 PHOENIX_TTL spec should be in seconds instead of milliseconds
fe47d56 is described below
commit fe47d566ad3da14e5512f778591643fa9e1d9d03
Author: Jacob Isaac <ji...@salesforce.com>
AuthorDate: Mon Oct 5 15:32:07 2020 -0700
PHOENIX-6170 PHOENIX_TTL spec should be in seconds instead of milliseconds
Signed-off-by: Xinyi Yan <ya...@apache.org>
---
.../java/org/apache/phoenix/end2end/ViewTTLIT.java | 24 +++++++++++++---------
.../org/apache/phoenix/schema/TableProperty.java | 6 ++++--
2 files changed, 18 insertions(+), 12 deletions(-)
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ViewTTLIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ViewTTLIT.java
index 032ad11..3a69fcb 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ViewTTLIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ViewTTLIT.java
@@ -209,7 +209,8 @@ public class ViewTTLIT extends ParallelStatsDisabledIT {
tableOptions.setTableProps("COLUMN_ENCODED_BYTES=0,MULTI_TENANT=true");
TenantViewOptions tenantViewOptions = TenantViewOptions.withDefaults();
- tenantViewOptions.setTableProps("PHOENIX_TTL=1000");
+ // Phoenix TTL is set to 120s => 120000 ms
+ tenantViewOptions.setTableProps("PHOENIX_TTL=120");
schemaBuilder
.withTableOptions(tableOptions)
.withTenantViewOptions(tenantViewOptions)
@@ -225,8 +226,8 @@ public class ViewTTLIT extends ParallelStatsDisabledIT {
// Since the PHOENIX_TTL property values are being set, we expect the view header columns to show up in regular scans too.
assertViewHeaderRowsHavePhoenixTTLRelatedCells(schemaBuilder.getTableOptions().getSchemaName(), startTime, false, 2);
// Since the PHOENIX_TTL property values are not being overriden, we expect the TTL value to be different from the global view.
- assertSyscatHavePhoenixTTLRelatedColumns(tenantId, schemaName, tenantViewName, PTableType.VIEW.getSerializedValue(), 1000);
- assertSyscatHavePhoenixTTLRelatedColumns(tenantId, schemaName, indexOnTenantViewName, PTableType.INDEX.getSerializedValue(), 1000);
+ assertSyscatHavePhoenixTTLRelatedColumns(tenantId, schemaName, tenantViewName, PTableType.VIEW.getSerializedValue(), 120000);
+ assertSyscatHavePhoenixTTLRelatedColumns(tenantId, schemaName, indexOnTenantViewName, PTableType.INDEX.getSerializedValue(), 120000);
}
@@ -245,7 +246,8 @@ public class ViewTTLIT extends ParallelStatsDisabledIT {
PhoenixTestBuilder.SchemaBuilder.GlobalViewOptions
globalViewOptions = PhoenixTestBuilder.SchemaBuilder.GlobalViewOptions.withDefaults();
- globalViewOptions.setTableProps("PHOENIX_TTL=300000");
+ // Phoenix TTL is set to 300s => 300000 ms
+ globalViewOptions.setTableProps("PHOENIX_TTL=300");
PhoenixTestBuilder.SchemaBuilder.GlobalViewIndexOptions
globalViewIndexOptions =
@@ -253,7 +255,8 @@ public class ViewTTLIT extends ParallelStatsDisabledIT {
globalViewIndexOptions.setLocal(false);
TenantViewOptions tenantViewWithOverrideOptions = TenantViewOptions.withDefaults();
- tenantViewWithOverrideOptions.setTableProps("PHOENIX_TTL=1000");
+ // Phoenix TTL is set to 120s => 120000 ms
+ tenantViewWithOverrideOptions.setTableProps("PHOENIX_TTL=120");
schemaBuilder
.withTableOptions(tableOptions)
.withGlobalViewOptions(globalViewOptions)
@@ -275,8 +278,8 @@ public class ViewTTLIT extends ParallelStatsDisabledIT {
assertSyscatHavePhoenixTTLRelatedColumns("", schemaName, globalViewName, PTableType.VIEW.getSerializedValue(), 300000);
assertSyscatHavePhoenixTTLRelatedColumns("", schemaName, indexOnGlobalViewName, PTableType.INDEX.getSerializedValue(), 300000);
// Since the PHOENIX_TTL property values are not being overriden, we expect the TTL value to be different from the global view.
- assertSyscatHavePhoenixTTLRelatedColumns(tenantId, schemaName, tenantViewName, PTableType.VIEW.getSerializedValue(), 1000);
- assertSyscatHavePhoenixTTLRelatedColumns(tenantId, schemaName, indexOnTenantViewName, PTableType.INDEX.getSerializedValue(), 1000);
+ assertSyscatHavePhoenixTTLRelatedColumns(tenantId, schemaName, tenantViewName, PTableType.VIEW.getSerializedValue(), 120000);
+ assertSyscatHavePhoenixTTLRelatedColumns(tenantId, schemaName, indexOnTenantViewName, PTableType.INDEX.getSerializedValue(), 120000);
// Without override
startTime = System.currentTimeMillis();
@@ -381,7 +384,8 @@ public class ViewTTLIT extends ParallelStatsDisabledIT {
String tenantURL = getUrl() + ';' + TENANT_ID_ATTRIB + '=' + tenantId;
try (Connection connection = DriverManager.getConnection(tenantURL)) {
Statement stmt = connection.createStatement();
- String sql = String.format(ALTER_PHOENIX_TTL_SQL, schemaName, tenantViewName, 1000);
+ // Phoenix TTL is set to 120s => 120000 ms
+ String sql = String.format(ALTER_PHOENIX_TTL_SQL, schemaName, tenantViewName, 120);
stmt.execute(sql);
}
@@ -389,8 +393,8 @@ public class ViewTTLIT extends ParallelStatsDisabledIT {
// Since the PHOENIX_TTL property values are being set, we expect the view header columns to show up in regular scans too.
assertViewHeaderRowsHavePhoenixTTLRelatedCells(schemaBuilder.getTableOptions().getSchemaName(), startTime, false, 2);
// Since the PHOENIX_TTL property values are not being overriden, we expect the TTL value to be different from the global view.
- assertSyscatHavePhoenixTTLRelatedColumns(tenantId, schemaName, tenantViewName, PTableType.VIEW.getSerializedValue(), 1000);
- assertSyscatHavePhoenixTTLRelatedColumns(tenantId, schemaName, indexOnTenantViewName, PTableType.INDEX.getSerializedValue(), 1000);
+ assertSyscatHavePhoenixTTLRelatedColumns(tenantId, schemaName, tenantViewName, PTableType.VIEW.getSerializedValue(), 120000);
+ assertSyscatHavePhoenixTTLRelatedColumns(tenantId, schemaName, indexOnTenantViewName, PTableType.INDEX.getSerializedValue(), 120000);
}
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/schema/TableProperty.java b/phoenix-core/src/main/java/org/apache/phoenix/schema/TableProperty.java
index 7853576..7fbbc95 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/schema/TableProperty.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/TableProperty.java
@@ -260,8 +260,10 @@ public enum TableProperty {
} else if ("NONE".equalsIgnoreCase(strValue)) {
return PHOENIX_TTL_NOT_DEFINED;
}
- } else {
- return value == null ? null : ((Number) value).longValue();
+ } else if (value != null) {
+ long valueInSeconds = ((Number) value).longValue();
+ // Value is specified in seconds, so convert it to ms.
+ return valueInSeconds * 1000;
}
return value;
}