hawq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From h...@apache.org
Subject incubator-hawq git commit: HAWQ-588. Improve performance for truncate with small table
Date Fri, 25 Mar 2016 02:11:18 GMT
Repository: incubator-hawq
Updated Branches:
  refs/heads/master 1c4388a4f -> 90e3dd470


HAWQ-588. Improve performance for truncate with small 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/90e3dd47
Tree: http://git-wip-us.apache.org/repos/asf/incubator-hawq/tree/90e3dd47
Diff: http://git-wip-us.apache.org/repos/asf/incubator-hawq/diff/90e3dd47

Branch: refs/heads/master
Commit: 90e3dd4700c857971020e3f63550e2eb43e4c149
Parents: 1c4388a
Author: Ruilong Huo <rhuo@pivotal.io>
Authored: Thu Mar 24 01:43:19 2016 -0700
Committer: Ruilong Huo <rhuo@pivotal.io>
Committed: Thu Mar 24 19:10:16 2016 -0700

----------------------------------------------------------------------
 src/backend/catalog/catalog.c | 29 +++--------------------------
 src/backend/storage/file/fd.c | 29 +++++++++++++++++++++++++++++
 src/include/storage/fd.h      |  2 ++
 3 files changed, 34 insertions(+), 26 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/90e3dd47/src/backend/catalog/catalog.c
----------------------------------------------------------------------
diff --git a/src/backend/catalog/catalog.c b/src/backend/catalog/catalog.c
index dd10dc2..45aa9bb 100755
--- a/src/backend/catalog/catalog.c
+++ b/src/backend/catalog/catalog.c
@@ -1052,8 +1052,7 @@ GetNewRelFileNode(Oid reltablespace, bool relisshared, Relation pg_class,
bool i
 {
 	RelFileNode rnode;
 	char	   *rpath;
-	int			fd;
-	bool		collides;
+	bool		exist = false;
 
 	/* This should match RelationInitPhysicalAddr */
 	if (isAo && reltablespace == InvalidOid)
@@ -1077,32 +1076,10 @@ GetNewRelFileNode(Oid reltablespace, bool relisshared, Relation pg_class,
bool i
 
 		/* Check for existing file of same name */
 		rpath = relpath(rnode);
-		fd = PathNameOpenFile(rpath, O_RDONLY | PG_BINARY, 0);
-
-		if (fd >= 0)
-		{
-			/* definite collision */
-			gp_retry_close(fd);
-			collides = true;
-		}
-		else
-		{
-			/*
-			 * Here we have a little bit of a dilemma: if errno is something
-			 * other than ENOENT, should we declare a collision and loop? In
-			 * particular one might think this advisable for, say, EPERM.
-			 * However there really shouldn't be any unreadable files in a
-			 * tablespace directory, and if the EPERM is actually complaining
-			 * that we can't read the directory itself, we'd be in an infinite
-			 * loop.  In practice it seems best to go ahead regardless of the
-			 * errno.  If there is a colliding file we will get an smgr
-			 * failure when we attempt to create the new relation file.
-			 */
-			collides = false;
-		}
+		exist = PathExist(rpath);
 
 		pfree(rpath);
-	} while (collides);
+	} while (exist);
 	
 	if (!gp_upgrade_mode && Gp_role == GP_ROLE_EXECUTE)
 		Insist(!PointerIsValid(pg_class));

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/90e3dd47/src/backend/storage/file/fd.c
----------------------------------------------------------------------
diff --git a/src/backend/storage/file/fd.c b/src/backend/storage/file/fd.c
index e550307..e71282a 100644
--- a/src/backend/storage/file/fd.c
+++ b/src/backend/storage/file/fd.c
@@ -975,6 +975,35 @@ FileInvalidate(File file)
 }
 #endif
 
+bool
+PathExist(char *fileName)
+{
+	Assert(fileName);
+
+	if (IsLocalPath(fileName))
+	{
+		return LocalPathExist(fileName);
+	}
+	else
+	{
+		return HdfsPathExist(fileName);
+	}
+}
+
+bool
+LocalPathExist(char *fileName)
+{
+	Assert(fileName);
+
+	if( access( fileName, F_OK ) != -1 )
+	{
+		return true;
+	}
+	else
+	{
+		return false;
+	}
+}
 
 /*
  * open a file in an arbitrary directory

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/90e3dd47/src/include/storage/fd.h
----------------------------------------------------------------------
diff --git a/src/include/storage/fd.h b/src/include/storage/fd.h
index d611894..3e0782d 100644
--- a/src/include/storage/fd.h
+++ b/src/include/storage/fd.h
@@ -89,6 +89,7 @@ extern int64 LocalFileSeek(File file, int64 offset, int whence);
 extern int LocalFileSync(File file);
 extern int LocalRemovePath(FileName fileName, int recursive);
 extern int LocalFileTruncate(File file, int64 offset);
+extern bool LocalPathExist(char *path);
 
 /* access hdfs file system */
 extern int HdfsParsePath(const char * path, char **protocol, char **host, int *port, short
*replica);
@@ -140,6 +141,7 @@ extern int64 FileNonVirtualTell(File file);
 extern int	FileTruncate(File file, int64 offset);
 extern int  PathFileTruncate(FileName fileName);
 extern int64 FileDiskSize(File file);
+extern bool PathExist(char *path);
 
 /* Operations that allow use of regular stdio --- USE WITH CAUTION */
 extern FILE *AllocateFile(const char *name, const char *mode);


Mime
View raw message