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

Commitc4dbd74

Browse files
author
Alexandra Pervushina
committed
Fix after review
1 parent233374c commitc4dbd74

File tree

2 files changed

+41
-25
lines changed

2 files changed

+41
-25
lines changed

‎storage.c‎

Lines changed: 38 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1395,19 +1395,18 @@ aqo_data_store(uint64 fs, int fss, OkNNrdata *data, List *reloids)
13951395
LWLockAcquire(&aqo_state->neighbours_lock,LW_EXCLUSIVE);
13961396

13971397
prev= (NeighboursEntry*)hash_search(fss_neighbours,&key.fss,HASH_ENTER,&found);
1398-
if (!found)
1399-
{
1400-
entry->list.prev=NULL;
1401-
entry->list.next=NULL;
1402-
}
1403-
else
1398+
1399+
/* A new element contains backward link to the first element list and
1400+
* the first element contains toward link to the new element.
1401+
* The new element has become the first element of the list.
1402+
*/
1403+
if (found)
14041404
{
1405-
prev->data->list.next=entry;
1406-
entry->list.next=NULL;
1407-
entry->list.prev=prev->data;
1405+
prev->data->neighbour_refs.next=entry;
1406+
entry->neighbour_refs.prev=prev->data;
14081407
}
14091408
prev->data=entry;
1410-
1409+
aqo_state->neighbours_changed= true;
14111410
LWLockRelease(&aqo_state->neighbours_lock);
14121411
}
14131412

@@ -1590,6 +1589,9 @@ load_aqo_data(uint64 fs, int fss, OkNNrdata *data, List **reloids,
15901589
neighbour_entry= (NeighboursEntry*)hash_search(fss_neighbours,&fss,HASH_FIND,&found);
15911590
entry=found ?neighbour_entry->data :NULL;
15921591

1592+
/*
1593+
* Go through the list, starting from the first element and go to back.
1594+
*/
15931595
while (entry!=NULL)
15941596
{
15951597
List*tmp_oids=NIL;
@@ -1620,7 +1622,11 @@ load_aqo_data(uint64 fs, int fss, OkNNrdata *data, List **reloids,
16201622

16211623
build_knn_matrix(data,temp_data);
16221624

1623-
entry=entry->list.prev;
1625+
/*
1626+
* We have a backward oriented list since the first element always stay
1627+
* the last element of list, so go to the next element on the backward link.
1628+
*/
1629+
entry=entry->neighbour_refs.prev;
16241630
}
16251631
LWLockRelease(&aqo_state->neighbours_lock);
16261632
}
@@ -1758,15 +1764,15 @@ _aqo_data_clean(uint64 fs)
17581764
entry->data_dp=InvalidDsaPointer;
17591765

17601766
/* fix neighbour list */
1761-
if (entry->list.next)
1767+
if (entry->neighbour_refs.next)
17621768
has_next= true;
1763-
if (entry->list.prev)
1769+
if (entry->neighbour_refs.prev)
17641770
has_prev= true;
17651771

17661772
if (has_prev)
1767-
entry->list.prev->list.next=has_next ?entry->list.next :NULL;
1773+
entry->neighbour_refs.prev->neighbour_refs.next=has_next ?entry->neighbour_refs.next :NULL;
17681774
if (has_next)
1769-
entry->list.next->list.prev=has_prev ?entry->list.prev :NULL;
1775+
entry->neighbour_refs.next->neighbour_refs.prev=has_prev ?entry->neighbour_refs.prev :NULL;
17701776

17711777
/* Fix or remove neighbours htab entry*/
17721778
LWLockAcquire(&aqo_state->neighbours_lock,LW_EXCLUSIVE);
@@ -1775,15 +1781,20 @@ _aqo_data_clean(uint64 fs)
17751781
{
17761782
if (has_prev)
17771783
{
1778-
fss_htab_entry->data=entry->list.prev;
1784+
fss_htab_entry->data=entry->neighbour_refs.prev;
17791785
}
17801786
else
17811787
{
17821788
hash_search(fss_neighbours,&entry->key.fss,HASH_REMOVE,NULL);
17831789
}
1790+
/*
1791+
* We found element in Neibours hash table and made change:
1792+
* either delete element of table or replace its value.
1793+
*/
1794+
aqo_state->neighbours_changed= true;
17841795
}
17851796
LWLockRelease(&aqo_state->neighbours_lock);
1786-
1797+
17871798

17881799
if (hash_search(data_htab,&entry->key,HASH_REMOVE,NULL)==NULL)
17891800
elog(ERROR,"[AQO] hash table corrupted");
@@ -2324,15 +2335,15 @@ cleanup_aqo_database(bool gentle, int *fs_num, int *fss_num)
23242335
entry= (DataEntry*)hash_search(data_htab,&key,HASH_FIND,&found);
23252336
if (found)
23262337
{
2327-
if (entry->list.next)
2338+
if (entry->neighbour_refs.next)
23282339
has_next= true;
2329-
if (entry->list.prev)
2340+
if (entry->neighbour_refs.prev)
23302341
has_prev= true;
23312342

23322343
if (has_prev)
2333-
entry->list.prev->list.next=has_next ?entry->list.next :NULL;
2344+
entry->neighbour_refs.prev->neighbour_refs.next=has_next ?entry->neighbour_refs.next :NULL;
23342345
if (has_next)
2335-
entry->list.next->list.prev=has_prev ?entry->list.prev :NULL;
2346+
entry->neighbour_refs.next->neighbour_refs.prev=has_prev ?entry->neighbour_refs.prev :NULL;
23362347

23372348
/* Fix or remove neighbours htab entry*/
23382349
LWLockAcquire(&aqo_state->neighbours_lock,LW_EXCLUSIVE);
@@ -2341,12 +2352,17 @@ cleanup_aqo_database(bool gentle, int *fs_num, int *fss_num)
23412352
{
23422353
if (has_prev)
23432354
{
2344-
fss_htab_entry->data=entry->list.prev;
2355+
fss_htab_entry->data=entry->neighbour_refs.prev;
23452356
}
23462357
else
23472358
{
23482359
hash_search(fss_neighbours,&key.fss,HASH_REMOVE,NULL);
23492360
}
2361+
/*
2362+
* We found element in Neibours hash table and made change:
2363+
* either delete element of table or replace its value.
2364+
*/
2365+
aqo_state->neighbours_changed= true;
23502366
}
23512367
LWLockRelease(&aqo_state->neighbours_lock);
23522368
}

‎storage.h‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,9 @@ typedef struct data_key
5656
}data_key;
5757

5858
typedefstructDataEntryDataEntry;
59-
typedefstructneigbour_listneigbour_list;
59+
typedefstructneighbour_referencesneighbour_references;
6060

61-
structneigbour_list
61+
structneighbour_references
6262
{
6363
DataEntry*prev;
6464
DataEntry*next;
@@ -67,7 +67,7 @@ struct neigbour_list
6767
structDataEntry
6868
{
6969
data_keykey;
70-
neigbour_listlist;
70+
neighbour_referencesneighbour_refs;
7171

7272
/* defines a size and data placement in the DSA memory block */
7373
intcols;/* aka nfeatures */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp