Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 89c2e93

Browse files
committed
Bugfix. Initialization of kNN data structure was omitted in one newly
added case.
1 parent 7123766 commit 89c2e93

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

storage.c

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1465,6 +1465,7 @@ aqo_data_store(uint64 fs, int fss, AqoDataArgs *data, List *reloids)
14651465
}
14661466
}
14671467
aqo_state->data_changed = true;
1468+
Assert(entry->rows > 0);
14681469
end:
14691470
result = aqo_state->data_changed;
14701471
LWLockRelease(&aqo_state->data_lock);
@@ -1505,13 +1506,15 @@ build_knn_matrix(OkNNrdata *data, const OkNNrdata *temp_data, double *features)
15051506
if (features != NULL)
15061507
{
15071508
int old_rows = data->rows;
1508-
int k = old_rows;
1509+
int k = (old_rows < 0) ? 0 : old_rows;
15091510

15101511
if (data->cols > 0)
15111512
{
15121513
int i;
15131514

1514-
for (i = 0; i < data->rows; i++)
1515+
Assert(data->cols == temp_data->cols);
1516+
1517+
for (i = 0; i < temp_data->rows; i++)
15151518
{
15161519
if (k < aqo_K && !neirest_neighbor(data->matrix, old_rows, data->matrix[i], data->cols))
15171520
{
@@ -1521,6 +1524,7 @@ build_knn_matrix(OkNNrdata *data, const OkNNrdata *temp_data, double *features)
15211524
k++;
15221525
}
15231526
}
1527+
data->rows = k;
15241528
}
15251529
}
15261530
else
@@ -1605,11 +1609,13 @@ _fill_knn_data(const DataEntry *entry, List **reloids)
16051609
}
16061610

16071611
/*
1608-
* Return on feature subspace, unique defined by its class (fs) and hash value
1609-
* (fss).
1610-
* If reloids is NULL, skip loading of this list.
1612+
* By given feature space and subspace, build kNN data structure.
1613+
*
16111614
* If wideSearch is true - make seqscan on the hash table to see for relevant
16121615
* data across neighbours.
1616+
* If reloids is NULL - don't fill this list.
1617+
*
1618+
* Return false if the operation was unsuccessful.
16131619
*/
16141620
bool
16151621
load_aqo_data(uint64 fs, int fss, OkNNrdata *data, List **reloids,
@@ -1634,7 +1640,7 @@ load_aqo_data(uint64 fs, int fss, OkNNrdata *data, List **reloids,
16341640
goto end;
16351641

16361642
/* One entry with all correctly filled fields is found */
1637-
Assert(entry);
1643+
Assert(entry && entry->rows > 0);
16381644
Assert(DsaPointerIsValid(entry->data_dp));
16391645

16401646
if (entry->cols != data->cols)
@@ -1643,12 +1649,14 @@ load_aqo_data(uint64 fs, int fss, OkNNrdata *data, List **reloids,
16431649
elog(LOG, "[AQO] Does a collision happened? Check it if possible "
16441650
"(fs: "UINT64_FORMAT", fss: %d).",
16451651
fs, fss);
1646-
found = false;
1652+
found = false; /* Sign of unsuccessful operation */
16471653
goto end;
16481654
}
16491655

16501656
temp_data = _fill_knn_data(entry, reloids);
1657+
Assert(temp_data->rows > 0);
16511658
build_knn_matrix(data, temp_data, features);
1659+
Assert(data->rows > 0);
16521660
}
16531661
else
16541662
/* Iterate across all elements of the table. XXX: Maybe slow. */
@@ -1662,6 +1670,8 @@ load_aqo_data(uint64 fs, int fss, OkNNrdata *data, List **reloids,
16621670
{
16631671
List *tmp_oids = NIL;
16641672

1673+
Assert(entry->rows > 0);
1674+
16651675
if (entry->key.fss != fss || entry->cols != data->cols)
16661676
continue;
16671677

0 commit comments

Comments
 (0)