Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1487,72 +1487,4 @@ public void testShortestPathWithStringInputs()
assertEquals("1",path.path("length").path("value").toString());
}
}

// TODO: Enable testShortestPathWithWeight and testShortestPathWithWeightColumn tests after server code starts
// accepting weight column and string.
@Disabled
@Test
public void testShortestPathWithWeight()
{
if(!isML12OrHigher){
return;
}

RowManager rowMgr = client.newRowManager();
PlanBuilder p = rowMgr.newPlanBuilder();

PlanColumn teamIdCol = p.col("player_team");
PlanColumn teamNameCol = p.col("team_name");
PlanColumn teamCityCol = p.col("team_city");

PlanPrefixer team = p.prefixer("http://marklogic.com/mlb/team/");
PlanBuilder.ModifyPlan team_plan = p.fromTriples(
p.pattern(teamIdCol, team.iri("name"), teamNameCol),
p.pattern(teamIdCol, team.iri("city"), teamCityCol)
).shortestPath("team_name", "team_city", "path", "length", "weight");
JacksonHandle jacksonHandle = new JacksonHandle().withMimetype("application/json");
rowMgr.resultDoc(team_plan, jacksonHandle);
JsonNode jsonResults = jacksonHandle.get();
JsonNode jsonBindingsNodes = jsonResults.path("rows");
for (int i=0; i<jsonBindingsNodes.size(); i++){
JsonNode path = jsonBindingsNodes.path(i);
assertNotNull(path.path("team_name"));
assertNotNull(path.path("team_city"));
assertNotNull(path.path("path"));
assertEquals("1",path.path("length").path("value").toString());
}
}

@Disabled
@Test
public void testShortestPathWithWeightColumn()
{
if(!isML12OrHigher){
return;
}

RowManager rowMgr = client.newRowManager();
PlanBuilder p = rowMgr.newPlanBuilder();

PlanColumn teamIdCol = p.col("player_team");
PlanColumn teamNameCol = p.col("team_name");
PlanColumn teamCityCol = p.col("team_city");

PlanPrefixer team = p.prefixer("http://marklogic.com/mlb/team/");
PlanBuilder.ModifyPlan team_plan = p.fromTriples(
p.pattern(teamIdCol, team.iri("name"), teamNameCol),
p.pattern(teamIdCol, team.iri("city"), teamCityCol)
).shortestPath(p.col("team_name"), p.col("team_city"), p.col("path"), p.col("length"), p.col("weight"));
JacksonHandle jacksonHandle = new JacksonHandle().withMimetype("application/json");
rowMgr.resultDoc(team_plan, jacksonHandle);
JsonNode jsonResults = jacksonHandle.get();
JsonNode jsonBindingsNodes = jsonResults.path("rows");
for (int i=0; i<jsonBindingsNodes.size(); i++){
JsonNode path = jsonBindingsNodes.path(i);
assertNotNull(path.path("team_name"));
assertNotNull(path.path("team_city"));
assertNotNull(path.path("path"));
assertEquals("1",path.path("length").path("value").toString());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2030,28 +2030,6 @@ public interface ModifyPlan extends PreparePlan, PlanBuilderBase.ModifyPlanBase
* @since 7.1.0; requires MarkLogic 12
*/
public abstract ModifyPlan shortestPath(PlanExprCol start, PlanExprCol end, PlanExprCol path, PlanExprCol length);
/**
* This method can be used to find the shortest path between two nodes in a given graph.
* @param start The column representing the input starting subject of the shortest path search. The columns can be named with a string or a column parameter function such as op:col. See {@link PlanBuilder#col(XsStringVal)}
* @param end The column representing the input ending object of the shortest path search. The columns can be named with a string or a column parameter function such as op:col. See {@link PlanBuilder#col(XsStringVal)}
* @param path The column is the output column representing the actual shortest path(s) taken from start to end. Values are not returned for this column if this is the empty sequence.The columns can be named with a string or a column parameter function such as op:col. See {@link PlanBuilder#col(XsStringVal)}
* @param length The column is the output column representing the length of the shortest path. Value is not returned for this column if this is the empty sequence.The columns can be named with a string or a column parameter function such as op:col. See {@link PlanBuilder#col(XsStringVal)}
* @param weight the weight value. See {@link PlanBuilder#col(XsStringVal)}
* @return a ModifyPlan object
* @since 7.1.0; requires MarkLogic 12
*/
public abstract ModifyPlan shortestPath(String start, String end, String path, String length, String weight);
/**
* This method can be used to find the shortest path between two nodes in a given graph.
* @param start The column representing the input starting subject of the shortest path search. The columns can be named with a string or a column parameter function such as op:col. See {@link PlanBuilder#col(XsStringVal)}
* @param end The column representing the input ending object of the shortest path search. The columns can be named with a string or a column parameter function such as op:col. See {@link PlanBuilder#col(XsStringVal)}
* @param path The column is the output column representing the actual shortest path(s) taken from start to end. Values are not returned for this column if this is the empty sequence.The columns can be named with a string or a column parameter function such as op:col. See {@link PlanBuilder#col(XsStringVal)}
* @param length The column is the output column representing the length of the shortest path. Value is not returned for this column if this is the empty sequence.The columns can be named with a string or a column parameter function such as op:col. See {@link PlanBuilder#col(XsStringVal)}
* @param weight the weight value. See {@link PlanBuilder#col(XsStringVal)}
* @return a ModifyPlan object
* @since 7.1.0; requires MarkLogic 12
*/
public abstract ModifyPlan shortestPath(PlanExprCol start, PlanExprCol end, PlanExprCol path, PlanExprCol length, PlanExprCol weight);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2247,7 +2247,6 @@ public ModifyPlan shortestPath(String start, String end, String path, String len
return shortestPath((start == null) ? (PlanExprCol) null : exprCol(start), (end == null) ? (PlanExprCol) null : exprCol(end), (path == null) ? (PlanExprCol) null : exprCol(path), (length == null) ? (PlanExprCol) null : exprCol(length));
}


@Override
public ModifyPlan shortestPath(PlanExprCol start, PlanExprCol end, PlanExprCol path, PlanExprCol length) {
if (start == null) {
Expand All @@ -2259,25 +2258,6 @@ public ModifyPlan shortestPath(PlanExprCol start, PlanExprCol end, PlanExprCol p
return new PlanBuilderSubImpl.ModifyPlanSubImpl(this, "op", "shortest-path", new Object[]{ start, end, path, length });
}


@Override
public ModifyPlan shortestPath(String start, String end, String path, String length, String weight) {
return shortestPath((start == null) ? (PlanExprCol) null : exprCol(start), (end == null) ? (PlanExprCol) null : exprCol(end), (path == null) ? (PlanExprCol) null : exprCol(path), (length == null) ? (PlanExprCol) null : exprCol(length), (weight == null) ? (PlanExprCol) null : exprCol(weight));
}


@Override
public ModifyPlan shortestPath(PlanExprCol start, PlanExprCol end, PlanExprCol path, PlanExprCol length, PlanExprCol weight) {
if (start == null) {
throw new IllegalArgumentException("start parameter for shortestPath() cannot be null");
}
if (end == null) {
throw new IllegalArgumentException("end parameter for shortestPath() cannot be null");
}
return new PlanBuilderSubImpl.ModifyPlanSubImpl(this, "op", "shortest-path", new Object[]{ start, end, path, length, weight });
}


@Override
public ModifyPlan union(ModifyPlan right) {
if (right == null) {
Expand Down