@@ -1074,39 +1074,12 @@ AddConnections(char *base, HnswElement element, List *neighbors, int lc)
1074
1074
a -> items [a -> length ++ ] = * ((HnswCandidate * ) lfirst (lc2 ));
1075
1075
}
1076
1076
1077
- /*
1078
- * Load elements for insert
1079
- */
1080
- static void
1081
- LoadElementsForInsert (HnswNeighborArray * neighbors , Datum q , HnswCandidate * * pruned , Relation index , FmgrInfo * procinfo , Oid collation )
1082
- {
1083
- char * base = NULL ;
1084
-
1085
- for (int i = 0 ; i < neighbors -> length ; i ++ )
1086
- {
1087
- HnswCandidate * hc = & neighbors -> items [i ];
1088
- HnswElement element = HnswPtrAccess (base , hc -> element );
1089
- double distance ;
1090
-
1091
- HnswLoadElement (element , & distance , & q , index , procinfo , collation , true, NULL );
1092
- hc -> distance = distance ;
1093
-
1094
- /* Prune element if being deleted */
1095
- if (element -> heaptidsLength == 0 )
1096
- {
1097
- * pruned = & neighbors -> items [i ];
1098
- break ;
1099
- }
1100
- }
1101
- }
1102
-
1103
1077
/*
1104
1078
* Update connections
1105
1079
*/
1106
1080
void
1107
1081
HnswUpdateConnection (char * base , HnswElement newElement , HnswCandidate * hc , HnswNeighborArray * neighbors , int lm , int * updateIdx , Relation index , FmgrInfo * procinfo , Oid collation )
1108
1082
{
1109
- HnswElement hce = HnswPtrAccess (base , hc -> element );
1110
1083
HnswCandidate newHc ;
1111
1084
1112
1085
HnswPtrStore (base , newHc .element , newElement );
@@ -1123,27 +1096,19 @@ HnswUpdateConnection(char *base, HnswElement newElement, HnswCandidate * hc, Hns
1123
1096
else
1124
1097
{
1125
1098
/* Shrink connections */
1099
+ List * c = NIL ;
1126
1100
HnswCandidate * pruned = NULL ;
1127
1101
1128
- /* Load elements on insert */
1129
- if (index != NULL )
1130
- LoadElementsForInsert (neighbors , HnswGetValue (base , hce ), & pruned , index , procinfo , collation );
1131
-
1132
- if (pruned == NULL )
1133
- {
1134
- List * c = NIL ;
1135
-
1136
- /* Add candidates */
1137
- for (int i = 0 ; i < neighbors -> length ; i ++ )
1138
- c = lappend (c , & neighbors -> items [i ]);
1139
- c = lappend (c , & newHc );
1102
+ /* Add candidates */
1103
+ for (int i = 0 ; i < neighbors -> length ; i ++ )
1104
+ c = lappend (c , & neighbors -> items [i ]);
1105
+ c = lappend (c , & newHc );
1140
1106
1141
- SelectNeighbors (base , c , lm , procinfo , collation , neighbors , & newHc , & pruned , true);
1107
+ SelectNeighbors (base , c , lm , procinfo , collation , neighbors , & newHc , & pruned , true);
1142
1108
1143
- /* Should not happen */
1144
- if (pruned == NULL )
1145
- return ;
1146
- }
1109
+ /* Should not happen */
1110
+ if (pruned == NULL )
1111
+ return ;
1147
1112
1148
1113
/* Find and replace the pruned element */
1149
1114
for (int i = 0 ; i < neighbors -> length ; i ++ )
0 commit comments