Merge remote-tracking branch 'upstream/master' into PHOENIX-3534

Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/7420ae3a
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/7420ae3a
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/7420ae3a

Branch: refs/heads/system-catalog
Commit: 7420ae3aaf6c8a02c17dedb155a29bbd9d333203
Parents: 0f58bc9 d10151e
Author: Thomas D'Silva <tdsi...@apache.org>
Authored: Mon Apr 30 10:39:24 2018 -0700
Committer: Thomas D'Silva <tdsi...@apache.org>
Committed: Mon Apr 30 10:39:24 2018 -0700

----------------------------------------------------------------------
 .../src/build/components/all-common-files.xml   |   5 +
 phoenix-assembly/src/build/src.xml              |   7 +-
 .../apache/phoenix/end2end/AlterTableIT.java    |  12 +-
 .../phoenix/end2end/AlterTableWithViewsIT.java  |  22 ++
 .../end2end/ExplainPlanWithStatsEnabledIT.java  |  49 +++-
 .../phoenix/tx/ParameterizedTransactionIT.java  |  37 +--
 .../coprocessor/MetaDataEndpointImpl.java       |  28 +-
 .../phoenix/coprocessor/MetaDataProtocol.java   |   1 -
 .../org/apache/phoenix/execute/ScanPlan.java    |   4 +-
 .../phoenix/iterate/BaseResultIterators.java    |  50 +++-
 .../phoenix/iterate/ParallelIterators.java      |   8 +
 .../apache/phoenix/iterate/SerialIterators.java |  13 +-
 .../phoenix/jdbc/PhoenixDatabaseMetaData.java   |   1 +
 .../query/ConnectionQueryServicesImpl.java      |  24 +-
 .../query/ConnectionlessQueryServicesImpl.java  |   7 +-
 .../apache/phoenix/query/QueryConstants.java    | 107 ++++----
 .../apache/phoenix/schema/MetaDataClient.java   |  22 +-
 .../SplitOnLeadingVarCharColumnsPolicy.java     |  43 +++
 .../schema/SystemFunctionSplitPolicy.java       |  27 ++
 .../phoenix/schema/SystemStatsSplitPolicy.java  |  27 ++
 .../apache/phoenix/schema/TableProperty.java    | 270 ++++++++++---------
 .../phoenix/schema/stats/StatisticsUtil.java    |   6 +
 .../phoenix/schema/SystemSplitPolicyTest.java   |  97 +++++++
 .../apache/phoenix/hive/HivePhoenixStoreIT.java |  27 ++
 .../PhoenixStorageHandlerConstants.java         |   8 +-
 .../phoenix/hive/query/PhoenixQueryBuilder.java |   4 +-
 .../pherf/configuration/XMLConfigParser.java    |   2 +-
 .../pherf/result/impl/XMLResultHandler.java     |  18 +-
 28 files changed, 664 insertions(+), 262 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/phoenix/blob/7420ae3a/phoenix-core/src/it/java/org/apache/phoenix/end2end/AlterTableIT.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/phoenix/blob/7420ae3a/phoenix-core/src/it/java/org/apache/phoenix/end2end/AlterTableWithViewsIT.java
----------------------------------------------------------------------
diff --cc 
phoenix-core/src/it/java/org/apache/phoenix/end2end/AlterTableWithViewsIT.java
index 1d6e786,e1b1372..0e926f0
--- 
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/AlterTableWithViewsIT.java
+++ 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/AlterTableWithViewsIT.java
@@@ -40,14 -40,14 +41,16 @@@ import org.apache.hadoop.hbase.util.Byt
  import org.apache.phoenix.coprocessor.TephraTransactionalProcessor;
  import org.apache.phoenix.exception.SQLExceptionCode;
  import org.apache.phoenix.jdbc.PhoenixConnection;
+ import org.apache.phoenix.jdbc.PhoenixDatabaseMetaData;
  import org.apache.phoenix.query.QueryConstants;
 +import org.apache.phoenix.schema.PColumn;
  import org.apache.phoenix.schema.PName;
  import org.apache.phoenix.schema.PNameFactory;
  import org.apache.phoenix.schema.PTable;
  import org.apache.phoenix.schema.PTableKey;
  import org.apache.phoenix.schema.PTableType;
 +import org.apache.phoenix.util.PhoenixRuntime;
+ import org.apache.phoenix.util.StringUtil;
  import org.junit.Test;
  import org.junit.runner.RunWith;
  import org.junit.runners.Parameterized;

http://git-wip-us.apache.org/repos/asf/phoenix/blob/7420ae3a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ExplainPlanWithStatsEnabledIT.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/phoenix/blob/7420ae3a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataEndpointImpl.java
----------------------------------------------------------------------
diff --cc 
phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataEndpointImpl.java
index 06c9aa9,b77f113..454bcda
--- 
a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataEndpointImpl.java
+++ 
b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataEndpointImpl.java
@@@ -584,8 -591,9 +588,8 @@@ public class MetaDataEndpointImpl exten
                  builder.setTable(PTableImpl.toProto(table));
              }
              done.run(builder.build());
 -            return;
          } catch (Throwable t) {
-               logger.error("getTable failed", t);
+             logger.error("getTable failed", t);
              ProtobufUtil.setControllerException(controller,
                  
ServerUtil.createIOException(SchemaUtil.getTableName(schemaName, tableName), 
t));
          }
@@@ -2807,32 -2544,45 +2810,43 @@@
                  }
              }
          }
 -        // Sort the puts by ordinal position 
 +        // Sort the puts by ordinal position
          Collections.sort(columnPutsForBaseTable);
 -        for (ViewInfo viewInfo : childViewsResult.getViewInfoList()) {
 -            short deltaNumPkColsSoFar = 0;
 -            short columnsAddedToView = 0;
 -            short columnsAddedToBaseTable = 0;
 +        for (TableInfo viewInfo : childViewsResult.getResults()) {
+             byte[] tenantId = viewInfo.getTenantId();
+             byte[] schema = viewInfo.getSchemaName();
 -            byte[] table = viewInfo.getViewName();
 -            byte[] viewKey = SchemaUtil.getTableKey(tenantId, schema, table);
 -            
 -            // lock the rows corresponding to views so that no other thread 
can modify the view meta-data
 -            RowLock viewRowLock = acquireLock(region, viewKey, locks);
 -            PTable view = doGetTable(viewKey, clientTimeStamp, viewRowLock, 
clientVersion);
++            byte[] table = viewInfo.getTableName();
 +            byte[] viewKey = SchemaUtil.getTableKey(viewInfo.getTenantId(), 
viewInfo.getSchemaName(), viewInfo.getTableName());
 +            PTable view = doGetTable(viewKey, clientTimeStamp, clientVersion);
+             if (view == null) {
+                 logger.warn("Found orphan tenant view row in SYSTEM.CATALOG 
with tenantId:"
+                     + Bytes.toString(tenantId) + ", schema:"
+                     + Bytes.toString(schema) + ", table:"
+                     + Bytes.toString(table));
+                 continue;
+              }
+             
 -            ColumnOrdinalPositionUpdateList ordinalPositionList = new 
ColumnOrdinalPositionUpdateList();
 +
 +            // add the new columns to the child view
              List<PColumn> viewPkCols = new ArrayList<>(view.getPKColumns());
              boolean addingExistingPkCol = false;
 -            int numCols = view.getColumns().size();
 -            // add the new columns to the child view
              for (PutWithOrdinalPosition p : columnPutsForBaseTable) {
 -                Put baseTableColumnPut = p.put;
 +                Put columnToBeAdded = p.put;
                  PColumn existingViewColumn = null;
                  byte[][] rkmd = new byte[5][];
 -                getVarChars(baseTableColumnPut.getRow(), rkmd);
 +                getVarChars(columnToBeAdded.getRow(), rkmd);
                  String columnName = Bytes.toString(rkmd[COLUMN_NAME_INDEX]);
 -                String columnFamily = rkmd[FAMILY_NAME_INDEX] == null ? null 
: Bytes.toString(rkmd[FAMILY_NAME_INDEX]);
 +                String columnFamily =
 +                        rkmd[FAMILY_NAME_INDEX] == null ? null
 +                                : Bytes.toString(rkmd[FAMILY_NAME_INDEX]);
                  try {
 -                    existingViewColumn = columnFamily == null ? 
view.getColumnForColumnName(columnName) : view.getColumnFamily(
 -                            columnFamily).getPColumnForColumnName(columnName);
 +                    existingViewColumn =
 +                            columnFamily == null ? 
view.getColumnForColumnName(columnName)
 +                                    : view.getColumnFamily(columnFamily)
 +                                            
.getPColumnForColumnName(columnName);
                  } catch (ColumnFamilyNotFoundException e) {
 -                    // ignore since it means that the column family is not 
present for the column to be added.
 +                    // ignore since it means that the column family is not 
present for the column to
 +                    // be added.
                  } catch (ColumnNotFoundException e) {
                      // ignore since it means the column is not present in the 
view
                  }

http://git-wip-us.apache.org/repos/asf/phoenix/blob/7420ae3a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataProtocol.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/phoenix/blob/7420ae3a/phoenix-core/src/main/java/org/apache/phoenix/jdbc/PhoenixDatabaseMetaData.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/phoenix/blob/7420ae3a/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java
----------------------------------------------------------------------
diff --cc 
phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java
index 45016c6,1d3feed..448382a
--- 
a/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java
+++ 
b/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java
@@@ -2471,13 -2471,8 +2473,13 @@@ public class ConnectionQueryServicesImp
  
      // Available for testing
      protected String getLogTableDDL() {
-         return setSystemLogDDLProperties(QueryConstants.CREATE_LOG_METADATA);
+         return QueryConstants.CREATE_LOG_METADATA;
      }
 +    
 +    // Available for testing
 +    protected String getChildLinkDDL() {
 +        return 
setSystemDDLProperties(QueryConstants.CREATE_CHILD_LINK_METADATA);
 +    }
  
      private String setSystemDDLProperties(String ddl) {
          return String.format(ddl,
@@@ -2964,12 -2951,22 +2961,27 @@@
                MetaDataProtocol.MIN_SYSTEM_TABLE_TIMESTAMP_4_14_0,
                PhoenixDatabaseMetaData.TRANSACTION_PROVIDER + " "
                  + PTinyint.INSTANCE.getSqlTypeName());
+             metaConnection.createStatement().executeUpdate("ALTER TABLE " + 
+                     PhoenixDatabaseMetaData.SYSTEM_CATALOG + " SET " + 
+                     HConstants.VERSIONS + "= " + 
props.getInt(DEFAULT_SYSTEM_MAX_VERSIONS_ATTRIB, 
QueryServicesOptions.DEFAULT_SYSTEM_MAX_VERSIONS) + ",\n" +
+                     HColumnDescriptor.KEEP_DELETED_CELLS + "=" + 
props.getBoolean(DEFAULT_SYSTEM_KEEP_DELETED_CELLS_ATTRIB, 
QueryServicesOptions.DEFAULT_SYSTEM_KEEP_DELETED_CELLS)
+                     );
+             metaConnection.createStatement().executeUpdate("ALTER TABLE " + 
+                 PhoenixDatabaseMetaData.SYSTEM_FUNCTION + " SET " + 
+                     HTableDescriptor.SPLIT_POLICY + "='" + 
SystemFunctionSplitPolicy.class.getName() + "',\n" +
+                     HConstants.VERSIONS + "= " + 
props.getInt(DEFAULT_SYSTEM_MAX_VERSIONS_ATTRIB, 
QueryServicesOptions.DEFAULT_SYSTEM_MAX_VERSIONS) + ",\n" +
+                     HColumnDescriptor.KEEP_DELETED_CELLS + "=" + 
props.getBoolean(DEFAULT_SYSTEM_KEEP_DELETED_CELLS_ATTRIB, 
QueryServicesOptions.DEFAULT_SYSTEM_KEEP_DELETED_CELLS)
+                     );
+             metaConnection.createStatement().executeUpdate("ALTER TABLE " + 
+                     PhoenixDatabaseMetaData.SYSTEM_STATS_NAME + " SET " + 
+                     HTableDescriptor.SPLIT_POLICY + "='" + 
SystemStatsSplitPolicy.class.getName() +"'"
+                     );
          }
 +        // TODO set the version for which the following upgrade code runs 
correct
 +        if (currentServerSideTableTimeStamp < 
MetaDataProtocol.MIN_SYSTEM_TABLE_TIMESTAMP_4_14_0) {
 +            addViewIndexToParentLinks(metaConnection);
 +            moveChildLinks(metaConnection);
 +        }
          return metaConnection;
      }
  

http://git-wip-us.apache.org/repos/asf/phoenix/blob/7420ae3a/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionlessQueryServicesImpl.java
----------------------------------------------------------------------
diff --cc 
phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionlessQueryServicesImpl.java
index 0fdf5e6,3531a87..11e33e9
--- 
a/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionlessQueryServicesImpl.java
+++ 
b/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionlessQueryServicesImpl.java
@@@ -164,12 -164,8 +164,12 @@@ public class ConnectionlessQueryService
      }
  
      protected String getLogTableDDL() {
-         return setSystemLogDDLProperties(QueryConstants.CREATE_LOG_METADATA);
+         return QueryConstants.CREATE_LOG_METADATA;
      }
 +    
 +    protected String getChildLinkDDL() {
 +        return 
setSystemDDLProperties(QueryConstants.CREATE_CHILD_LINK_METADATA);
 +    }
  
      private String setSystemDDLProperties(String ddl) {
          return String.format(ddl,

http://git-wip-us.apache.org/repos/asf/phoenix/blob/7420ae3a/phoenix-core/src/main/java/org/apache/phoenix/query/QueryConstants.java
----------------------------------------------------------------------
diff --cc 
phoenix-core/src/main/java/org/apache/phoenix/query/QueryConstants.java
index aa37517,2fe7b14..97acba0
--- a/phoenix-core/src/main/java/org/apache/phoenix/query/QueryConstants.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/query/QueryConstants.java
@@@ -10,7 -17,113 +10,8 @@@
   */
  package org.apache.phoenix.query;
  
+ 
 -import static 
org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.APPEND_ONLY_SCHEMA;
 -import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.ARG_POSITION;
 -import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.ARRAY_SIZE;
 -import static 
org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.AUTO_PARTITION_SEQ;
 -import static 
org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.BASE_COLUMN_COUNT;
 -import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.BIND_PARAMETERS;
 -import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.BUFFER_LENGTH;
 -import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.CACHE_SIZE;
 -import static 
org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.CHAR_OCTET_LENGTH;
 -import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.CLASS_NAME;
 -import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.CLIENT_IP;
 -import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.COLUMN_COUNT;
 -import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.COLUMN_DEF;
 -import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.COLUMN_FAMILY;
 -import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.COLUMN_NAME;
 -import static 
org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.COLUMN_QUALIFIER;
 -import static 
org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.COLUMN_QUALIFIER_COUNTER;
 -import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.COLUMN_SIZE;
 -import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.CURRENT_VALUE;
 -import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.CYCLE_FLAG;
 -import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.DATA_TABLE_NAME;
 -import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.DATA_TYPE;
 -import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.DECIMAL_DIGITS;
 -import static 
org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.DEFAULT_COLUMN_FAMILY_NAME;
 -import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.DEFAULT_VALUE;
 -import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.DISABLE_WAL;
 -import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.ENCODING_SCHEME;
 -import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.EXCEPTION_TRACE;
 -import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.EXPLAIN_PLAN;
 -import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.FUNCTION_NAME;
 -import static 
org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.GLOBAL_SCAN_DETAILS;
 -import static 
org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.GUIDE_POSTS_ROW_COUNT;
 -import static 
org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.GUIDE_POSTS_WIDTH;
 -import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.GUIDE_POST_KEY;
 -import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.IMMUTABLE_ROWS;
 -import static 
org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.IMMUTABLE_STORAGE_SCHEME;
 -import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.INCREMENT_BY;
 -import static 
org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.INDEX_DISABLE_TIMESTAMP;
 -import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.INDEX_STATE;
 -import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.INDEX_TYPE;
 -import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.IS_ARRAY;
 -import static 
org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.IS_AUTOINCREMENT;
 -import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.IS_CONSTANT;
 -import static 
org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.IS_NAMESPACE_MAPPED;
 -import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.IS_NULLABLE;
 -import static 
org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.IS_ROW_TIMESTAMP;
 -import static 
org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.IS_VIEW_REFERENCED;
 -import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.JAR_PATH;
 -import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.KEY_SEQ;
 -import static 
org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.LAST_STATS_UPDATE_TIME;
 -import static 
org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.LIMIT_REACHED_FLAG;
 -import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.LINK_TYPE;
 -import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.MAX_VALUE;
 -import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.MIN_VALUE;
 -import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.MULTI_TENANT;
 -import static 
org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.NO_OF_RESULTS_ITERATED;
 -import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.NULLABLE;
 -import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.NUM_ARGS;
 -import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.NUM_PREC_RADIX;
 -import static 
org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.ORDINAL_POSITION;
 -import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.PHYSICAL_NAME;
 -import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.PK_NAME;
 -import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.QUERY;
 -import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.QUERY_ID;
 -import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.QUERY_STATUS;
 -import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.REF_GENERATION;
 -import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.REMARKS;
 -import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.RETURN_TYPE;
 -import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.SALT_BUCKETS;
 -import static 
org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.SCAN_METRICS_JSON;
 -import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.SCOPE_CATALOG;
 -import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.SCOPE_SCHEMA;
 -import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.SCOPE_TABLE;
 -import static 
org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.SELF_REFERENCING_COL_NAME;
 -import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.SEQUENCE_NAME;
 -import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.SEQUENCE_SCHEMA;
 -import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.SORT_ORDER;
 -import static 
org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.SOURCE_DATA_TYPE;
 -import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.SQL_DATA_TYPE;
 -import static 
org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.SQL_DATETIME_SUB;
 -import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.START_TIME;
 -import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.START_WITH;
 -import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.STORE_NULLS;
 -import static 
org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.SYSTEM_CATALOG_SCHEMA;
 -import static 
org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.SYSTEM_CATALOG_TABLE;
 -import static 
org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.SYSTEM_FUNCTION_TABLE;
 -import static 
org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.SYSTEM_LOG_TABLE;
 -import static 
org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.SYSTEM_STATS_TABLE;
 -import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.TABLE_NAME;
 -import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.TABLE_SCHEM;
 -import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.TABLE_SEQ_NUM;
 -import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.TABLE_TYPE;
 -import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.TENANT_ID;
 -import static 
org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.TOTAL_EXECUTION_TIME;
 -import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.TRANSACTIONAL;
 -import static 
org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.TRANSACTION_PROVIDER;
 -import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.TYPE;
 -import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.TYPE_NAME;
 -import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.TYPE_SEQUENCE;
 -import static 
org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.UPDATE_CACHE_FREQUENCY;
 -import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.USER;
 -import static 
org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.USE_STATS_FOR_PARALLELIZATION;
 -import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.VIEW_CONSTANT;
 -import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.VIEW_INDEX_ID;
 -import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.VIEW_STATEMENT;
 -import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.VIEW_TYPE;
 +import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.*;
  
  import java.math.BigDecimal;
  
@@@ -26,10 -139,16 +27,12 @@@ import org.apache.phoenix.schema.PName
  import org.apache.phoenix.schema.PNameFactory;
  import org.apache.phoenix.schema.PTable.QualifierEncodingScheme;
  import org.apache.phoenix.schema.SortOrder;
+ import org.apache.phoenix.schema.SystemFunctionSplitPolicy;
+ import org.apache.phoenix.schema.SystemStatsSplitPolicy;
  import org.apache.phoenix.schema.TableProperty;
  
 -
  /**
 - *
   * Constants used during querying
 - *
 - *
   * @since 0.1
   */
  public interface QueryConstants {
@@@ -219,27 -354,35 +222,30 @@@
      public static final String CREATE_STATS_TABLE_METADATA =
              "CREATE TABLE " + SYSTEM_CATALOG_SCHEMA + ".\"" + 
SYSTEM_STATS_TABLE + "\"(\n" +
              // PK columns
-                     PHYSICAL_NAME + " VARCHAR NOT NULL," + COLUMN_FAMILY + " 
VARCHAR,"
-                     + GUIDE_POST_KEY + " VARBINARY," + GUIDE_POSTS_WIDTH + " 
BIGINT,"
-                     + LAST_STATS_UPDATE_TIME + " DATE, " + 
GUIDE_POSTS_ROW_COUNT + " BIGINT, "
-                     + "CONSTRAINT " + SYSTEM_TABLE_PK_NAME + " PRIMARY KEY (" 
+ PHYSICAL_NAME + ","
-                     + COLUMN_FAMILY + "," + GUIDE_POST_KEY + "))\n" +
-                     // Install split policy to prevent a physical table's 
stats from being split
-                     // across regions.
-                     HTableDescriptor.SPLIT_POLICY + "='" + 
MetaDataSplitPolicy.class.getName()
-                     + "',\n" + PhoenixDatabaseMetaData.TRANSACTIONAL + "=" + 
Boolean.FALSE;
+             PHYSICAL_NAME  + " VARCHAR NOT NULL," +
+             COLUMN_FAMILY + " VARCHAR," +
+             GUIDE_POST_KEY  + " VARBINARY," +
+             GUIDE_POSTS_WIDTH + " BIGINT," +
+             LAST_STATS_UPDATE_TIME+ " DATE, "+
+             GUIDE_POSTS_ROW_COUNT+ " BIGINT, "+
+             "CONSTRAINT " + SYSTEM_TABLE_PK_NAME + " PRIMARY KEY ("
+             + PHYSICAL_NAME + ","
+             + COLUMN_FAMILY + ","+ GUIDE_POST_KEY+"))\n" +
+             // Install split policy to prevent a physical table's stats from 
being split across regions.
+             HTableDescriptor.SPLIT_POLICY + "='" + 
SystemStatsSplitPolicy.class.getName() + "',\n" + 
+             PhoenixDatabaseMetaData.TRANSACTIONAL + "=" + Boolean.FALSE;
  
      public static final String CREATE_SEQUENCE_METADATA =
 -            "CREATE TABLE " + SYSTEM_CATALOG_SCHEMA + ".\"" + TYPE_SEQUENCE + 
"\"(\n" +
 -            TENANT_ID + " VARCHAR NULL," +
 -            SEQUENCE_SCHEMA + " VARCHAR NULL, \n" +
 -            SEQUENCE_NAME +  " VARCHAR NOT NULL, \n" +
 -            START_WITH + " BIGINT, \n" +
 -            CURRENT_VALUE + " BIGINT, \n" +
 -            INCREMENT_BY  + " BIGINT, \n" +
 -            CACHE_SIZE  + " BIGINT, \n" +
 -            //  the following three columns were added in 3.1/4.1
 -            MIN_VALUE + " BIGINT, \n" +
 -            MAX_VALUE + " BIGINT, \n" +
 -            CYCLE_FLAG + " BOOLEAN, \n" +
 -            LIMIT_REACHED_FLAG + " BOOLEAN \n" +
 -            " CONSTRAINT " + SYSTEM_TABLE_PK_NAME + " PRIMARY KEY (" + 
TENANT_ID + "," + SEQUENCE_SCHEMA + "," + SEQUENCE_NAME + "))\n" +
 -            PhoenixDatabaseMetaData.TRANSACTIONAL + "=" + Boolean.FALSE;
 +            "CREATE TABLE " + SYSTEM_CATALOG_SCHEMA + ".\"" + TYPE_SEQUENCE + 
"\"(\n" + TENANT_ID
 +                    + " VARCHAR NULL," + SEQUENCE_SCHEMA + " VARCHAR NULL, 
\n" + SEQUENCE_NAME
 +                    + " VARCHAR NOT NULL, \n" + START_WITH + " BIGINT, \n" + 
CURRENT_VALUE
 +                    + " BIGINT, \n" + INCREMENT_BY + " BIGINT, \n" + 
CACHE_SIZE + " BIGINT, \n" +
 +                    // the following three columns were added in 3.1/4.1
 +                    MIN_VALUE + " BIGINT, \n" + MAX_VALUE + " BIGINT, \n" + 
CYCLE_FLAG
 +                    + " BOOLEAN, \n" + LIMIT_REACHED_FLAG + " BOOLEAN \n" + " 
CONSTRAINT "
 +                    + SYSTEM_TABLE_PK_NAME + " PRIMARY KEY (" + TENANT_ID + 
"," + SEQUENCE_SCHEMA
 +                    + "," + SEQUENCE_NAME + "))\n" + 
PhoenixDatabaseMetaData.TRANSACTIONAL + "="
 +                    + Boolean.FALSE;
      public static final String CREATE_SYSTEM_SCHEMA = "CREATE SCHEMA " + 
SYSTEM_CATALOG_SCHEMA;
      public static final String UPGRADE_TABLE_SNAPSHOT_PREFIX = 
"_UPGRADING_TABLE_";
  

http://git-wip-us.apache.org/repos/asf/phoenix/blob/7420ae3a/phoenix-core/src/main/java/org/apache/phoenix/schema/MetaDataClient.java
----------------------------------------------------------------------

Reply via email to