本文整理汇总了Java中com.marklogic.xcc.types.XdmValue类的典型用法代码示例。如果您正苦于以下问题:Java XdmValue类的具体用法?Java XdmValue怎么用?Java XdmValue使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
XdmValue类属于com.marklogic.xcc.types包,在下文中一共展示了XdmValue类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: constructTransformOption
import com.marklogic.xcc.types.XdmValue; //导入依赖的package包/类
private static XdmValue constructTransformOption(Configuration conf,
String functionParam, String functionNs) {
HashMap<String, String> transMap = new HashMap<>();
String modules = conf.get(ConfigConstants.CONF_INPUT_MODULES_DATABASE);
String modulesRoot = conf.get(ConfigConstants.CONF_INPUT_MODULES_ROOT);
if (modules != null) {
transMap.put("modules", modules);
}
if (modulesRoot != null) {
transMap.put("modules-root", modulesRoot);
}
if (!"".equals(functionNs)) {
transMap.put("transform-namespace", functionNs);
}
if (!"".equals(functionParam)) {
transMap.put("transform-param", functionParam);
}
if (transMap.isEmpty()) {
return ValueFactory.newJSNull();
} else {
ObjectNode node = mapToNode(transMap);
return ValueFactory.newValue(ValueType.JS_OBJECT, node);
}
}
示例2: newValue
import com.marklogic.xcc.types.XdmValue; //导入依赖的package包/类
/**
* Create new XdmValue from value type and Writables.
*
*/
public static XdmValue newValue(ValueType valueType, Object value) {
if (value instanceof Text) {
return ValueFactory.newValue(valueType, ((Text)value).toString());
} else if (value instanceof BytesWritable) {
return ValueFactory.newValue(valueType, ((BytesWritable)value).getBytes());
} else if (value instanceof IntWritable) {
return ValueFactory.newValue(valueType, ((IntWritable)value).get());
} else if (value instanceof LongWritable) {
return ValueFactory.newValue(valueType, ((LongWritable)value).get());
} else if (value instanceof VIntWritable) {
return ValueFactory.newValue(valueType, ((VIntWritable)value).get());
} else if (value instanceof VLongWritable) {
return ValueFactory.newValue(valueType, ((VLongWritable)value).get());
} else if (value instanceof BooleanWritable) {
return ValueFactory.newValue(valueType, ((BooleanWritable)value).get());
} else if (value instanceof FloatWritable) {
return ValueFactory.newValue(valueType, ((FloatWritable)value).get());
} else if (value instanceof DoubleWritable) {
return ValueFactory.newValue(valueType, ((DoubleWritable)value).get());
} else if (value instanceof MarkLogicNode) {
return ValueFactory.newValue(valueType, ((MarkLogicNode)value).get());
} else {
throw new UnsupportedOperationException("Value " +
value.getClass().getName() + " is unsupported.");
}
}
示例3: bindParams
import com.marklogic.xcc.types.XdmValue; //导入依赖的package包/类
private void bindParams(Map<String, Parameter> params, Request request) { //throws RequestException {
for (Map.Entry<String, Parameter> e: params.entrySet()) {
XName name = new XName(e.getKey());
XdmValue value;
switch (e.getValue().getType()) {
case "boolean": {
value = ValueFactory.newXSBoolean(new Boolean(e.getValue().getName()));
break;
}
case "byte":
case "int":
case "long":
case "short": {
value = ValueFactory.newXSInteger(new Integer(e.getValue().getName()));
break;
}
case "double": {
value = ValueFactory.newValue(ValueType.XS_DOUBLE, new Double(e.getValue().getName()));
break;
}
case "float": {
value = ValueFactory.newValue(ValueType.XS_FLOAT, new Float(e.getValue().getName()));
break;
}
default:
value = ValueFactory.newXSString(e.getValue().getName());
}
request.setVariable(ValueFactory.newVariable(name, value));
}
}
示例4: TransformWriter
import com.marklogic.xcc.types.XdmValue; //导入依赖的package包/类
public TransformWriter(Configuration conf,
Map<String, ContentSource> hostSourceMap, boolean fastLoad,
AssignmentManager am) {
super(conf, hostSourceMap, fastLoad, am);
batchSize = effectiveVersion >= BATCH_MIN_VERSION ? batchSize : 1;
moduleUri = conf.get(ConfigConstants.CONF_TRANSFORM_MODULE);
functionNs = conf.get(ConfigConstants.CONF_TRANSFORM_NAMESPACE, "");
functionName = conf.get(ConfigConstants.CONF_TRANSFORM_FUNCTION,
"transform");
functionParam = conf.get(ConfigConstants.CONF_TRANSFORM_PARAM, "");
String contentTypeStr = conf.get(MarkLogicConstants.CONTENT_TYPE,
MarkLogicConstants.DEFAULT_CONTENT_TYPE);
contentType = ContentType.valueOf(contentTypeStr);
queries = new AdhocQuery[sessions.length];
pendingURIs = new HashSet[sessions.length];
for (int i = 0; i < sessions.length; i++) {
pendingURIs[i] = new HashSet<DocumentURI>(batchSize);
}
// counts is only initialized by ContentWriter when batchSize > 1
if (counts == null) {
counts = new int[sessions.length];
}
// Whether the server mlcp talks to has a transformation-option
// in transformation-insert-batch signature
boolean hasOpt = effectiveVersion >= TRANS_OPT_MIN_VERSION;
uris = new XdmValue[counts.length][batchSize];
values = new XdmValue[counts.length][batchSize];
optionsVals = new XdmValue[counts.length][batchSize];
optionsMap = new HashMap<String, String>();
uriName = new XName("URI");
contentName = new XName("CONTENT");
optionsName = new XName("INSERT-OPTIONS");
query = constructQryString(moduleUri, functionNs,
functionName, functionParam, effectiveVersion, hasOpt);
if (hasOpt) {
transOptName = new XName("TRANSFORM-OPTION");
transOpt = constructTransformOption(conf,
functionParam, functionNs);
}
if (LOG.isDebugEnabled()) {
LOG.debug("query:"+query);
}
}
示例5: insertBatch
import com.marklogic.xcc.types.XdmValue; //导入依赖的package包/类
protected void insertBatch(int id, XdmValue[] uriList,
XdmValue[] valueList, XdmValue[] optionsValList)
throws IOException
{
retry = 0;
sleepTime = 500;
while (retry < maxRetries) {
try {
if (retry > 0) {
LOG.info("Retrying insert document " + retry);
}
if (transOpt != null) {
queries[id].setNewVariable(transOptName, transOpt);
}
ResultSequence rs = sessions[id].submitRequest(queries[id]);
while (rs.hasNext()) { // batch mode
String uri = rs.next().asString();
LOG.warn("Failed document " + uri);
failed++;
pendingURIs[id].remove(new DocumentURI(uri));
if (rs.hasNext()) {
String err = rs.next().asString();
LOG.warn(err);
} else break;
}
counts[id] = 0;
break;
} catch (Exception e) {
// compatible mode: log error and continue
if (e instanceof QueryException) {
LOG.error("QueryException:" +
((QueryException) e).getFormatString());
} else if (e instanceof RequestServerException) {
LOG.error("RequestServerException:" + e.getMessage());
} else {
LOG.error("Exception:" + e.getMessage());
}
rollback(id);
if (++retry < maxRetries) {
try {
InternalUtilities.sleep(sleepTime);
} catch (Exception e2) {
}
sleepTime = sleepTime * 2;
if (sleepTime > maxSleepTime)
sleepTime = maxSleepTime;
sessions[id].close();
sessions[id] = getSession(id, true);
queries[id] = getAdhocQuery(id);
queries[id].setNewVariables(uriName, uriList);
queries[id].setNewVariables(contentName, valueList);
queries[id].setNewVariables(optionsName, optionsValList);
continue;
}
LOG.info("Exceeded max retry");
for ( DocumentURI failedUri: pendingURIs[id] ) {
LOG.warn("Failed document " + failedUri);
failed++;
}
pendingURIs[id].clear();
counts[id] = 0;
throw new IOException(e);
}
}
}
示例6: getXdmValue
import com.marklogic.xcc.types.XdmValue; //导入依赖的package包/类
private XdmValue getXdmValue(String type, String value) {
XQueryItemType itemType = XQueryItemType.valueFor(type);
ValueType xdmType = typeMapper.getType(itemType);
return ValueFactory.newValue(xdmType, value);
}