Skip to content

Replace macro with just code for structure builders #195

@generall

Description

@generall

Currently we use macro definitions to auto-generate code for structure builders, which looks like this:

builder_type_conversions!(CreateCollection, CreateCollectionBuilder);
builder_type_conversions!(VectorParams, VectorParamsBuilder, true);
builder_type_conversions!(HnswConfigDiff, HnswConfigDiffBuilder);
builder_type_conversions!(ScalarQuantization, ScalarQuantizationBuilder, true);
builder_type_conversions!(ProductQuantization, ProductQuantizationBuilder, true);
builder_type_conversions!(BinaryQuantization, BinaryQuantizationBuilder, true);
builder_type_conversions!(OptimizersConfigDiff, OptimizersConfigDiffBuilder);

https://github.com/qdrant/rust-client/blob/master/src/qdrant.rs#L9606

But usage of macros makes navigation in the project harder.

qdrant.rs file is generated using code from here https://github.com/qdrant/rust-client/blob/master/tests/protos.rs#L173 (yes, in test 🤷‍♂️ )

I propose to abandon macros and use hand-written code instead. It would be easier to write a whole new definition of the builder than to understand how generator works.

To do this, I think we need to

  • generate the code by unrolling existing macroses
  • Copy builders-related generated code into new files
  • remove all macro generations and rely only on the copy-pasted code.

In order to make sure friction-less transition, we need to make sure all test snippets are still valid without changing: https://github.com/qdrant/rust-client/tree/master/tests/snippet_tests

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions