Skip to content

Commit

Permalink
SCBC-461: Support for base64 encoded vector types [FIT]
Browse files Browse the repository at this point in the history
FIT performer side of this work.

Change-Id: Ibfb2e7c055e7677b7c8409d53d342c7952084528
Reviewed-on: https://review.couchbase.org/c/couchbase-jvm-clients/+/211117
Reviewed-by: Graham Pople <[email protected]>
Tested-by: Build Bot <[email protected]>
  • Loading branch information
programmatix committed Nov 5, 2024
1 parent 7f36cf2 commit 374a820
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -219,14 +219,11 @@ object SearchHelper {
opts = opts.facets(facets)
}
if (o.hasTimeoutMillis) {
// [start:1.4.5]
// [if:1.4.5]
opts = opts.timeout(Duration(o.getTimeoutMillis, TimeUnit.MILLISECONDS))
// [end:1.4.5]
// [start:<1.4.5]
/*
throw new UnsupportedOperationException()
// [end:<1.4.5]
*/
// [else]
//? throw new UnsupportedOperationException()
// [end]
}
if (o.hasParentSpanId) throw new UnsupportedOperationException()
if (o.getRawCount > 0) opts = opts.raw(o.getRawMap.asScala.toMap)
Expand Down Expand Up @@ -453,7 +450,7 @@ object SearchHelper {
result
}

// [start:1.6.0]
// [if:1.6.0]
def handleSearchBlocking(
cluster: Cluster,
command: com.couchbase.client.protocol.sdk.search.SearchWrapper
Expand Down Expand Up @@ -533,8 +530,17 @@ object SearchHelper {
def convertVectorQuery(
vq: com.couchbase.client.protocol.sdk.search.VectorQuery
): com.couchbase.client.scala.search.vector.VectorQuery = {
val query: Array[Float] = vq.getVectorQueryList.asScala.toArray.map(v => v.asInstanceOf[Float])
var out = com.couchbase.client.scala.search.vector.VectorQuery(vq.getVectorFieldName, query)
// [if:1.6.2]
var out = if (vq.hasBase64VectorQuery) {
com.couchbase.client.scala.search.vector.VectorQuery(vq.getVectorFieldName, vq.getBase64VectorQuery)
} else {
val query: Array[Float] = vq.getVectorQueryList.asScala.toArray.map(v => v.asInstanceOf[Float])
com.couchbase.client.scala.search.vector.VectorQuery(vq.getVectorFieldName, query)
}
// [else]
//? val query: Array[Float] = vq.getVectorQueryList.asScala.toArray.map(v => v.asInstanceOf[Float])
//? var out = com.couchbase.client.scala.search.vector.VectorQuery(vq.getVectorFieldName, query)
// [end]
if (vq.hasOptions) {
val opts = vq.getOptions
if (opts.hasNumCandidates) out = out.numCandidates(opts.getNumCandidates)
Expand All @@ -561,7 +567,7 @@ object SearchHelper {
}
}

// [end:1.6.0]
// [end]

private def convertResult(
result: SearchResult,
Expand Down Expand Up @@ -732,7 +738,7 @@ object SearchHelper {
} else if (command.hasUpsertIndex) {
val req = command.getUpsertIndex

// [start:1.4.5]
// [if:1.4.5]
val converted = SearchIndex.fromJson(req.getIndexDefinition.toStringUtf8).get
result.setInitiated(getTimeNow)
val start = System.nanoTime
Expand All @@ -747,12 +753,9 @@ object SearchHelper {
.get
result.setElapsedNanos(System.nanoTime - start)
setSuccess(result)
// [end:1.4.5]
// [start:<1.4.5]
/*
throw new UnsupportedOperationException()
// [end:<1.4.5]
*/
// [else]
//? throw new UnsupportedOperationException()
// [end]
} else if (command.hasDropIndex) {
val req = command.getDropIndex

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ object Capabilities {
out.add(Caps.SDK_VECTOR_SEARCH)
// [end:1.6.0]

// [start:1.6.2]
out.add(Caps.SDK_VECTOR_SEARCH_BASE64)
// [end:1.6.2]

out
}

Expand Down

0 comments on commit 374a820

Please sign in to comment.