Skip to content

Commit be7d6c1

Browse files
authored
Merge pull request #1674 from BillFarber/task/opticGenerate-release-12.0.0-ea1
Optic Generation updates for release-12.0.0-ea1
2 parents 561295c + a336273 commit be7d6c1

File tree

14 files changed

+1059
-411
lines changed

14 files changed

+1059
-411
lines changed

marklogic-client-api/src/main/java/com/marklogic/client/expression/CtsExpr.java

Lines changed: 88 additions & 88 deletions
Large diffs are not rendered by default.

marklogic-client-api/src/main/java/com/marklogic/client/expression/PlanBuilder.java

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
*/
2828
public abstract class PlanBuilder implements PlanBuilderBase {
2929
protected PlanBuilder(
30-
CtsExpr cts, FnExpr fn, GeoExpr geo, JsonExpr json, MapExpr map, MathExpr math, RdfExpr rdf, SemExpr sem, SpellExpr spell, SqlExpr sql, XdmpExpr xdmp, XsExpr xs, RdtExpr rdt
30+
CtsExpr cts, FnExpr fn, GeoExpr geo, JsonExpr json, MapExpr map, MathExpr math, RdfExpr rdf, SemExpr sem, SpellExpr spell, SqlExpr sql, VecExpr vec, XdmpExpr xdmp, XsExpr xs, RdtExpr rdt
3131
) {
3232
this.cts = cts;
3333
this.fn = fn;
@@ -39,6 +39,7 @@ protected PlanBuilder(
3939
this.sem = sem;
4040
this.spell = spell;
4141
this.sql = sql;
42+
this.vec = vec;
4243
this.xdmp = xdmp;
4344
this.xs = xs;
4445
this.rdt = rdt;
@@ -84,6 +85,10 @@ protected PlanBuilder(
8485
* Builds expressions with sql server functions.
8586
*/
8687
public final SqlExpr sql;
88+
/**
89+
* Builds expressions with vec server functions.
90+
*/
91+
public final VecExpr vec;
8792
/**
8893
* Builds expressions with xdmp server functions.
8994
*/
@@ -312,13 +317,13 @@ protected PlanBuilder(
312317
public abstract PlanColumn viewCol(XsStringVal view, XsStringVal column);
313318
/**
314319
* Specifies a name for adding a fragment id column to the row set identifying the source documents for the rows from a view, lexicons or triples. The only use for the fragment id is joining other rows from the same document, the document uri, or the document content. The fragment id is only useful during execution of the query and not after.
315-
* @param column the column value.
320+
* @param column The name of the fragment ID column.
316321
* @return a PlanSystemColumn object
317322
*/
318323
public abstract PlanSystemColumn fragmentIdCol(String column);
319324
/**
320325
* Specifies a name for adding a fragment id column to the row set identifying the source documents for the rows from a view, lexicons or triples. The only use for the fragment id is joining other rows from the same document, the document uri, or the document content. The fragment id is only useful during execution of the query and not after.
321-
* @param column the column value.
326+
* @param column The name of the fragment ID column.
322327
* @return a PlanSystemColumn object
323328
*/
324329
public abstract PlanSystemColumn fragmentIdCol(XsStringVal column);
@@ -1781,26 +1786,26 @@ public interface ModifyPlan extends PreparePlan, PlanBuilderBase.ModifyPlanBase
17811786
public abstract ModifyPlan orderBy(PlanSortKeySeq keys);
17821787
/**
17831788
* Add an error-handler to the Optic Pipeline to catch Optic Update runtime errors. The runtime errors are added in the errors column. If no error occurred the value of the error column is null. When added, the error-handler should be the last operator before op:result.
1784-
* @param action Valid options are: "fail" - stop procesisng and "continue" - add an error to the error column and continue processing.
1789+
* @param action Valid options are: "fail" - stop processing and "continue" - add an error to the error column and continue processing.
17851790
* @return a ModifyPlan object
17861791
*/
17871792
public abstract ModifyPlan onError(String action);
17881793
/**
17891794
* Add an error-handler to the Optic Pipeline to catch Optic Update runtime errors. The runtime errors are added in the errors column. If no error occurred the value of the error column is null. When added, the error-handler should be the last operator before op:result.
1790-
* @param action Valid options are: "fail" - stop procesisng and "continue" - add an error to the error column and continue processing.
1795+
* @param action Valid options are: "fail" - stop processing and "continue" - add an error to the error column and continue processing.
17911796
* @return a ModifyPlan object
17921797
*/
17931798
public abstract ModifyPlan onError(XsStringVal action);
17941799
/**
17951800
* Add an error-handler to the Optic Pipeline to catch Optic Update runtime errors. The runtime errors are added in the errors column. If no error occurred the value of the error column is null. When added, the error-handler should be the last operator before op:result.
1796-
* @param action Valid options are: "fail" - stop procesisng and "continue" - add an error to the error column and continue processing.
1801+
* @param action Valid options are: "fail" - stop processing and "continue" - add an error to the error column and continue processing.
17971802
* @param errorColumn An optional error column which is not used in the plan. If this parameter is not passed in 'sys.errors' is used. See {@link PlanBuilder#col(XsStringVal)}
17981803
* @return a ModifyPlan object
17991804
*/
18001805
public abstract ModifyPlan onError(String action, String errorColumn);
18011806
/**
18021807
* Add an error-handler to the Optic Pipeline to catch Optic Update runtime errors. The runtime errors are added in the errors column. If no error occurred the value of the error column is null. When added, the error-handler should be the last operator before op:result.
1803-
* @param action Valid options are: "fail" - stop procesisng and "continue" - add an error to the error column and continue processing.
1808+
* @param action Valid options are: "fail" - stop processing and "continue" - add an error to the error column and continue processing.
18041809
* @param errorColumn An optional error column which is not used in the plan. If this parameter is not passed in 'sys.errors' is used. See {@link PlanBuilder#col(XsStringVal)}
18051810
* @return a ModifyPlan object
18061811
*/
Lines changed: 204 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,204 @@
1+
/*
2+
* Copyright (c) 2024 MarkLogic Corporation
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.marklogic.client.expression;
18+
19+
import com.marklogic.client.type.XsAnyAtomicTypeSeqVal;
20+
import com.marklogic.client.type.XsDoubleVal;
21+
import com.marklogic.client.type.XsFloatVal;
22+
import com.marklogic.client.type.XsStringVal;
23+
import com.marklogic.client.type.XsUnsignedIntVal;
24+
25+
import com.marklogic.client.type.ServerExpression;
26+
27+
// IMPORTANT: Do not edit. This file is generated.
28+
29+
/**
30+
* Builds expressions to call functions in the vec server library for a row
31+
* pipeline.
32+
*/
33+
public interface VecExpr {
34+
public ServerExpression add(ServerExpression vector1, ServerExpression vector2);
35+
/**
36+
* Constructs a vector result by decoding the base64 binary input.
37+
*
38+
* <a name="ml-server-type-base64-decode"></a>
39+
40+
* <p>
41+
* Provides a client interface to the <a href="http://docs.marklogic.com/vec:base64-decode" target="mlserverdoc">vec:base64-decode</a> server function.
42+
* @param base64Vector The base64 binary encoded string vector to decode. (of <a href="{@docRoot}/doc-files/types/xs_string.html">xs:string</a>)
43+
* @return a server expression with the <a href="{@docRoot}/doc-files/types/vec_vector.html">vec:vector</a> server data type
44+
*/
45+
public ServerExpression base64Decode(ServerExpression base64Vector);
46+
/**
47+
* Returns the base64 encoding of the vector. Useful for compressing a high-dimensional float vector represented as a string into fewer characters.
48+
*
49+
* <a name="ml-server-type-base64-encode"></a>
50+
51+
* <p>
52+
* Provides a client interface to the <a href="http://docs.marklogic.com/vec:base64-encode" target="mlserverdoc">vec:base64-encode</a> server function.
53+
* @param vector1 The vector to base64 encode. (of <a href="{@docRoot}/doc-files/types/vec_vector.html">vec:vector</a>)
54+
* @return a server expression with the <a href="{@docRoot}/doc-files/types/xs_string.html">xs:string</a> server data type
55+
*/
56+
public ServerExpression base64Encode(ServerExpression vector1);
57+
/**
58+
* Returns the cosine similarity between two vectors. The vectors must be of the same dimension.
59+
*
60+
* <a name="ml-server-type-cosine-similarity"></a>
61+
62+
* <p>
63+
* Provides a client interface to the <a href="http://docs.marklogic.com/vec:cosine-similarity" target="mlserverdoc">vec:cosine-similarity</a> server function.
64+
* @param vector1 The vector from which to calculate the cosine similarity with vector2. (of <a href="{@docRoot}/doc-files/types/vec_vector.html">vec:vector</a>)
65+
* @param vector2 The vector from which to calculate the cosine similarity with vector1. (of <a href="{@docRoot}/doc-files/types/vec_vector.html">vec:vector</a>)
66+
* @return a server expression with the <a href="{@docRoot}/doc-files/types/xs_double.html">xs:double</a> server data type
67+
*/
68+
public ServerExpression cosineSimilarity(ServerExpression vector1, ServerExpression vector2);
69+
/**
70+
* Returns the dimension of the vector passed in.
71+
*
72+
* <a name="ml-server-type-dimension"></a>
73+
74+
* <p>
75+
* Provides a client interface to the <a href="http://docs.marklogic.com/vec:dimension" target="mlserverdoc">vec:dimension</a> server function.
76+
* @param vector1 The vector to find the dimension of. (of <a href="{@docRoot}/doc-files/types/vec_vector.html">vec:vector</a>)
77+
* @return a server expression with the <a href="{@docRoot}/doc-files/types/xs_unsignedInt.html">xs:unsignedInt</a> server data type
78+
*/
79+
public ServerExpression dimension(ServerExpression vector1);
80+
/**
81+
* Returns the dot product between two vectors. The vectors must be of the same dimension. Use this function to calculate similarity between vectors if you are certain they are both of magnitude 1.
82+
*
83+
* <a name="ml-server-type-dot-product"></a>
84+
85+
* <p>
86+
* Provides a client interface to the <a href="http://docs.marklogic.com/vec:dot-product" target="mlserverdoc">vec:dot-product</a> server function.
87+
* @param vector1 The vector from which to calculate the dot product with vector2. (of <a href="{@docRoot}/doc-files/types/vec_vector.html">vec:vector</a>)
88+
* @param vector2 The vector from which to calculate the dot product with vector1. (of <a href="{@docRoot}/doc-files/types/vec_vector.html">vec:vector</a>)
89+
* @return a server expression with the <a href="{@docRoot}/doc-files/types/xs_double.html">xs:double</a> server data type
90+
*/
91+
public ServerExpression dotProduct(ServerExpression vector1, ServerExpression vector2);
92+
/**
93+
* Returns the Euclidean distance between two vectors. The vectors must be of the same dimension.
94+
*
95+
* <a name="ml-server-type-euclidean-distance"></a>
96+
97+
* <p>
98+
* Provides a client interface to the <a href="http://docs.marklogic.com/vec:euclidean-distance" target="mlserverdoc">vec:euclidean-distance</a> server function.
99+
* @param vector1 The vector from which to calculate the Euclidean distance to vector2. (of <a href="{@docRoot}/doc-files/types/vec_vector.html">vec:vector</a>)
100+
* @param vector2 The vector from which to calculate the Euclidean distance to vector1. (of <a href="{@docRoot}/doc-files/types/vec_vector.html">vec:vector</a>)
101+
* @return a server expression with the <a href="{@docRoot}/doc-files/types/xs_double.html">xs:double</a> server data type
102+
*/
103+
public ServerExpression euclideanDistance(ServerExpression vector1, ServerExpression vector2);
104+
/**
105+
* Returns the element at the k-th index of the vector.
106+
*
107+
* <a name="ml-server-type-get"></a>
108+
109+
* <p>
110+
* Provides a client interface to the <a href="http://docs.marklogic.com/vec:get" target="mlserverdoc">vec:get</a> server function.
111+
* @param vector1 The vector to grab the k-th element of. (of <a href="{@docRoot}/doc-files/types/vec_vector.html">vec:vector</a>)
112+
* @param k The zero-based index of vector1 to return. (of <a href="{@docRoot}/doc-files/types/xs_unsignedInt.html">xs:unsignedInt</a>)
113+
* @return a server expression with the <a href="{@docRoot}/doc-files/types/xs_float.html">xs:float</a> server data type
114+
*/
115+
public ServerExpression get(ServerExpression vector1, ServerExpression k);
116+
/**
117+
* Returns the magnitude of the vector.
118+
*
119+
* <a name="ml-server-type-magnitude"></a>
120+
121+
* <p>
122+
* Provides a client interface to the <a href="http://docs.marklogic.com/vec:magnitude" target="mlserverdoc">vec:magnitude</a> server function.
123+
* @param vector1 The vector to find the magnitude of. (of <a href="{@docRoot}/doc-files/types/vec_vector.html">vec:vector</a>)
124+
* @return a server expression with the <a href="{@docRoot}/doc-files/types/xs_double.html">xs:double</a> server data type
125+
*/
126+
public ServerExpression magnitude(ServerExpression vector1);
127+
/**
128+
* Returns the vector passed in, normalized to a length of 1.
129+
*
130+
* <a name="ml-server-type-normalize"></a>
131+
132+
* <p>
133+
* Provides a client interface to the <a href="http://docs.marklogic.com/vec:normalize" target="mlserverdoc">vec:normalize</a> server function.
134+
* @param vector1 The vector to normalize. (of <a href="{@docRoot}/doc-files/types/vec_vector.html">vec:vector</a>)
135+
* @return a server expression with the <a href="{@docRoot}/doc-files/types/vec_vector.html">vec:vector</a> server data type
136+
*/
137+
public ServerExpression normalize(ServerExpression vector1);
138+
public ServerExpression subtract(ServerExpression vector1, ServerExpression vector2);
139+
/**
140+
* Returns a subvector of the input vector, starting at the specified index and with the specified length.
141+
*
142+
* <a name="ml-server-type-subvector"></a>
143+
144+
* <p>
145+
* Provides a client interface to the <a href="http://docs.marklogic.com/vec:subvector" target="mlserverdoc">vec:subvector</a> server function.
146+
* @param vector The input vector. (of <a href="{@docRoot}/doc-files/types/vec_vector.html">vec:vector</a>)
147+
* @param start The starting index of the subvector (inclusive). (of <a href="{@docRoot}/doc-files/types/xs_unsignedInt.html">xs:unsignedInt</a>)
148+
* @param length The length of the subvector. (of <a href="{@docRoot}/doc-files/types/xs_unsignedInt.html">xs:unsignedInt</a>)
149+
* @return a server expression with the <a href="{@docRoot}/doc-files/types/vec_vector.html">vec:vector</a> server data type
150+
*/
151+
public ServerExpression subvector(ServerExpression vector, ServerExpression start, ServerExpression length);
152+
/**
153+
* Returns a vector value.
154+
*
155+
* <a name="ml-server-type-vector"></a>
156+
157+
* <p>
158+
* Provides a client interface to the <a href="http://docs.marklogic.com/vec:vector" target="mlserverdoc">vec:vector</a> server function.
159+
* @param values The values to create the vector from. Can be a sequence or json:array of integer or floating-point numbers. (of <a href="{@docRoot}/doc-files/types/xs_anyAtomicType.html">xs:anyAtomicType</a>)
160+
* @return a server expression with the <a href="{@docRoot}/doc-files/types/vec_vector.html">vec:vector</a> server data type
161+
*/
162+
public ServerExpression vector(ServerExpression values);
163+
/**
164+
* A helper function that returns the hybrid score using a cts:score and a vector similarity function. You can tune the effect of the vector similarity on the score using the "similarity-weight" option.
165+
* <p>
166+
* Provides a client interface to the <a href="http://docs.marklogic.com/vec:vector-score" target="mlserverdoc">vec:vector-score</a> server function.
167+
* @param score The cts:score of the matching document. (of <a href="{@docRoot}/doc-files/types/xs_unsignedInt.html">xs:unsignedInt</a>)
168+
* @param similarity The similarity between the vector in the matching document and the query vector. The result of a call to ovec:cosine-similarity() or op.vec.cosineSimilarity(). In the case that the vectors are normalized, pass ovec:dot-product() or op.vec.dotProduct(). Note that vec:euclideanDistance() should not be used here. (of <a href="{@docRoot}/doc-files/types/xs_double.html">xs:double</a>)
169+
* @return a server expression with the <a href="{@docRoot}/doc-files/types/xs_unsignedInt.html">xs:unsignedInt</a> server data type
170+
*/
171+
public ServerExpression vectorScore(ServerExpression score, double similarity);
172+
/**
173+
* A helper function that returns the hybrid score using a cts:score and a vector similarity function. You can tune the effect of the vector similarity on the score using the "similarity-weight" option.
174+
*
175+
* <a name="ml-server-type-vector-score"></a>
176+
177+
* <p>
178+
* Provides a client interface to the <a href="http://docs.marklogic.com/vec:vector-score" target="mlserverdoc">vec:vector-score</a> server function.
179+
* @param score The cts:score of the matching document. (of <a href="{@docRoot}/doc-files/types/xs_unsignedInt.html">xs:unsignedInt</a>)
180+
* @param similarity The similarity between the vector in the matching document and the query vector. The result of a call to ovec:cosine-similarity() or op.vec.cosineSimilarity(). In the case that the vectors are normalized, pass ovec:dot-product() or op.vec.dotProduct(). Note that vec:euclideanDistance() should not be used here. (of <a href="{@docRoot}/doc-files/types/xs_double.html">xs:double</a>)
181+
* @return a server expression with the <a href="{@docRoot}/doc-files/types/xs_unsignedInt.html">xs:unsignedInt</a> server data type
182+
*/
183+
public ServerExpression vectorScore(ServerExpression score, ServerExpression similarity);
184+
/**
185+
* A helper function that returns the hybrid score using a cts:score and a vector similarity function. You can tune the effect of the vector similarity on the score using the "similarity-weight" option.
186+
* <p>
187+
* Provides a client interface to the <a href="http://docs.marklogic.com/vec:vector-score" target="mlserverdoc">vec:vector-score</a> server function.
188+
* @param score The cts:score of the matching document. (of <a href="{@docRoot}/doc-files/types/xs_unsignedInt.html">xs:unsignedInt</a>)
189+
* @param similarity The similarity between the vector in the matching document and the query vector. The result of a call to ovec:cosine-similarity() or op.vec.cosineSimilarity(). In the case that the vectors are normalized, pass ovec:dot-product() or op.vec.dotProduct(). Note that vec:euclideanDistance() should not be used here. (of <a href="{@docRoot}/doc-files/types/xs_double.html">xs:double</a>)
190+
* @param similarityWeight The weight of the vector similarity on the score. The default value is 1.0. Values less than or equal to zero have no effect. (of <a href="{@docRoot}/doc-files/types/xs_double.html">xs:double</a>)
191+
* @return a server expression with the <a href="{@docRoot}/doc-files/types/xs_unsignedInt.html">xs:unsignedInt</a> server data type
192+
*/
193+
public ServerExpression vectorScore(ServerExpression score, double similarity, double similarityWeight);
194+
/**
195+
* A helper function that returns the hybrid score using a cts:score and a vector similarity function. You can tune the effect of the vector similarity on the score using the "similarity-weight" option.
196+
* <p>
197+
* Provides a client interface to the <a href="http://docs.marklogic.com/vec:vector-score" target="mlserverdoc">vec:vector-score</a> server function.
198+
* @param score The cts:score of the matching document. (of <a href="{@docRoot}/doc-files/types/xs_unsignedInt.html">xs:unsignedInt</a>)
199+
* @param similarity The similarity between the vector in the matching document and the query vector. The result of a call to ovec:cosine-similarity() or op.vec.cosineSimilarity(). In the case that the vectors are normalized, pass ovec:dot-product() or op.vec.dotProduct(). Note that vec:euclideanDistance() should not be used here. (of <a href="{@docRoot}/doc-files/types/xs_double.html">xs:double</a>)
200+
* @param similarityWeight The weight of the vector similarity on the score. The default value is 1.0. Values less than or equal to zero have no effect. (of <a href="{@docRoot}/doc-files/types/xs_double.html">xs:double</a>)
201+
* @return a server expression with the <a href="{@docRoot}/doc-files/types/xs_unsignedInt.html">xs:unsignedInt</a> server data type
202+
*/
203+
public ServerExpression vectorScore(ServerExpression score, ServerExpression similarity, ServerExpression similarityWeight);
204+
}

0 commit comments

Comments
 (0)