Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit855754c

Browse files
author
Alexandra Pervushina
committed
Add fss_neighbours hash table
1 parent4041b10 commit855754c

File tree

4 files changed

+48
-3
lines changed

4 files changed

+48
-3
lines changed

‎aqo--1.4--1.5.sql‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ DROP TABLE public.aqo_query_texts CASCADE;
2121
DROPTABLEpublic.aqo_query_stat CASCADE;
2222
DROPFUNCTION invalidate_deactivated_queries_cache;
2323

24-
2524
/*
2625
* VIEWs to discover AQO data.
2726
*/
@@ -63,7 +62,9 @@ CREATE FUNCTION aqo_data (
6362
OUT featuresdouble precision[][],
6463
OUT targetsdouble precision[],
6564
OUT reliabilitydouble precision[],
66-
OUT oidsOid[]
65+
OUT oidsOid[],
66+
OUT prev_fsbigint,
67+
OUT next_fsbigint
6768
)
6869
RETURNS SETOF record
6970
AS'MODULE_PATHNAME','aqo_data'

‎aqo_shared.c‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ aqo_init_shmem(void)
182182
qtexts_htab=NULL;
183183
data_htab=NULL;
184184
queries_htab=NULL;
185+
fss_neighbours=NULL;
185186

186187
LWLockAcquire(AddinShmemInitLock,LW_EXCLUSIVE);
187188
aqo_state=ShmemInitStruct("AQO",sizeof(AQOSharedState),&found);
@@ -207,6 +208,7 @@ aqo_init_shmem(void)
207208
LWLockInitialize(&aqo_state->queries_lock,LWLockNewTrancheId());
208209
}
209210

211+
/* Init shared memory hash for partial aqo data table*/
210212
info.keysize=sizeof(htab_key);
211213
info.entrysize=sizeof(htab_entry);
212214
fss_htab=ShmemInitHash("AQO hash",
@@ -237,6 +239,12 @@ aqo_init_shmem(void)
237239
queries_htab=ShmemInitHash("AQO Queries HTAB",fs_max_items,fs_max_items,
238240
&info,HASH_ELEM |HASH_BLOBS);
239241

242+
/* Shared memory hash table for fss neighbours */
243+
info.keysize=sizeof(int);
244+
info.entrysize=sizeof(DataEntry*);
245+
fss_neighbours=ShmemInitHash("AQO fss neighbours HTAB",fss_max_items,fss_max_items,
246+
&info,HASH_ELEM |HASH_BLOBS);
247+
240248
LWLockRelease(AddinShmemInitLock);
241249
LWLockRegisterTranche(aqo_state->lock.tranche,"AQO");
242250
LWLockRegisterTranche(aqo_state->stat_lock.tranche,"AQO Stat Lock Tranche");
@@ -285,6 +293,7 @@ aqo_memsize(void)
285293
size=add_size(size,hash_estimate_size(fs_max_items,sizeof(QueryTextEntry)));
286294
size=add_size(size,hash_estimate_size(fss_max_items,sizeof(DataEntry)));
287295
size=add_size(size,hash_estimate_size(fs_max_items,sizeof(QueriesEntry)));
296+
size=add_size(size,hash_estimate_size(fss_max_items,sizeof(DataEntry*)));
288297

289298
returnsize;
290299
}

‎storage.c‎

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ typedef enum {
5252

5353
typedefenum {
5454
AD_FS=0,AD_FSS,AD_NFEATURES,AD_FEATURES,AD_TARGETS,AD_RELIABILITY,
55-
AD_OIDS,AD_TOTAL_NCOLS
55+
AD_OIDS,AD_PREV_FS,AD_NEXT_FS,AD_TOTAL_NCOLS
5656
}aqo_data_cols;
5757

5858
typedefenum {
@@ -74,6 +74,7 @@ dsa_area *qtext_dsa = NULL;
7474
HTAB*data_htab=NULL;
7575
dsa_area*data_dsa=NULL;
7676
HTAB*deactivated_queries=NULL;
77+
HTAB*fss_neighbours=NULL;
7778

7879
/* Used to check data file consistency */
7980
staticconstuint32PGAQO_FILE_HEADER=123467589;
@@ -1293,13 +1294,15 @@ aqo_data_store(uint64 fs, int fss, OkNNrdata *data, List *reloids)
12931294
DataEntry*entry;
12941295
boolfound;
12951296
data_keykey= {.fs=fs, .fss=fss};
1297+
fs_listneighbour_list= {0};
12961298
inti;
12971299
char*ptr;
12981300
ListCell*lc;
12991301
size_tsize;
13001302
booltblOverflow;
13011303
HASHACTIONaction;
13021304
boolresult;
1305+
DataEntry**prev;
13031306

13041307
Assert(!LWLockHeldByMe(&aqo_state->data_lock));
13051308

@@ -1383,12 +1386,32 @@ aqo_data_store(uint64 fs, int fss, OkNNrdata *data, List *reloids)
13831386
ptr= (char*)dsa_get_address(data_dsa,entry->data_dp);
13841387
Assert(ptr!=NULL);
13851388

1389+
/*
1390+
* Find prev fss
1391+
*/
1392+
1393+
prev= (DataEntry**)hash_search(fss_neighbours,&fss,HASH_ENTER,&found);
1394+
if (!found)
1395+
{
1396+
*prev=entry;
1397+
}
1398+
else
1399+
{
1400+
(*prev)->list.next_fs=fss;
1401+
}
1402+
neighbour_list.prev_fs= (*prev)->key.fs;
1403+
1404+
prev= (DataEntry**)hash_search(fss_neighbours,&fss,HASH_FIND,&found);
1405+
elog(NOTICE,"%d",found);
1406+
13861407
/*
13871408
* Copy AQO data into allocated DSA segment
13881409
*/
13891410

13901411
memcpy(ptr,&key,sizeof(data_key));/* Just for debug */
13911412
ptr+=sizeof(data_key);
1413+
memcpy(ptr,&neighbour_list,sizeof(fs_list));
1414+
ptr+=sizeof(fs_list);
13921415
if (entry->cols>0)
13931416
{
13941417
for (i=0;i<entry->rows;i++)
@@ -1652,6 +1675,8 @@ aqo_data(PG_FUNCTION_ARGS)
16521675
values[AD_FS]=Int64GetDatum(entry->key.fs);
16531676
values[AD_FSS]=Int32GetDatum((int)entry->key.fss);
16541677
values[AD_NFEATURES]=Int32GetDatum(entry->cols);
1678+
values[AD_PREV_FS]=Int64GetDatum(entry->list.prev_fs);
1679+
values[AD_NEXT_FS]=Int64GetDatum(entry->list.next_fs);
16551680

16561681
/* Fill values from the DSA data chunk */
16571682
Assert(DsaPointerIsValid(entry->data_dp));
@@ -2135,6 +2160,8 @@ cleanup_aqo_database(bool gentle, int *fs_num, int *fss_num)
21352160
foreach(lc,junk_fss)
21362161
{
21372162
data_keykey= {.fs=entry->fs, .fss=lfirst_int(lc)};
2163+
//TODO fix fs list
2164+
hash_search(fss_neighbours,&lfirst_int(lc),HASH_REMOVE,NULL);
21382165
(*fss_num)+= (int)_aqo_data_remove(&key);
21392166
}
21402167

‎storage.h‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,16 @@ typedef struct data_key
5555
int64fss;/* just for alignment */
5656
}data_key;
5757

58+
typedefstructfs_list
59+
{
60+
int64prev_fs;
61+
int64next_fs;
62+
}fs_list;
63+
5864
typedefstructDataEntry
5965
{
6066
data_keykey;
67+
fs_listlist;
6168

6269
/* defines a size and data placement in the DSA memory block */
6370
intcols;/* aka nfeatures */
@@ -89,6 +96,7 @@ extern HTAB *stat_htab;
8996
externHTAB*qtexts_htab;
9097
externHTAB*queries_htab;/* TODO */
9198
externHTAB*data_htab;/* TODO */
99+
externHTAB*fss_neighbours;
92100

93101
externStatEntry*aqo_stat_store(uint64queryid,booluse_aqo,doubleplan_time,
94102
doubleexec_time,doubleest_error);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp