Skip to content

Commit

Permalink
Merge branch 'main' into logn
Browse files Browse the repository at this point in the history
  • Loading branch information
friendlymatthew authored Jun 12, 2024
2 parents c13d18f + 851b21b commit ddfa628
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 312 deletions.
4 changes: 4 additions & 0 deletions examples/client/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ func main() {
// Handle all requests by serving a file of the same name
http.Handle("/", fs)

http.HandleFunc("/search", func(w http.ResponseWriter, r *http.Request) {
http.ServeFile(w, r, "./search.html")
})

// Define the port to listen on
port := "3001"
log.Printf("Listening on http://localhost:%s/", port)
Expand Down
285 changes: 0 additions & 285 deletions examples/search/index.html

This file was deleted.

24 changes: 0 additions & 24 deletions examples/search/server.go

This file was deleted.

3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
"main": "index.js",
"scripts": {
"build": "esbuild src/index.ts --bundle --minify --sourcemap --outfile=dist/appendable.min.js",
"warp": "rm -rf dist examples/client/appendable.min.js examples/client/appendable.min.js.map examples/search/appendable.min.js examples/search/appendable.min.js.map && esbuild src/index.ts --bundle --minify --sourcemap --outfile=dist/appendable.min.js",
"warp": "rm -rf dist examples/client/appendable.min.js examples/client/appendable.min.js.map && esbuild src/index.ts --bundle --minify --sourcemap --outfile=dist/appendable.min.js",
"client": "cd examples/client && go run server.go",
"search": "cd examples/search && go run server.go",
"test": "jest"
},
"repository": {
Expand Down
7 changes: 6 additions & 1 deletion pkg/hnsw/hnsw.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func NewHnsw(d int, efConstruction int, M int, entryPoint Point) *Hnsw {
}

func (h *Hnsw) SpawnLevel() int {
return int(math.Floor(-math.Log(rand.Float64() * h.levelMultiplier)))
return int(math.Floor(-math.Log(rand.Float64()) * h.levelMultiplier))
}

func (h *Hnsw) GenerateId() Id {
Expand Down Expand Up @@ -181,6 +181,11 @@ func (h *Hnsw) InsertVector(q Point) error {

qId := h.GenerateId()
qTopLevel := h.SpawnLevel()

if qTopLevel < 0 {
panic("invalid top level cannot have a negative top level")
}

qFriends := NewFriends(qTopLevel)
h.friends[qId] = qFriends
h.points[qId] = &q
Expand Down
Loading

0 comments on commit ddfa628

Please sign in to comment.