Skip to content

Consider moving back to builder pattern or add Kotlin shim? #120

@rasharab

Description

@rasharab

Is this your first time submitting a feature request?

  • I have searched the existing issues, and I could not find an existing issue for this feature
  • I am requesting a straightforward extension of existing functionality

Describe the feature

As of 1.0.0, it is easy to get this wrong, seeing as types like id/namespace are the same, and since this library is written in Java, I can't use named arguments in Kotlin land.

    return index.query(
        topK ?: DEFAULT_TOP_K,
        denseVector,
        filteredSparseVector?.indicesWithUnsigned32IntList,
        filteredSparseVector?.valuesList,
        null,
        namespace,
        filter?.let { PineconeStructUtils.fromMap(it) },
        includeMetadata,
        includeValues,
    )

In the old way, the declarative approach towards specifying arguments was less error prone:

    val queryRequest = QueryRequest.newBuilder()
        .addAllVector(denseVector)
        .setTopK(topK ?: DEFAULT_TOP_K)
        .setIncludeMetadata(includeMetadata)
        .setIncludeValues(includeValues)
        .setNamespace(namespace)
        .apply {
            filter?.let { setFilter(PineconeStructUtils.fromMap(it)) }
            sparseVector
                ?.takeIf { it.indicesCount in 1..MAX_SPARSE_SIZE }
                ?.let {
                    setSparseVector(it)
                }
        }
        .build()

Two questions:

  1. Any reason for the transition away from a builder pattern?
  2. Are you planning on releasing a Kotlin shim?

Describe alternatives you've considered

No response

Who will this benefit?

Anyone who find it currently a bit tedious having to deal with 5+ parameters for a function call.

Are you interested in contributing this feature?

Sure, I can look into helping with this.

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions