6
6
* Copyright (c) 1994, Regents of the University of California
7
7
*
8
8
*
9
- * $Id: nodeHash.c,v 1.33 1999/05/06 00:30:46 tgl Exp $
9
+ * $Id: nodeHash.c,v 1.34 1999/05/09 00:53:20 tgl Exp $
10
10
*
11
11
*-------------------------------------------------------------------------
12
12
*/
39
39
40
40
extern int NBuffers ;
41
41
42
- #define HJ_TEMP_NAMELEN 16 /* max length for mk_hj_temp file names */
43
-
44
- static void mk_hj_temp (char * tempname );
45
42
static int hashFunc (Datum key , int len , bool byVal );
46
43
static RelativeAddr hashTableAlloc (int size , HashJoinTable hashtable );
47
44
static void * absHashTableAlloc (int size , HashJoinTable hashtable );
@@ -72,7 +69,6 @@ ExecHash(Hash *node)
72
69
RelativeAddr * batchPos ;
73
70
int * batchSizes ;
74
71
int i ;
75
- RelativeAddr * innerbatchNames ;
76
72
77
73
/* ----------------
78
74
* get state info from node
@@ -91,8 +87,6 @@ ExecHash(Hash *node)
91
87
92
88
if (nbatch > 0 )
93
89
{ /* if needs hash partition */
94
- innerbatchNames = (RelativeAddr * ) ABSADDR (hashtable -> innerbatchNames );
95
-
96
90
/* --------------
97
91
* allocate space for the file descriptors of batch files
98
92
* then open the batch files in the current processes.
@@ -101,13 +95,7 @@ ExecHash(Hash *node)
101
95
batches = (File * ) palloc (nbatch * sizeof (File ));
102
96
for (i = 0 ; i < nbatch ; i ++ )
103
97
{
104
- #ifndef __CYGWIN32__
105
- batches [i ] = FileNameOpenFile (ABSADDR (innerbatchNames [i ]),
106
- O_CREAT | O_RDWR , 0600 );
107
- #else
108
- batches [i ] = FileNameOpenFile (ABSADDR (innerbatchNames [i ]),
109
- O_CREAT | O_RDWR | O_BINARY , 0600 );
110
- #endif
98
+ batches [i ] = OpenTemporaryFile ();
111
99
}
112
100
hashstate -> hashBatches = batches ;
113
101
batchPos = (RelativeAddr * ) ABSADDR (hashtable -> innerbatchPos );
@@ -291,7 +279,7 @@ absHashTableAlloc(int size, HashJoinTable hashtable)
291
279
* ----------------------------------------------------------------
292
280
*/
293
281
#define NTUP_PER_BUCKET 10
294
- #define FUDGE_FAC 1.5
282
+ #define FUDGE_FAC 2.0
295
283
296
284
HashJoinTable
297
285
ExecHashTableCreate (Hash * node )
@@ -310,12 +298,9 @@ ExecHashTableCreate(Hash *node)
310
298
int totalbuckets ;
311
299
int bucketsize ;
312
300
int i ;
313
- RelativeAddr * outerbatchNames ;
314
301
RelativeAddr * outerbatchPos ;
315
- RelativeAddr * innerbatchNames ;
316
302
RelativeAddr * innerbatchPos ;
317
303
int * innerbatchSizes ;
318
- RelativeAddr tempname ;
319
304
320
305
/* ----------------
321
306
* Get information about the size of the relation to be hashed
@@ -425,46 +410,32 @@ ExecHashTableCreate(Hash *node)
425
410
* allocate and initialize the outer batches
426
411
* ---------------
427
412
*/
428
- outerbatchNames = (RelativeAddr * )
429
- absHashTableAlloc (nbatch * sizeof (RelativeAddr ), hashtable );
430
413
outerbatchPos = (RelativeAddr * )
431
414
absHashTableAlloc (nbatch * sizeof (RelativeAddr ), hashtable );
432
415
for (i = 0 ; i < nbatch ; i ++ )
433
416
{
434
- tempname = hashTableAlloc (HJ_TEMP_NAMELEN , hashtable );
435
- mk_hj_temp (ABSADDR (tempname ));
436
- outerbatchNames [i ] = tempname ;
437
417
outerbatchPos [i ] = -1 ;
438
418
}
439
- hashtable -> outerbatchNames = RELADDR (outerbatchNames );
440
419
hashtable -> outerbatchPos = RELADDR (outerbatchPos );
441
420
/* ---------------
442
421
* allocate and initialize the inner batches
443
422
* ---------------
444
423
*/
445
- innerbatchNames = (RelativeAddr * )
446
- absHashTableAlloc (nbatch * sizeof (RelativeAddr ), hashtable );
447
424
innerbatchPos = (RelativeAddr * )
448
425
absHashTableAlloc (nbatch * sizeof (RelativeAddr ), hashtable );
449
426
innerbatchSizes = (int * )
450
427
absHashTableAlloc (nbatch * sizeof (int ), hashtable );
451
428
for (i = 0 ; i < nbatch ; i ++ )
452
429
{
453
- tempname = hashTableAlloc (HJ_TEMP_NAMELEN , hashtable );
454
- mk_hj_temp (ABSADDR (tempname ));
455
- innerbatchNames [i ] = tempname ;
456
430
innerbatchPos [i ] = -1 ;
457
431
innerbatchSizes [i ] = 0 ;
458
432
}
459
- hashtable -> innerbatchNames = RELADDR (innerbatchNames );
460
433
hashtable -> innerbatchPos = RELADDR (innerbatchPos );
461
434
hashtable -> innerbatchSizes = RELADDR (innerbatchSizes );
462
435
}
463
436
else
464
437
{
465
- hashtable -> outerbatchNames = (RelativeAddr ) NULL ;
466
438
hashtable -> outerbatchPos = (RelativeAddr ) NULL ;
467
- hashtable -> innerbatchNames = (RelativeAddr ) NULL ;
468
439
hashtable -> innerbatchPos = (RelativeAddr ) NULL ;
469
440
hashtable -> innerbatchSizes = (RelativeAddr ) NULL ;
470
441
}
@@ -886,15 +857,6 @@ ExecHashTableReset(HashJoinTable hashtable, int ntuples)
886
857
hashtable -> pcount = hashtable -> nprocess ;
887
858
}
888
859
889
- static void
890
- mk_hj_temp (char * tempname )
891
- {
892
- static int hjtmpcnt = 0 ;
893
-
894
- snprintf (tempname , HJ_TEMP_NAMELEN , "HJ%d.%d" , (int ) MyProcPid , hjtmpcnt );
895
- hjtmpcnt = (hjtmpcnt + 1 ) % 1000 ;
896
- }
897
-
898
860
void
899
861
ExecReScanHash (Hash * node , ExprContext * exprCtxt , Plan * parent )
900
862
{
0 commit comments