Skip to content

Commit 8d45fd4

Browse files
Ryan DewSanjeevani19
authored andcommitted
DHFPROD-9050: Additional matching performance updates
1 parent 4dae4ac commit 8d45fd4

File tree

30 files changed

+460
-195
lines changed

30 files changed

+460
-195
lines changed

marklogic-data-hub/src/main/java/com/marklogic/hub/deploy/commands/DeployHubAmpsCommand.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ protected ResourceManager getResourceManager(CommandContext context) {
5252
return new HubAmpManager(context.getManageClient());
5353
}
5454

55-
class HubAmpManager extends AmpManager {
55+
static class HubAmpManager extends AmpManager {
5656

5757
public HubAmpManager(ManageClient client) {
5858
super(client);

marklogic-data-hub/src/main/java/com/marklogic/hub/deploy/commands/LoadUserModulesCommand.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ public void execute(CommandContext context) {
197197
DatabaseClient finalClient = hubConfig.newFinalClient();
198198

199199
Path userModulesPath = hubConfig.getHubPluginsDir();
200-
String baseDir = new String();
200+
String baseDir = "";
201201
String EncodedBaseDir = userModulesPath.normalize().toAbsolutePath().toString();
202202
Path startPath = userModulesPath.resolve("entities");
203203

marklogic-data-hub/src/main/java/com/marklogic/hub/flow/impl/FlowRunnerImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -595,7 +595,7 @@ public Flow getRunningFlow() {
595595
return this.runningFlow;
596596
}
597597

598-
class FlowContext {
598+
static class FlowContext {
599599
boolean jobOutputIsEnabled = true;
600600
JobService jobService;
601601

marklogic-data-hub/src/main/java/com/marklogic/hub/impl/DataHubImpl.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -459,17 +459,17 @@ public void clearUserArtifacts(){
459459
public List<Command> buildListOfCommands() {
460460
Map<String, List<Command>> commandMap = buildCommandMap();
461461
List<Command> commands = new ArrayList<>();
462-
for (String name : commandMap.keySet()) {
463-
commands.addAll(commandMap.get(name));
462+
for (Map.Entry<String, List<Command>> entry: commandMap.entrySet()) {
463+
commands.addAll(entry.getValue());
464464
}
465465
return commands;
466466
}
467467

468468
public List<Command> getSecurityCommandList() {
469469
Map<String, List<Command>> commandMap = getSecurityCommands();
470470
List<Command> commands = new ArrayList<>();
471-
for (String name : commandMap.keySet()) {
472-
commands.addAll(commandMap.get(name));
471+
for (Map.Entry<String, List<Command>> entry: commandMap.entrySet()) {
472+
commands.addAll(entry.getValue());
473473
}
474474
return commands;
475475
}

marklogic-data-hub/src/main/java/com/marklogic/hub/impl/HubProjectImpl.java

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,15 @@
2929
import org.springframework.core.io.Resource;
3030
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
3131
import org.springframework.util.FileCopyUtils;
32-
import java.io.*;
32+
33+
import java.io.File;
34+
import java.io.FileInputStream;
35+
import java.io.FileOutputStream;
36+
import java.io.FileWriter;
37+
import java.io.IOException;
38+
import java.io.InputStream;
39+
import java.io.OutputStream;
40+
import java.nio.charset.Charset;
3341
import java.nio.file.Files;
3442
import java.nio.file.Path;
3543
import java.nio.file.Paths;
@@ -403,12 +411,11 @@ private void writeResourceFileWithReplace(Map<String, String> customTokens, Stri
403411
logger.debug("Getting file with replace: " + srcFile);
404412
inputStream = HubProject.class.getClassLoader().getResourceAsStream(srcFile);
405413

406-
String fileContents = IOUtils.toString(inputStream);
407-
for (String key : customTokens.keySet()) {
408-
409-
String value = customTokens.get(key);
414+
String fileContents = IOUtils.toString(inputStream, Charset.defaultCharset());
415+
for (Map.Entry<String, String> entry : customTokens.entrySet()) {
416+
String value = entry.getValue();
410417
if (value != null) {
411-
fileContents = fileContents.replace(key, value);
418+
fileContents = fileContents.replace(entry.getKey(), value);
412419
}
413420
}
414421
try(FileWriter writer = new FileWriter(dstFile.toFile())) {

marklogic-data-hub/src/main/java/com/marklogic/hub/impl/ScaffoldingImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ private String getFileContent(String srcFile, String placeholder) {
448448
return output.toString();
449449
}
450450

451-
public class ContentPlugin extends ResourceManager {
451+
public static class ContentPlugin extends ResourceManager {
452452
private static final String NAME = "mlScaffoldContent";
453453

454454
private RequestParameters params = new RequestParameters();

marklogic-data-hub/src/main/java/com/marklogic/hub/util/json/JSONObject.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -360,8 +360,8 @@ public String convertMapToJsonString(Map<String, Object> map) throws JsonProcess
360360
* @param map a map of (String, Object)
361361
*/
362362
public void putMap(Map<String, Object> map) {
363-
for (String key : map.keySet()) {
364-
put(key, map.get(key));
363+
for (Map.Entry<String, Object> entry : map.entrySet()) {
364+
put(entry.getKey(), entry.getValue());
365365
}
366366
}
367367

marklogic-data-hub/src/main/resources/ml-modules/root/com.marklogic.smart-mastering/algorithms/thesaurus.xqy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ declare function algorithms:thesaurus(
2626
{
2727
let $expand-options := fn:head(($expand/options, $expand))
2828
let $thesaurus := $expand-options/(*:thesaurus|thesaurusURI)
29-
let $original-values := $expand-values ! fn:string(.)[. ne '']
29+
let $original-values := $expand-values ! fn:string(.) ! (., fn:lower-case(.))[. ne '']
3030
where fn:exists($thesaurus) and fn:exists($original-values)
3131
return
3232
let $expand-options := fn:head(($expand/options, $expand))

marklogic-data-hub/src/main/resources/ml-modules/root/com.marklogic.smart-mastering/impl/process.xqy

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ declare function proc-impl:build-match-summary(
369369
let $archived-collection := coll:archived-collections($match-options-node)
370370
let $normalized-input :=
371371
if ($input instance of xs:string*) then
372-
for $doc in cts:search(fn:doc(), cts:and-not-query(cts:document-query($input), cts:collection-query($archived-collection)), "unfiltered")
372+
for $doc in cts:search(fn:doc(), cts:and-not-query(cts:document-query($input), cts:collection-query($archived-collection)), ("unfiltered", "score-zero"), 0)
373373
return
374374
util-impl:build-write-object-for-doc($doc)
375375
else if ($input instance of map:map*) then
@@ -648,6 +648,8 @@ declare function proc-impl:build-match-summary(
648648
=> map:with(
649649
"matchSummary",
650650
map:map()
651+
=> map:with("matchStepFlow", fn:string($match-options-node/flow))
652+
=> map:with("matchStepName", fn:string($match-options-node/stepName))
651653
=> map:with("URIsToProcess",
652654
json:to-array(fn:distinct-values(($no-matches-uris,map:keys($action-details)))))
653655
=> map:with("actionDetails", $action-details)
@@ -682,7 +684,7 @@ declare function proc-impl:process-match-and-merge-with-options(
682684
let $archived-collection := coll:archived-collections($matching-options)
683685
let $normalized-input :=
684686
if ($input instance of xs:string*) then
685-
for $doc in cts:search(fn:doc(), cts:and-not-query(cts:document-query($input), cts:collection-query($archived-collection)), "unfiltered")
687+
for $doc in cts:search(fn:doc(), cts:and-not-query(cts:document-query($input), cts:collection-query($archived-collection)), ("unfiltered", "score-zero"), 0)
686688
return
687689
util-impl:build-write-object-for-doc($doc)
688690
else if ($input instance of map:map*) then

marklogic-data-hub/src/main/resources/ml-modules/root/com.marklogic.smart-mastering/impl/sm-es-impl.xqy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ declare function es-impl:get-entity-property-info($entity-type-iri as xs:string)
181181
$entity-properties-by-model-iri => map:get($entity-model-iri) => map:get($entity-type-title)
182182
else
183183
let $entity-model-descriptor := fn:head(cts:search(fn:collection("http://marklogic.com/entity-services/models"),
184-
cts:triple-range-query(sem:iri($entity-type-iri), sem:curie-expand("rdf:type"), sem:iri("http://marklogic.com/entity-services#EntityType"), "=")))
184+
cts:triple-range-query(sem:iri($entity-type-iri), sem:curie-expand("rdf:type"), sem:iri("http://marklogic.com/entity-services#EntityType"), "="), ("score-zero"), 0))
185185
let $entity-descriptor-maps := map:map()
186186
let $entity-property-info := es-impl:get-definition-properties($entity-model-descriptor, $entity-descriptor-maps, $entity-type-title, get-entity-type-namespaces($entity-type-iri))
187187
return (

0 commit comments

Comments
 (0)