Skip to content

Instantly share code, notes, and snippets.

Avatar

Alex Bleasdale ableasdale

View GitHub Profile
@ableasdale
ableasdale / directory-fragment-delete.xqy
Created Dec 11, 2020
MarkLogic: Remove a problem directory fragment in an event where you encounter XDMP-DBDUPURI issues
View directory-fragment-delete.xqy
xquery version "1.0-ml";
(:
A Utility module to allow the deletion of a directory fragment in a given forest in the event of
an XDMP-DBDUPURI exception.
:)
let $doc := "/" (: URI for the conflicting directory that is causing an XDMP-DBDUPURI to be reported in 2 forests :)
let $forest-name := "forest_00" (: The name of the forest from which the problem directory fragment should be removed :)
@ableasdale
ableasdale / duplicate-uri-lookup.xqy
Created Dec 11, 2020
MarkLogic: Look up duplicate URIs using the URI Lexicon (for troubleshooting XDMP-DBDUPURI exceptions)
View duplicate-uri-lookup.xqy
xquery version "1.0-ml";
(:
A Utility module to allow the detection of duplicate URIs for a given database
This can be used in any situation where XDMP-DBDUPURI messages are found in the ErrorLogs
URIs are sorted by frequency order so higher frequencies (e.g. > 1) indicate that the URI
has been found in more than one forest
This module requires the uri lexicon to be enabled on your database
@ableasdale
ableasdale / delete-one-fragment.xqy
Created Dec 11, 2020
MarkLogic: Delete one document after inspecting both duplicates in the event of an XDMP-DBDUPURI
View delete-one-fragment.xqy
xquery version "1.0-ml";
(:
A Utility module to allow the deletion of a fragment in a given forest in the event of
an XDMP-DBDUPURI exception.
Given the following exception:
XDMP-DBDUPURI: URI /problem/uri.xml found in forests Library06 and Library07
$doc would be set to "/problem/uri.xml"
@ableasdale
ableasdale / duplicate-uri.xqy
Last active Dec 11, 2020
MarkLogic: Manual inspection of a document found in 2 forests in the event of an XDMP-DBDUPURI exception
View duplicate-uri.xqy
xquery version "1.0-ml";
(:
A Utility module for viewing duplicate document/properties fragment information in situations
where MarkLogic Server reports an XDMP-DBDUPURI exception.
An XDMP-DBDUPURI will be thrown by MarkLogic in any situation where a document at a given URI
appears to exist in more than one forest in a given database; example:
XDMP-DBDUPURI: URI /problem/uri.xml found in forests Library06 and Library07
@ableasdale
ableasdale / document-assign.xqy
Created Dec 11, 2020
MarkLogic: In Forest Eval - adding xdmp:document-assign back into the evaluation
View document-assign.xqy
let $forest :=
let $forests := xdmp:database-forests(xdmp:database())
let $index := xdmp:document-assign("document-1.xml", count($forests))
return $forests[$index]
return local:in-forest-eval("xdmp:document-insert('/foo1.xml', <foo>1</foo>)", (), xs:unsignedLong($forest))
@ableasdale
ableasdale / in-forest-eval.xqy
Last active Dec 11, 2020
MarkLogic: In Forest Eval example
View in-forest-eval.xqy
xquery version "1.0-ml";
(:
The following XQuery code demonstrates a technique to force an "in forest eval" of a call to xdmp:document-insert().
This code will force a document insert to get evaluated within the context of a specific forest (Documents2)
Note that the practice outlined in this code (or similar) can have the potential to lead to an increased chance of
XDMP-DBDUPURI URIs as the code effectively bypasses the normal xdmp:document-assign() process that assigns a URI to
a given forest based on the hash of it's URI key.
This code is for demonstration purposes only.
@ableasdale
ableasdale / pstack.sh
Last active Oct 12, 2020
MarkLogic: Simple pstack script
View pstack.sh
#!/bin/bash
# root check
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root" 1>&2
exit 1
fi
# default argument check
if [[ -z $1 ]]; then
@ableasdale
ableasdale / process-json.xqy
Created Jun 1, 2020
MarkLogic: processing JSON using XPath
View process-json.xqy
xquery version "1.0-ml";
(: Taken from:
https://www.linkedin.com/posts/kurtcagle_informatix8gulp-saxon-xslt-activity-6673109285721010176-hDYU/
See also:
https://www.npmjs.com/package/@informatix8/gulp-saxon-xslt
The above example was modified from Kurt's example to work with MarkLogic Server.
:)
@ableasdale
ableasdale / remove-replicas.xqy
Created May 26, 2020
MarkLogic: Removing multiple replica forests from their respective master forests
View remove-replicas.xqy
xquery version "1.0-ml";
import module namespace admin = "http://marklogic.com/xdmp/admin" at "/MarkLogic/admin.xqy";
declare variable $CONFIG := admin:get-configuration();
let $CONFIG := admin:forest-remove-replica($CONFIG, xdmp:forest("Documents"), xdmp:forest("Documents-R"))
let $CONFIG := admin:forest-remove-replica($CONFIG, xdmp:forest("Extensions"), xdmp:forest("Extensions-R"))
return admin:save-configuration($CONFIG)
@ableasdale
ableasdale / v8.md
Last active Apr 24, 2020 — forked from kevincennis/v8.md
V8 Installation and d8 shell usage
View v8.md

Installing V8 on a Mac

My Troubleshooting Notes

I had issues which I initially believed were related to python 3 but may have been XCode issues - I got it to work by doing all of these things but I'm not sure what was actually necessary - so I'll put all the steps in that I can recall.

Ultimately, I was seeing python stack traces when running tools/dev/v8gen.py x64.optdebug; the resulting stack trace looked like this:

tools/dev/v8gen.py x64.optdebug
You can’t perform that action at this time.