SpecializedGeneralist/hnsw-grpc-server

View on GitHub

Showing 12 of 13 total issues

Similar blocks of code found in 2 locations. Consider refactoring.
Open

func (s *Server) DeleteIndex(_ context.Context, req *grpcapi.DeleteIndexRequest) (*emptypb.Empty, error) {
    s.logger.Debug().Interface("req", req).Msg("Server.DeleteIndex")

    err := s.indexManager.DeleteIndex(req.GetIndexName())
    if err != nil {
Severity: Major
Found in pkg/server/server.go and 1 other location - About 1 hr to fix
pkg/server/server.go on lines 258..266

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 139.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

func (s *Server) FlushIndex(_ context.Context, req *grpcapi.FlushRequest) (*emptypb.Empty, error) {
    s.logger.Debug().Interface("req", req).Msg("Server.FlushIndex")

    err := s.indexManager.PersistIndex(req.GetIndexName())
    if err != nil {
Severity: Major
Found in pkg/server/server.go and 1 other location - About 1 hr to fix
pkg/server/server.go on lines 83..91

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 139.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Method IndexManager.CreateIndex has 6 return statements (exceeds 4 allowed).
Open

func (im *IndexManager) CreateIndex(name string, config hnswgo.Config) (*hnswgo.HNSW, error) {
    im.rwMx.Lock()
    defer im.rwMx.Unlock()

    if !isValidIndexName(name) {
Severity: Major
Found in pkg/indexmanager/indexmanager.go - About 40 mins to fix

    Method Server.InsertVectors has 5 return statements (exceeds 4 allowed).
    Open

    func (s *Server) InsertVectors(stream grpcapi.Server_InsertVectorsServer) error {
        s.logger.Debug().Msg("Server.InsertVectors")
    
        startTime := time.Now()
    
    
    Severity: Major
    Found in pkg/server/server.go - About 35 mins to fix

      Method Server.InsertVectorsWithIds has 5 return statements (exceeds 4 allowed).
      Open

      func (s *Server) InsertVectorsWithIds(stream grpcapi.Server_InsertVectorsWithIdsServer) error {
          s.logger.Debug().Msg("Server.InsertVectorsWithIds")
      
          startTime := time.Now()
      
      
      Severity: Major
      Found in pkg/server/server.go - About 35 mins to fix

        Method Log.Delete has 5 return statements (exceeds 4 allowed).
        Open

        func (log *Log) Delete() error {
            log.mx.Lock()
            defer log.mx.Unlock()
        
            if log.file != nil {
        Severity: Major
        Found in pkg/wal/wal.go - About 35 mins to fix

          method InsertVectorWithId should be InsertVectorWithID
          Open

          func (s *Server) InsertVectorWithId(_ context.Context, req *grpcapi.InsertVectorWithIdRequest) (*grpcapi.InsertVectorWithIdReply, error) {
          Severity: Minor
          Found in pkg/server/server.go by golint

          Line length
          Open

          | InsertVectors | Insert new vectors in the given index, with generated ID, then flush the index |
          Severity: Info
          Found in README.md by markdownlint

          MD013 - Line length

          Tags: line_length

          Aliases: line-length Parameters: linelength, codeblocks, tables (number; default 80, boolean; default true)

          This rule is triggered when there are lines that are longer than the configured line length (default: 80 characters). To fix this, split the line up into multiple lines.

          This rule has an exception where there is no whitespace beyond the configured line length. This allows you to still include items such as long URLs without being forced to break them in the middle.

          You also have the option to exclude this rule for code blocks and tables. To do this, set the code_blocks and/or tables parameters to false.

          Code blocks are included in this rule by default since it is often a requirement for document readability, and tentatively compatible with code rules. Still, some languages do not lend themselves to short lines.

          Line length
          Open

          | InsertVectorsWithId | Insert new vectors with given IDs in the given index, then flush the index |
          Severity: Info
          Found in README.md by markdownlint

          MD013 - Line length

          Tags: line_length

          Aliases: line-length Parameters: linelength, codeblocks, tables (number; default 80, boolean; default true)

          This rule is triggered when there are lines that are longer than the configured line length (default: 80 characters). To fix this, split the line up into multiple lines.

          This rule has an exception where there is no whitespace beyond the configured line length. This allows you to still include items such as long URLs without being forced to break them in the middle.

          You also have the option to exclude this rule for code blocks and tables. To do this, set the code_blocks and/or tables parameters to false.

          Code blocks are included in this rule by default since it is often a requirement for document readability, and tentatively compatible with code rules. Still, some languages do not lend themselves to short lines.

          Line length
          Open

          and [Efficient and robust approximate nearest neighbor search using Hierarchical Navigable Small World graphs.](https://arxiv.org/abs/1603.09320).
          Severity: Info
          Found in pkg/hnswgo/README.md by markdownlint

          MD013 - Line length

          Tags: line_length

          Aliases: line-length Parameters: linelength, codeblocks, tables (number; default 80, boolean; default true)

          This rule is triggered when there are lines that are longer than the configured line length (default: 80 characters). To fix this, split the line up into multiple lines.

          This rule has an exception where there is no whitespace beyond the configured line length. This allows you to still include items such as long URLs without being forced to break them in the middle.

          You also have the option to exclude this rule for code blocks and tables. To do this, set the code_blocks and/or tables parameters to false.

          Code blocks are included in this rule by default since it is often a requirement for document readability, and tentatively compatible with code rules. Still, some languages do not lend themselves to short lines.

          Line length
          Open

          | SearchKNN | Return the top k nearest neighbors to the query, searching on the given index |
          Severity: Info
          Found in README.md by markdownlint

          MD013 - Line length

          Tags: line_length

          Aliases: line-length Parameters: linelength, codeblocks, tables (number; default 80, boolean; default true)

          This rule is triggered when there are lines that are longer than the configured line length (default: 80 characters). To fix this, split the line up into multiple lines.

          This rule has an exception where there is no whitespace beyond the configured line length. This allows you to still include items such as long URLs without being forced to break them in the middle.

          You also have the option to exclude this rule for code blocks and tables. To do this, set the code_blocks and/or tables parameters to false.

          Code blocks are included in this rule by default since it is often a requirement for document readability, and tentatively compatible with code rules. Still, some languages do not lend themselves to short lines.

          Line length
          Open

          | InsertVector | Insert a new vector in the given index, letting the index generate an ID |
          Severity: Info
          Found in README.md by markdownlint

          MD013 - Line length

          Tags: line_length

          Aliases: line-length Parameters: linelength, codeblocks, tables (number; default 80, boolean; default true)

          This rule is triggered when there are lines that are longer than the configured line length (default: 80 characters). To fix this, split the line up into multiple lines.

          This rule has an exception where there is no whitespace beyond the configured line length. This allows you to still include items such as long URLs without being forced to break them in the middle.

          You also have the option to exclude this rule for code blocks and tables. To do this, set the code_blocks and/or tables parameters to false.

          Code blocks are included in this rule by default since it is often a requirement for document readability, and tentatively compatible with code rules. Still, some languages do not lend themselves to short lines.

          Severity
          Category
          Status
          Source
          Language