Skip to content

Commit 43ac079

Browse files
Ajit GeorgeAjit George
authored andcommitted
Modified addRangeElementIndex, addRangePathIndex and
setupAppServicesConstraint to have tests run faster
1 parent 542d6b9 commit 43ac079

File tree

1 file changed

+106
-17
lines changed

1 file changed

+106
-17
lines changed

test-complete/src/test/java/com/marklogic/client/functionaltest/ConnectedRESTQA.java

Lines changed: 106 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1103,6 +1103,36 @@ public static void addRangeElementIndex(String dbName, String type, String name
11031103
setDatabaseProperties(dbName,"range-element-index",mainNode);
11041104

11051105
}
1106+
1107+
public static void addRangeElementIndex(String dbName, String[][] rangeElements) throws Exception {
1108+
ObjectMapper mapper = new ObjectMapper();
1109+
ObjectNode mainNode = mapper.createObjectNode();
1110+
1111+
ArrayNode childArray = mapper.createArrayNode();
1112+
int nRowsLen = rangeElements.length;
1113+
int j = 0;
1114+
for (int i = 0; i < nRowsLen; i++) {
1115+
ObjectNode childNodeObject = mapper.createObjectNode();
1116+
childNodeObject.put("scalar-type", rangeElements[i][j++]);
1117+
childNodeObject.put("namespace-uri", rangeElements[i][j++]);
1118+
childNodeObject.put("localname", rangeElements[i][j++]);
1119+
childNodeObject.put("collation", rangeElements[i][j++]);
1120+
if (rangeElements[i][j].equalsIgnoreCase("false"))
1121+
childNodeObject.put("range-value-positions", false);
1122+
else
1123+
childNodeObject.put("range-value-positions", true);
1124+
j++;
1125+
childNodeObject.put("invalid-values", rangeElements[i][j++]);
1126+
/* if new field elements are to be added, then:
1127+
* 1) Increment value of j
1128+
* 2) add them below here using childNodeObject.put("FIELD-NAME", rangeElements[i][j++]);
1129+
*/
1130+
childArray.add(childNodeObject);
1131+
j = 0;
1132+
}
1133+
mainNode.putArray("range-element-index").addAll(childArray);
1134+
setDatabaseProperties(dbName,"range-element-index",mainNode);
1135+
}
11061136

11071137

11081138
/*
@@ -1222,6 +1252,38 @@ public static void addRangePathIndex(String dbName, String type, String pathexpr
12221252
setDatabaseProperties(dbName,"range-path-index",childNode);
12231253

12241254
}
1255+
1256+
public static void addRangePathIndex(String dbName, String[][] rangePaths) throws Exception {
1257+
1258+
ObjectMapper mapper = new ObjectMapper();
1259+
ObjectNode childNode = mapper.createObjectNode();
1260+
ArrayNode childArray = mapper.createArrayNode();
1261+
1262+
int nRowsLen = rangePaths.length;
1263+
int j = 0;
1264+
for (int i = 0; i < nRowsLen; i++) {
1265+
ObjectNode childNodeObject = mapper.createObjectNode();
1266+
childNodeObject.put("scalar-type", rangePaths[i][j++]);
1267+
childNodeObject.put("path-expression", rangePaths[i][j++]);
1268+
childNodeObject.put("collation", rangePaths[i][j++]);
1269+
childNodeObject.put("invalid-values", rangePaths[i][j++]);
1270+
1271+
if (rangePaths[i][j].equalsIgnoreCase("false"))
1272+
childNodeObject.put("range-value-positions", false);
1273+
else
1274+
childNodeObject.put("range-value-positions", true);
1275+
/* if new field elements are to be added, then:
1276+
* 1) Increment value of j
1277+
* 2) add them below here using childNodeObject.put("FIELD-NAME", rangePaths[i][j++]);
1278+
*/
1279+
1280+
childArray.add(childNodeObject);
1281+
j = 0;
1282+
}
1283+
childNode.putArray("range-path-index").addAll(childArray);
1284+
1285+
setDatabaseProperties(dbName,"range-path-index",childNode);
1286+
}
12251287
public static void addGeospatialElementIndexes(String dbName,String localname,String namespace,String coordinateSystem,String pointFormat,boolean rangeValuePositions,String invalidValues) throws Exception{
12261288
ObjectMapper mapper = new ObjectMapper();
12271289
// ObjectNode mainNode = mapper.createObjectNode();
@@ -1480,22 +1542,7 @@ public static void includeElementFieldWithWeight(String dbName, String field_nam
14801542
setDatabaseFieldProperties(dbName,field_name,"included-element",childNode);
14811543

14821544
}
1483-
public static void setupAppServicesConstraint(String dbName) throws Exception {
1484-
enableCollectionLexicon(dbName);
1485-
enableWordLexicon(dbName);
1486-
addRangeElementIndex(dbName, "date", "http://purl.org/dc/elements/1.1/", "date");
1487-
addRangeElementIndex(dbName, "int", "", "popularity");
1488-
addRangeElementIndex(dbName, "int", "http://test.tups.com", "rate");
1489-
addRangeElementIndex(dbName, "decimal", "http://test.aggr.com", "score");
1490-
addRangeElementIndex(dbName, "string", "", "title", "http://marklogic.com/collation/");
1491-
addRangeElementAttributeIndex(dbName, "decimal", "http://cloudbank.com", "price", "", "amt", "http://marklogic.com/collation/");
1492-
enableTrailingWildcardSearches(dbName);
1493-
addFieldExcludeRoot(dbName, "para");
1494-
includeElementFieldWithWeight(dbName, "para", "", "p", 5,"","","");
1495-
addRangePathIndex(dbName, "string", "/Employee/fn", "http://marklogic.com/collation/", "ignore");
1496-
addRangePathIndex(dbName, "int", "/root/popularity", "", "ignore");
1497-
addRangePathIndex(dbName, "decimal", "//@amt", "", "ignore");
1498-
}
1545+
14991546
public static void setupAppServicesGeoConstraint(String dbName) throws Exception {
15001547
enableCollectionLexicon(dbName);
15011548
addRangeElementIndex(dbName, "dateTime", "", "bday", "http://marklogic.com/collation/");
@@ -1507,7 +1554,49 @@ public static void setupAppServicesGeoConstraint(String dbName) throws Exception
15071554
addBuiltInGeoIndex(dbName);
15081555

15091556
}
1510-
1557+
1558+
public static void setupAppServicesConstraint(String dbName) throws Exception {
1559+
// Add new range elements into this array
1560+
String[][] rangeElements = {
1561+
//{ scalar-type, namespace-uri, localname, collation, range-value-positions, invalid-values }
1562+
// If there is a need to add additional fields, then add them to the end of each array
1563+
// and pass empty strings ("") into an array where the additional field does not have a value.
1564+
// For example : as in namespace, collections below.
1565+
{ "date", "http://purl.org/dc/elements/1.1/", "date", "", "false", "reject" },
1566+
{ "int", "", "popularity", "", "false", "reject" },
1567+
{ "int", "http://test.tups.com", "rate", "", "false", "reject" },
1568+
{ "decimal", "http://test.aggr.com", "score", "", "false", "reject" },
1569+
{ "string", "", "title", "http://marklogic.com/collation/", "false", "reject" }
1570+
// Add new RangeElementIndex as an array below.
1571+
};
1572+
1573+
//Add new path elements into this array
1574+
String[][] rangePaths = {
1575+
//{ scalar-type, path-expression, collation, range-value-positions, invalid-values }
1576+
// If there is a need to add additional fields, then add them to the end of each array
1577+
// and pass empty strings ("") into an array where the additional field does not have a value.
1578+
// For example : as in namespace, collections below.
1579+
{ "string", "/Employee/fn", "http://marklogic.com/collation/", "ignore", "false"},
1580+
{ "int", "/root/popularity", "", "ignore", "false"},
1581+
{ "decimal", "//@amt", "", "ignore", "false" }
1582+
// Add new RangePathIndex as an array below.
1583+
};
1584+
1585+
enableCollectionLexicon(dbName);
1586+
enableWordLexicon(dbName);
1587+
1588+
// Insert the range indices
1589+
addRangeElementIndex(dbName, rangeElements);
1590+
1591+
addRangeElementAttributeIndex(dbName, "decimal", "http://cloudbank.com", "price", "", "amt", "http://marklogic.com/collation/");
1592+
enableTrailingWildcardSearches(dbName);
1593+
addFieldExcludeRoot(dbName, "para");
1594+
includeElementFieldWithWeight(dbName, "para", "", "p", 5,"","","");
1595+
1596+
// Insert the path range indices
1597+
addRangePathIndex(dbName, rangePaths);
1598+
}
1599+
15111600
/*
15121601
* Create a temporal axis based on 2 element range indexes, for start and end values (for system or valid axis)
15131602
* @dbName Database Name

0 commit comments

Comments
 (0)