hawq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hubertzh...@apache.org
Subject incubator-hawq git commit: HAWQ-562. Refactor bucket number of external table.
Date Mon, 28 Mar 2016 02:27:26 GMT
Repository: incubator-hawq
Updated Branches:
  refs/heads/master eb229d974 -> 12b029ff1


HAWQ-562. Refactor bucket number of external table.


Project: http://git-wip-us.apache.org/repos/asf/incubator-hawq/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-hawq/commit/12b029ff
Tree: http://git-wip-us.apache.org/repos/asf/incubator-hawq/tree/12b029ff
Diff: http://git-wip-us.apache.org/repos/asf/incubator-hawq/diff/12b029ff

Branch: refs/heads/master
Commit: 12b029ff1b4bf92599470e5cc3efaa243476ee12
Parents: eb229d9
Author: hzhang2 <zhanghuan929@163.com>
Authored: Mon Mar 28 10:17:17 2016 +0800
Committer: hzhang2 <zhanghuan929@163.com>
Committed: Mon Mar 28 10:17:17 2016 +0800

----------------------------------------------------------------------
 src/backend/cdb/cdbdatalocality.c |  7 ++++++-
 src/backend/commands/tablecmds.c  | 23 ++++++++++++++---------
 src/backend/postmaster/identity.c |  2 +-
 3 files changed, 21 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/12b029ff/src/backend/cdb/cdbdatalocality.c
----------------------------------------------------------------------
diff --git a/src/backend/cdb/cdbdatalocality.c b/src/backend/cdb/cdbdatalocality.c
index 4c67429..cbe1222 100644
--- a/src/backend/cdb/cdbdatalocality.c
+++ b/src/backend/cdb/cdbdatalocality.c
@@ -768,7 +768,8 @@ static void check_keep_hash_and_external_table(
 			 * whose default value is set to default_segment_num
 			 */
 			ExtTableEntry* extEnrty = GetExtTableEntry(rel->rd_id);
-			if(extEnrty->isweb){
+			if(extEnrty->command){
+				// command external table case
 				if (context->externTableOnClauseSegNum == 0) {
 					context->externTableOnClauseSegNum = targetPolicy->bucketnum;
 				} else {
@@ -782,6 +783,7 @@ static void check_keep_hash_and_external_table(
 				}
 			}
 			else{
+				// gpfdist location case.
 				if (context->externTableLocationSegNum < targetPolicy->bucketnum) {
 					context->externTableLocationSegNum = targetPolicy->bucketnum;
 					context->minimum_segment_num =  targetPolicy->bucketnum;
@@ -4256,6 +4258,9 @@ calculate_planner_segment_num(Query *query, QueryResourceLife resourceLife,
 				}
 			} else {
 				maxTargetSegmentNumber = context.randomSegNum;
+				if(context.externTableLocationSegNum > 0 && maxTargetSegmentNumber < GetQueryVsegNum()){
+					maxTargetSegmentNumber = GetQueryVsegNum();
+				}
 				minTargetSegmentNumber = context.minimum_segment_num;
 			}
 

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/12b029ff/src/backend/commands/tablecmds.c
----------------------------------------------------------------------
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index d858d5c..4595f9a 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -387,7 +387,7 @@ static void update_ri_trigger_args(Oid relid,
 					   const char *newname,
 					   bool fk_scan,
 					   bool update_relname);
-static Datum transformLocationUris(List *locs, List* fmtopts, bool isweb, bool iswritable);
+static Datum transformLocationUris(List *locs, List* fmtopts, bool isweb, bool iswritable,
bool* isCustom);
 static Datum transformExecOnClause(List	*on_clause, int *preferred_segment_num, bool iswritable);
 static char transformFormatType(char *formatname);
 static Datum transformFormatOpts(char formattype, List *formatOpts, int numcols, bool iswritable);
@@ -959,19 +959,21 @@ DefineExternalRelation(CreateExternalStmt *createExtStmt)
 	createStmt->tablespacename = NULL;
 	createStmt->policy = createExtStmt->policy; /* policy was set in transform */
 	
-		
+	bool isCustom = false;
 	switch(exttypeDesc->exttabletype)
 	{
 		case EXTTBL_TYPE_LOCATION:
 
 			/* Parse and validate URI strings (LOCATION clause) */
 			locationUris = transformLocationUris(exttypeDesc->location_list,
-												 createExtStmt->formatOpts,
-												 isweb, iswritable);
-			int locLength = list_length(exttypeDesc->location_list);
-			if (createStmt->policy && locLength > 0)
-			{
-				createStmt->policy->bucketnum = locLength;
+									 createExtStmt->formatOpts,
+									 isweb, iswritable,&isCustom);
+			if(!isCustom){
+				int locLength = list_length(exttypeDesc->location_list);
+				if (createStmt->policy && locLength > 0)
+				{
+					createStmt->policy->bucketnum = locLength;
+				}
 			}
 
 			break;
@@ -17427,7 +17429,7 @@ AtEOSubXact_on_commit_actions(bool isCommit, SubTransactionId mySubid,
  * The result is a text array but we declare it as Datum to avoid
  * including array.h in analyze.h.
  */
-static Datum transformLocationUris(List *locs, List* fmtopts, bool isweb, bool iswritable)
+static Datum transformLocationUris(List *locs, List* fmtopts, bool isweb, bool iswritable,
bool* isCustom)
 {
 	ListCell   *cell;
 	ArrayBuildState *astate;
@@ -17552,6 +17554,9 @@ static Datum transformLocationUris(List *locs, List* fmtopts, bool
isweb, bool i
 		{
 		    first_protocol = uri->protocol;
 		    first_uri = false;
+		    if(uri->protocol == URI_CUSTOM){
+		    		*isCustom = true;
+		    }
 		} 
 		    	
 

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/12b029ff/src/backend/postmaster/identity.c
----------------------------------------------------------------------
diff --git a/src/backend/postmaster/identity.c b/src/backend/postmaster/identity.c
index 02a2038..a17958b 100644
--- a/src/backend/postmaster/identity.c
+++ b/src/backend/postmaster/identity.c
@@ -562,7 +562,7 @@ GetQueryVsegNum(void)
 int
 GetExternalTablePartitionNum(void)
 {
-	return GetQueryVsegNum();
+	return GetHashDistPartitionNum();
 }
 
 int


Mime
View raw message