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

Commit2a69432

Browse files
author
Alexandra Pervushina
committed
fix neighbours htab, fix list when performing aqo_cleanup
1 parentc00ed3f commit2a69432

File tree

2 files changed

+71
-27
lines changed

2 files changed

+71
-27
lines changed

‎storage.c‎

Lines changed: 65 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1291,18 +1291,17 @@ _compute_data_dsa(const DataEntry *entry)
12911291
bool
12921292
aqo_data_store(uint64fs,intfss,OkNNrdata*data,List*reloids)
12931293
{
1294-
DataEntry*entry;
1295-
boolfound;
1296-
data_keykey= {.fs=fs, .fss=fss};
1297-
fs_listneighbour_list= {0};
1298-
inti;
1299-
char*ptr;
1300-
ListCell*lc;
1301-
size_tsize;
1302-
booltblOverflow;
1303-
HASHACTIONaction;
1304-
boolresult;
1305-
uint64*prev_fs;
1294+
DataEntry*entry;
1295+
boolfound;
1296+
data_keykey= {.fs=fs, .fss=fss};
1297+
inti;
1298+
char*ptr;
1299+
ListCell*lc;
1300+
size_tsize;
1301+
booltblOverflow;
1302+
HASHACTIONaction;
1303+
boolresult;
1304+
NeighboursEntry*prev_fs;
13061305

13071306
Assert(!LWLockHeldByMe(&aqo_state->data_lock));
13081307

@@ -1392,25 +1391,23 @@ aqo_data_store(uint64 fs, int fss, OkNNrdata *data, List *reloids)
13921391

13931392
LWLockAcquire(&aqo_state->neighbours_lock,LW_EXCLUSIVE);
13941393

1395-
prev_fs= (uint64*)hash_search(fss_neighbours,&fss,HASH_ENTER,&found);
1394+
prev_fs= (NeighboursEntry*)hash_search(fss_neighbours,&fss,HASH_ENTER,&found);
13961395
if (!found)
13971396
{
1398-
//*prev_fs = fs;
1399-
memcpy(prev_fs,&entry->key.fs,sizeof(uint64));
1397+
entry->list.prev_fs=fs;
1398+
entry->list.next_fs=fs;
14001399
}
14011400
else
14021401
{
1403-
data_keyprev_key= {.fs=*prev_fs, .fss=fss};
1402+
data_keyprev_key= {.fs=prev_fs->fs, .fss=fss};
14041403
DataEntry*prev;
14051404

14061405
prev= (DataEntry*)hash_search(data_htab,&prev_key,HASH_FIND,NULL);
1407-
//prev->list.next_fs = fs;
1408-
memcpy(&prev->list.next_fs,&fs,sizeof(uint64));
1409-
neighbour_list.prev_fs=prev->key.fs;
1406+
prev->list.next_fs=fs;
1407+
entry->list.next_fs=fs;
1408+
entry->list.prev_fs=prev->key.fs;
14101409
}
1411-
1412-
prev_fs= (uint64*)hash_search(fss_neighbours,&fss,HASH_FIND,&found);
1413-
elog(NOTICE,"%d 🗿🔫",found);
1410+
prev_fs->fs=entry->key.fs;
14141411

14151412
LWLockRelease(&aqo_state->neighbours_lock);
14161413

@@ -1421,8 +1418,6 @@ aqo_data_store(uint64 fs, int fss, OkNNrdata *data, List *reloids)
14211418

14221419
memcpy(ptr,&key,sizeof(data_key));/* Just for debug */
14231420
ptr+=sizeof(data_key);
1424-
memcpy(ptr,&neighbour_list,sizeof(fs_list));
1425-
ptr+=sizeof(fs_list);
14261421
if (entry->cols>0)
14271422
{
14281423
for (i=0;i<entry->rows;i++)
@@ -2170,9 +2165,52 @@ cleanup_aqo_database(bool gentle, int *fs_num, int *fss_num)
21702165
/* Remove junk records from aqo_data */
21712166
foreach(lc,junk_fss)
21722167
{
2173-
data_keykey= {.fs=entry->fs, .fss=lfirst_int(lc)};
2174-
//TODO fix fs list
2175-
hash_search(fss_neighbours,&lfirst_int(lc),HASH_REMOVE,NULL);
2168+
data_keykey= {.fs=entry->fs, .fss=lfirst_int(lc)};
2169+
boolfound;
2170+
boolhas_prev_fs= false;
2171+
boolhas_next_fs= false;
2172+
DataEntry*current_entry;
2173+
DataEntry*prev_entry;
2174+
DataEntry*next_entry;
2175+
NeighboursEntry*fss_htab_entry;
2176+
2177+
/* fix fs list */
2178+
current_entry= (DataEntry*)hash_search(data_htab,&key,HASH_FIND,&found);
2179+
if (found)
2180+
{
2181+
data_keyneighbour_key= {.fs=current_entry->list.prev_fs, .fss=key.fss};
2182+
2183+
if (key.fs!=current_entry->list.prev_fs)
2184+
{
2185+
prev_entry= (DataEntry*)hash_search(data_htab,&neighbour_key,HASH_FIND,&has_prev_fs);
2186+
}
2187+
2188+
neighbour_key.fs=current_entry->list.next_fs;
2189+
if (key.fs!=current_entry->list.next_fs)
2190+
{
2191+
next_entry= (DataEntry*)hash_search(data_htab,&neighbour_key,HASH_FIND,&has_next_fs);
2192+
}
2193+
2194+
if (has_prev_fs)
2195+
prev_entry->list.next_fs=has_next_fs ?current_entry->list.next_fs :prev_entry->key.fs;
2196+
if (has_next_fs)
2197+
next_entry->list.prev_fs=has_prev_fs ?current_entry->list.prev_fs :next_entry->key.fs;
2198+
2199+
}
2200+
2201+
/* Fix or remove neighbours htab entry*/
2202+
fss_htab_entry= (NeighboursEntry*)hash_search(fss_neighbours,&key.fss,HASH_FIND,&found);
2203+
if (found&&fss_htab_entry->fs==key.fs)
2204+
{
2205+
if (has_prev_fs)
2206+
{
2207+
fss_htab_entry->fs=prev_entry->key.fs;
2208+
}
2209+
else
2210+
{
2211+
hash_search(fss_neighbours,&key.fss,HASH_REMOVE,NULL);
2212+
}
2213+
}
21762214
(*fss_num)+= (int)_aqo_data_remove(&key);
21772215
}
21782216

‎storage.h‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,12 @@ typedef struct QueriesEntry
8989
boolauto_tuning;
9090
}QueriesEntry;
9191

92+
typedefstructNeighboursEntry
93+
{
94+
int64fss;
95+
uint64fs;
96+
}NeighboursEntry;
97+
9298
externintquerytext_max_size;
9399
externintdsm_size_max;
94100

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp