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

Commit53c1781

Browse files
author
Alexandra Pervushina
committed
Add fss_neighbours hash table
1 parent1275c61 commit53c1781

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
@@ -20,7 +20,6 @@ DROP TABLE public.aqo_queries CASCADE;
2020
DROPTABLEpublic.aqo_query_texts CASCADE;
2121
DROPTABLEpublic.aqo_query_stat CASCADE;
2222

23-
2423
/*
2524
* VIEWs to discover AQO data.
2625
*/
@@ -62,7 +61,9 @@ CREATE FUNCTION aqo_data (
6261
OUT featuresdouble precision[][],
6362
OUT targetsdouble precision[],
6463
OUT reliabilitydouble precision[],
65-
OUT oidsOid[]
64+
OUT oidsOid[],
65+
OUT prev_fsbigint,
66+
OUT next_fsbigint
6667
)
6768
RETURNS SETOF record
6869
AS'MODULE_PATHNAME','aqo_data'

‎aqo_shared.c‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ aqo_init_shmem(void)
184184
qtexts_htab=NULL;
185185
data_htab=NULL;
186186
queries_htab=NULL;
187+
fss_neighbours=NULL;
187188

188189
LWLockAcquire(AddinShmemInitLock,LW_EXCLUSIVE);
189190
aqo_state=ShmemInitStruct("AQO",sizeof(AQOSharedState),&found);
@@ -209,6 +210,7 @@ aqo_init_shmem(void)
209210
LWLockInitialize(&aqo_state->queries_lock,LWLockNewTrancheId());
210211
}
211212

213+
/* Init shared memory hash for partial aqo data table*/
212214
info.keysize=sizeof(htab_key);
213215
info.entrysize=sizeof(htab_entry);
214216
fss_htab=ShmemInitHash("AQO hash",
@@ -239,6 +241,12 @@ aqo_init_shmem(void)
239241
queries_htab=ShmemInitHash("AQO Queries HTAB",fs_max_items,fs_max_items,
240242
&info,HASH_ELEM |HASH_BLOBS);
241243

244+
/* Shared memory hash table for fss neighbours */
245+
info.keysize=sizeof(int);
246+
info.entrysize=sizeof(DataEntry*);
247+
fss_neighbours=ShmemInitHash("AQO fss neighbours HTAB",fss_max_items,fss_max_items,
248+
&info,HASH_ELEM |HASH_BLOBS);
249+
242250
LWLockRelease(AddinShmemInitLock);
243251
LWLockRegisterTranche(aqo_state->lock.tranche,"AQO");
244252
LWLockRegisterTranche(aqo_state->stat_lock.tranche,"AQO Stat Lock Tranche");
@@ -287,6 +295,7 @@ aqo_memsize(void)
287295
size=add_size(size,hash_estimate_size(fs_max_items,sizeof(QueryTextEntry)));
288296
size=add_size(size,hash_estimate_size(fss_max_items,sizeof(DataEntry)));
289297
size=add_size(size,hash_estimate_size(fs_max_items,sizeof(QueriesEntry)));
298+
size=add_size(size,hash_estimate_size(fss_max_items,sizeof(DataEntry*)));
290299

291300
returnsize;
292301
}

‎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