Skip to content

Commit b10f638

Browse files
author
ehennum
committed
#1294 bind(), existsJoin(), notExistsJoin(), sem.defaultGraphIri()
1 parent 81bbae1 commit b10f638

File tree

6 files changed

+191
-4
lines changed

6 files changed

+191
-4
lines changed

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

Lines changed: 74 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ protected PlanBuilder(
322322
public abstract PlanExprColSeq colSeq(String... col);
323323
/**
324324
* Passes multiple columns as a parameter to an operation.
325-
* @param col the columns. See {@link PlanBuilder#col(String)} and {@link PlanBuilder#as(String, ServerExpression)}
325+
* @param col the columns. See {@link PlanBuilder#col(String)} and {@link PlanBuilder#as(String, ServerExpression)}
326326
* @return the sequence of columns
327327
*/
328328
public abstract PlanExprColSeq colSeq(PlanExprCol... col);
@@ -1276,6 +1276,7 @@ public interface ExportablePlan extends Plan, PlanBuilderBase.ExportablePlanBase
12761276
* of the plan for executing a row pipeline on the server.
12771277
*/
12781278
public interface ModifyPlan extends PreparePlan, PlanBuilderBase.ModifyPlanBase {
1279+
public abstract ModifyPlan bind(PlanExprColSeq columns);
12791280
/**
12801281
* This function adds a column based on an expression without altering the existing columns in the row set.
12811282
* @param column The name of the column to be defined.
@@ -1296,6 +1297,42 @@ public interface ModifyPlan extends PreparePlan, PlanBuilderBase.ModifyPlanBase
12961297
* @return a ModifyPlan object
12971298
*/
12981299
public abstract ModifyPlan except(ModifyPlan right);
1300+
/**
1301+
* This method is a filtering join that filters based on whether the join exists or not but doesn't add any columns.
1302+
* @param right The row set from the right view.
1303+
* @return a ModifyPlan object
1304+
*/
1305+
public abstract ModifyPlan existsJoin(ModifyPlan right);
1306+
/**
1307+
* This method is a filtering join that filters based on whether the join exists or not but doesn't add any columns.
1308+
* @param right The row set from the right view.
1309+
* @param keys The equijoin from one or more calls to the op:on function.
1310+
* @return a ModifyPlan object
1311+
*/
1312+
public abstract ModifyPlan existsJoin(ModifyPlan right, PlanJoinKey... keys);
1313+
/**
1314+
* This method is a filtering join that filters based on whether the join exists or not but doesn't add any columns.
1315+
* @param right The row set from the right view.
1316+
* @param keys The equijoin from one or more calls to the op:on function.
1317+
* @return a ModifyPlan object
1318+
*/
1319+
public abstract ModifyPlan existsJoin(ModifyPlan right, PlanJoinKeySeq keys);
1320+
/**
1321+
* This method is a filtering join that filters based on whether the join exists or not but doesn't add any columns.
1322+
* @param right The row set from the right view.
1323+
* @param keys The equijoin from one or more calls to the op:on function.
1324+
* @param condition A boolean expression that filters the join output rows. (of <a href="{@docRoot}/doc-files/types/xs_boolean.html">xs:boolean</a>)
1325+
* @return a ModifyPlan object
1326+
*/
1327+
public abstract ModifyPlan existsJoin(ModifyPlan right, PlanJoinKeySeq keys, boolean condition);
1328+
/**
1329+
* This method is a filtering join that filters based on whether the join exists or not but doesn't add any columns.
1330+
* @param right The row set from the right view.
1331+
* @param keys The equijoin from one or more calls to the op:on function.
1332+
* @param condition A boolean expression that filters the join output rows. (of <a href="{@docRoot}/doc-files/types/xs_boolean.html">xs:boolean</a>)
1333+
* @return a ModifyPlan object
1334+
*/
1335+
public abstract ModifyPlan existsJoin(ModifyPlan right, PlanJoinKeySeq keys, ServerExpression condition);
12991336
/**
13001337
* This method counts values for multiple grouping key columns.
13011338
* @param keys This parameter specifies the list of column keys for performing counts. For each column, the operation determines the unique values of that column and produces a separate count for the rows with that value. A column can be named with a string or a column parameter function such as op:col or constructed from an expression with the op:as function. See {@link PlanBuilder#colSeq(String...)}
@@ -1491,6 +1528,42 @@ public interface ModifyPlan extends PreparePlan, PlanBuilderBase.ModifyPlanBase
14911528
* @return a ModifyPlan object
14921529
*/
14931530
public abstract ModifyPlan joinFullOuter(ModifyPlan right, PlanJoinKeySeq keys, ServerExpression condition);
1531+
/**
1532+
* This method is a filtering join that filters based on whether the join exists or not but doesn't add any columns.
1533+
* @param right The row set from the right view.
1534+
* @return a ModifyPlan object
1535+
*/
1536+
public abstract ModifyPlan notExistsJoin(ModifyPlan right);
1537+
/**
1538+
* This method is a filtering join that filters based on whether the join exists or not but doesn't add any columns.
1539+
* @param right The row set from the right view.
1540+
* @param keys The equijoin from one or more calls to the op:on function.
1541+
* @return a ModifyPlan object
1542+
*/
1543+
public abstract ModifyPlan notExistsJoin(ModifyPlan right, PlanJoinKey... keys);
1544+
/**
1545+
* This method is a filtering join that filters based on whether the join exists or not but doesn't add any columns.
1546+
* @param right The row set from the right view.
1547+
* @param keys The equijoin from one or more calls to the op:on function.
1548+
* @return a ModifyPlan object
1549+
*/
1550+
public abstract ModifyPlan notExistsJoin(ModifyPlan right, PlanJoinKeySeq keys);
1551+
/**
1552+
* This method is a filtering join that filters based on whether the join exists or not but doesn't add any columns.
1553+
* @param right The row set from the right view.
1554+
* @param keys The equijoin from one or more calls to the op:on function.
1555+
* @param condition A boolean expression that filters the join output rows. (of <a href="{@docRoot}/doc-files/types/xs_boolean.html">xs:boolean</a>)
1556+
* @return a ModifyPlan object
1557+
*/
1558+
public abstract ModifyPlan notExistsJoin(ModifyPlan right, PlanJoinKeySeq keys, boolean condition);
1559+
/**
1560+
* This method is a filtering join that filters based on whether the join exists or not but doesn't add any columns.
1561+
* @param right The row set from the right view.
1562+
* @param keys The equijoin from one or more calls to the op:on function.
1563+
* @param condition A boolean expression that filters the join output rows. (of <a href="{@docRoot}/doc-files/types/xs_boolean.html">xs:boolean</a>)
1564+
* @return a ModifyPlan object
1565+
*/
1566+
public abstract ModifyPlan notExistsJoin(ModifyPlan right, PlanJoinKeySeq keys, ServerExpression condition);
14941567
/**
14951568
* This method sorts the row set by the specified order definition.
14961569
* @param keys The specified column or sortdef output from the op:asc or op:desc function. See {@link PlanBuilder#sortKeySeq(PlanSortKey...)}

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,16 @@ public interface SemExpr extends SemValue {
7575
* @return a server expression with the <a href="{@docRoot}/doc-files/types/sem_iri.html">sem:iri</a> server data type
7676
*/
7777
public ServerExpression datatype(ServerExpression value);
78+
/**
79+
* Returns the iri of the default graph.
80+
*
81+
* <a name="ml-server-type-default-graph-iri"></a>
82+
83+
* <p>
84+
* Provides a client interface to the <a href="http://docs.marklogic.com/sem:default-graph-iri" target="mlserverdoc">sem:default-graph-iri</a> server function.
85+
* @return a server expression with the <a href="{@docRoot}/doc-files/types/sem_iri.html">sem:iri</a> server data type
86+
*/
87+
public ServerExpression defaultGraphIri();
7888
/**
7989
* The IF function form evaluates the first argument, interprets it as a effective boolean value, then returns the value of expression2 if the EBV is true, otherwise it returns the value of expression3. Only one of expression2 and expression3 is evaluated. If evaluating the first argument raises an error, then an error is raised for the evaluation of the IF expression. This XQuery function backs up the SPARQL IF() functional form.
8090
*

marklogic-client-api/src/main/java/com/marklogic/client/impl/PlanBuilderImpl.java

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1539,6 +1539,15 @@ static abstract class ModifyPlanImpl extends PlanBuilderSubImpl.PreparePlanSubIm
15391539
}
15401540

15411541

1542+
@Override
1543+
public ModifyPlan bind(PlanExprColSeq columns) {
1544+
if (columns == null) {
1545+
throw new IllegalArgumentException("columns parameter for bind() cannot be null");
1546+
}
1547+
return new PlanBuilderSubImpl.ModifyPlanSubImpl(this, "op", "bind", new Object[]{ columns });
1548+
}
1549+
1550+
15421551
@Override
15431552
public ModifyPlan bindAs(String column, ServerExpression expression) {
15441553
return bindAs((column == null) ? (PlanColumn) null : col(column), expression);
@@ -1563,6 +1572,45 @@ public ModifyPlan except(ModifyPlan right) {
15631572
}
15641573

15651574

1575+
@Override
1576+
public ModifyPlan existsJoin(ModifyPlan right) {
1577+
if (right == null) {
1578+
throw new IllegalArgumentException("right parameter for existsJoin() cannot be null");
1579+
}
1580+
return new PlanBuilderSubImpl.ModifyPlanSubImpl(this, "op", "exists-join", new Object[]{ right });
1581+
}
1582+
1583+
1584+
@Override
1585+
public ModifyPlan existsJoin(ModifyPlan right, PlanJoinKey... keys) {
1586+
return existsJoin(right, new JoinKeySeqListImpl(keys));
1587+
}
1588+
1589+
1590+
@Override
1591+
public ModifyPlan existsJoin(ModifyPlan right, PlanJoinKeySeq keys) {
1592+
if (right == null) {
1593+
throw new IllegalArgumentException("right parameter for existsJoin() cannot be null");
1594+
}
1595+
return new PlanBuilderSubImpl.ModifyPlanSubImpl(this, "op", "exists-join", new Object[]{ right, keys });
1596+
}
1597+
1598+
1599+
@Override
1600+
public ModifyPlan existsJoin(ModifyPlan right, PlanJoinKeySeq keys, boolean condition) {
1601+
return existsJoin(right, keys, xs.booleanVal(condition));
1602+
}
1603+
1604+
1605+
@Override
1606+
public ModifyPlan existsJoin(ModifyPlan right, PlanJoinKeySeq keys, ServerExpression condition) {
1607+
if (right == null) {
1608+
throw new IllegalArgumentException("right parameter for existsJoin() cannot be null");
1609+
}
1610+
return new PlanBuilderSubImpl.ModifyPlanSubImpl(this, "op", "exists-join", new Object[]{ right, keys, condition });
1611+
}
1612+
1613+
15661614
@Override
15671615
public ModifyPlan facetBy(PlanExprColSeq keys) {
15681616
if (keys == null) {
@@ -1785,6 +1833,45 @@ public ModifyPlan joinLeftOuter(ModifyPlan right, PlanJoinKeySeq keys, ServerExp
17851833
}
17861834

17871835

1836+
@Override
1837+
public ModifyPlan notExistsJoin(ModifyPlan right) {
1838+
if (right == null) {
1839+
throw new IllegalArgumentException("right parameter for notExistsJoin() cannot be null");
1840+
}
1841+
return new PlanBuilderSubImpl.ModifyPlanSubImpl(this, "op", "not-exists-join", new Object[]{ right });
1842+
}
1843+
1844+
1845+
@Override
1846+
public ModifyPlan notExistsJoin(ModifyPlan right, PlanJoinKey... keys) {
1847+
return notExistsJoin(right, new JoinKeySeqListImpl(keys));
1848+
}
1849+
1850+
1851+
@Override
1852+
public ModifyPlan notExistsJoin(ModifyPlan right, PlanJoinKeySeq keys) {
1853+
if (right == null) {
1854+
throw new IllegalArgumentException("right parameter for notExistsJoin() cannot be null");
1855+
}
1856+
return new PlanBuilderSubImpl.ModifyPlanSubImpl(this, "op", "not-exists-join", new Object[]{ right, keys });
1857+
}
1858+
1859+
1860+
@Override
1861+
public ModifyPlan notExistsJoin(ModifyPlan right, PlanJoinKeySeq keys, boolean condition) {
1862+
return notExistsJoin(right, keys, xs.booleanVal(condition));
1863+
}
1864+
1865+
1866+
@Override
1867+
public ModifyPlan notExistsJoin(ModifyPlan right, PlanJoinKeySeq keys, ServerExpression condition) {
1868+
if (right == null) {
1869+
throw new IllegalArgumentException("right parameter for notExistsJoin() cannot be null");
1870+
}
1871+
return new PlanBuilderSubImpl.ModifyPlanSubImpl(this, "op", "not-exists-join", new Object[]{ right, keys, condition });
1872+
}
1873+
1874+
17881875
@Override
17891876
public ModifyPlan orderBy(PlanSortKeySeq keys) {
17901877
if (keys == null) {

marklogic-client-api/src/main/java/com/marklogic/client/impl/SemExprImpl.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,12 @@ public ServerExpression datatype(ServerExpression value) {
7272
}
7373

7474

75+
@Override
76+
public ServerExpression defaultGraphIri() {
77+
return new IriCallImpl("sem", "default-graph-iri", new Object[]{ });
78+
}
79+
80+
7581
@Override
7682
public ServerExpression ifExpr(ServerExpression condition, ServerExpression then, ServerExpression elseExpr) {
7783
if (condition == null) {

marklogic-client-api/src/main/javadoc/doc-files/types/sem_iri.html

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,23 +58,29 @@
5858
<td><a href="http://docs.marklogic.com/sem:datatype" target="mlserverdoc">server</a></td>
5959
</tr>
6060
<tr class="rowColor">
61+
<td class="colFirst">sem:iri</td>
62+
<td class="colLast"><span class="memberNameLink">sem:default-graph-iri</span>()</td>
63+
<td><a href="../../com/marklogic/client/expression/SemExpr.html#ml-server-type-default-graph-iri">java</a></td>
64+
<td><a href="http://docs.marklogic.com/sem:default-graph-iri" target="mlserverdoc">server</a></td>
65+
</tr>
66+
<tr class="altColor">
6167
<td class="colFirst">sem:iri</td>
6268
<td class="colLast"><span class="memberNameLink">sem:invalid-datatype</span>(<span><a href="sem_invalid.html">sem:invalid</a> <i>val</i></span>)</td>
6369
<td><a href="../../com/marklogic/client/expression/SemExpr.html#ml-server-type-invalid-datatype">java</a></td>
6470
<td><a href="http://docs.marklogic.com/sem:invalid-datatype" target="mlserverdoc">server</a></td>
6571
</tr>
66-
<tr class="altColor">
72+
<tr class="rowColor">
6773
<td class="colFirst">sem:iri</td>
6874
<td class="colLast"><span class="memberNameLink">sem:QName-to-iri</span>(<span><a href="xs_QName.html">xs:QName</a> <i>arg1</i></span>)</td>
6975
<td><a href="../../com/marklogic/client/expression/SemExpr.html#ml-server-type-QName-to-iri">java</a></td>
7076
</tr>
71-
<tr class="rowColor">
77+
<tr class="altColor">
7278
<td class="colFirst">sem:iri</td>
7379
<td class="colLast"><span class="memberNameLink">sem:unknown-datatype</span>(<span><a href="sem_unknown.html">sem:unknown</a> <i>val</i></span>)</td>
7480
<td><a href="../../com/marklogic/client/expression/SemExpr.html#ml-server-type-unknown-datatype">java</a></td>
7581
<td><a href="http://docs.marklogic.com/sem:unknown-datatype" target="mlserverdoc">server</a></td>
7682
</tr>
77-
<tr class="altColor">
83+
<tr class="rowColor">
7884
<td class="colFirst">sem:iri</td>
7985
<td class="colLast"><span class="memberNameLink">sem:uuid</span>()</td>
8086
<td><a href="../../com/marklogic/client/expression/SemExpr.html#ml-server-type-uuid">java</a></td>

marklogic-client-api/src/test/java/com/marklogic/client/test/PlanGeneratedTest.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -968,6 +968,11 @@ public void testSemDatatype1Exec() {
968968
executeTester("testSemDatatype1", p.sem.datatype(p.col("1")), false, "sem:iri", null, null, "http://www.w3.org/2001/XMLSchema#string", new ServerExpression[]{ p.xs.string("a") });
969969
}
970970

971+
@Test
972+
public void testSemDefaultGraphIri0Exec() {
973+
executeTester("testSemDefaultGraphIri0", p.sem.defaultGraphIri(), false, "sem:iri", null, null, "http://marklogic.com/semantics#default-graph", new ServerExpression[]{ });
974+
}
975+
971976
@Test
972977
public void testSemIfExpr3Exec() {
973978
executeTester("testSemIfExpr3", p.sem.ifExpr(p.col("1"), p.col("2"), p.col("3")), false, null, null, null, "a", new ServerExpression[]{ p.xs.booleanVal(true), p.xs.string("a"), p.xs.string("b") });

0 commit comments

Comments
 (0)