diff --git a/tok/hnsw/heap.go b/tok/hnsw/heap.go index da165f835ae..fee786dd607 100644 --- a/tok/hnsw/heap.go +++ b/tok/hnsw/heap.go @@ -1,3 +1,21 @@ +/* + * Copyright 2016-2024 Dgraph Labs, Inc. and Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Co-authored by: jairad26@gmail.com, sunil@hypermode.com, bill@hypdermode.com + */ + package hnsw import ( diff --git a/tok/hnsw/helper.go b/tok/hnsw/helper.go index 9e15636f3b8..6111e05f355 100644 --- a/tok/hnsw/helper.go +++ b/tok/hnsw/helper.go @@ -1,3 +1,21 @@ +/* + * Copyright 2016-2024 Dgraph Labs, Inc. and Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Co-authored by: jairad26@gmail.com, sunil@hypermode.com, bill@hypdermode.com + */ + package hnsw import ( @@ -535,33 +553,33 @@ func (ph *persistentHNSW[T]) distance_betw(ctx context.Context, tc *TxnCache, in return d } -type CustomHeap struct { +type HeapDataHolder struct { data []uint64 compare func(a, b uint64) bool } // Len is the number of elements in the collection. -func (h CustomHeap) Len() int { +func (h HeapDataHolder) Len() int { return len(h.data) } // Less reports whether the element with index i should sort before the element with index j. -func (h CustomHeap) Less(i, j int) bool { +func (h HeapDataHolder) Less(i, j int) bool { return h.compare(h.data[i], h.data[j]) } // Swap swaps the elements with indexes i and j. -func (h CustomHeap) Swap(i, j int) { +func (h HeapDataHolder) Swap(i, j int) { h.data[i], h.data[j] = h.data[j], h.data[i] } // Push adds an element to the heap. -func (h *CustomHeap) Push(x interface{}) { +func (h *HeapDataHolder) Push(x interface{}) { h.data = append(h.data, x.(uint64)) } // Pop removes and returns the maximum element from the heap. -func (h *CustomHeap) Pop() interface{} { +func (h *HeapDataHolder) Pop() interface{} { old := h.data n := len(old) x := old[n-1] @@ -608,7 +626,7 @@ func (ph *persistentHNSW[T]) addNeighbors(ctx context.Context, tc *TxnCache, if err != nil { log.Printf("[ERROR] While getting vector %s", err) } else { - h := &CustomHeap{ + h := &HeapDataHolder{ data: allLayerEdges[level], compare: func(i, j uint64) bool { return ph.distance_betw(ctx, tc, uuid, i, &inVec, &outVec) > diff --git a/tok/hnsw/persistent_factory.go b/tok/hnsw/persistent_factory.go index d391744195e..2b353e1a25b 100644 --- a/tok/hnsw/persistent_factory.go +++ b/tok/hnsw/persistent_factory.go @@ -1,3 +1,21 @@ +/* + * Copyright 2016-2024 Dgraph Labs, Inc. and Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Co-authored by: jairad26@gmail.com, sunil@hypermode.com, bill@hypdermode.com + */ + package hnsw import ( diff --git a/tok/hnsw/persistent_hnsw.go b/tok/hnsw/persistent_hnsw.go index 00b55552e04..f6a33585bd4 100644 --- a/tok/hnsw/persistent_hnsw.go +++ b/tok/hnsw/persistent_hnsw.go @@ -1,3 +1,21 @@ +/* + * Copyright 2016-2024 Dgraph Labs, Inc. and Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Co-authored by: jairad26@gmail.com, sunil@hypermode.com, bill@hypdermode.com + */ + package hnsw import ( diff --git a/tok/hnsw/persistent_hnsw_test.go b/tok/hnsw/persistent_hnsw_test.go index 2befa742030..11adcbea90e 100644 --- a/tok/hnsw/persistent_hnsw_test.go +++ b/tok/hnsw/persistent_hnsw_test.go @@ -1,3 +1,21 @@ +/* + * Copyright 2016-2024 Dgraph Labs, Inc. and Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Co-authored by: jairad26@gmail.com, sunil@hypermode.com, bill@hypdermode.com + */ + package hnsw import ( diff --git a/tok/hnsw/search_layer.go b/tok/hnsw/search_layer.go index d01a864d063..2e39472dcc6 100644 --- a/tok/hnsw/search_layer.go +++ b/tok/hnsw/search_layer.go @@ -1,3 +1,21 @@ +/* + * Copyright 2016-2024 Dgraph Labs, Inc. and Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Co-authored by: jairad26@gmail.com, sunil@hypermode.com, bill@hypdermode.com + */ + package hnsw import ( diff --git a/tok/hnsw/test_helper.go b/tok/hnsw/test_helper.go index 29f1412254a..69f851e659e 100644 --- a/tok/hnsw/test_helper.go +++ b/tok/hnsw/test_helper.go @@ -1,3 +1,21 @@ +/* + * Copyright 2016-2024 Dgraph Labs, Inc. and Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Co-authored by: jairad26@gmail.com, sunil@hypermode.com, bill@hypdermode.com + */ + package hnsw import ( diff --git a/tok/index/helper.go b/tok/index/helper.go index de56ac5023d..2d08897c18b 100644 --- a/tok/index/helper.go +++ b/tok/index/helper.go @@ -1,5 +1,5 @@ /* - * Copyright 2016-2023 Dgraph Labs, Inc. and Contributors + * Copyright 2016-2024 Dgraph Labs, Inc. and Contributors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -12,6 +12,8 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. + * + * Co-authored by: jairad26@gmail.com, sunil@hypermode.com, bill@hypdermode.com */ package index diff --git a/tok/index/helper_test.go b/tok/index/helper_test.go index 1968ae8d4d3..0dc0ab1a7b3 100644 --- a/tok/index/helper_test.go +++ b/tok/index/helper_test.go @@ -12,6 +12,8 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. + * + * Co-authored by: jairad26@gmail.com, sunil@hypermode.com, bill@hypdermode.com */ package index diff --git a/tok/index/index.go b/tok/index/index.go index 9d51b37ad55..e5c46894ba2 100644 --- a/tok/index/index.go +++ b/tok/index/index.go @@ -1,5 +1,5 @@ /* - * Copyright 2016-2023 Dgraph Labs, Inc. and Contributors + * Copyright 2016-2024 Dgraph Labs, Inc. and Contributors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -12,6 +12,8 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. + * + * Co-authored by: jai@hypermode.com, sunil@hypermode.com, bill@hypdermode.com */ package index diff --git a/tok/index/search_path.go b/tok/index/search_path.go index b95f2e5a8e7..761971d9d98 100644 --- a/tok/index/search_path.go +++ b/tok/index/search_path.go @@ -1,5 +1,5 @@ /* - * Copyright 2016-2023 Dgraph Labs, Inc. and Contributors + * Copyright 2016-2024 Dgraph Labs, Inc. and Contributors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -12,6 +12,8 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. + * + * Co-authored by: jairad26@gmail.com, sunil@hypermode.com, bill@hypdermode.com */ package index diff --git a/tok/index/types.go b/tok/index/types.go index a9bac545b43..254b292ed8d 100644 --- a/tok/index/types.go +++ b/tok/index/types.go @@ -1,5 +1,5 @@ /* - * Copyright 2016-2023 Dgraph Labs, Inc. and Contributors + * Copyright 2016-2024 Dgraph Labs, Inc. and Contributors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -12,6 +12,8 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. + * + * Co-authored by: jairad26@gmail.com, sunil@hypermode.com, bill@hypdermode.com */ package index