当前位置: 首页>>代码示例>>Java>>正文


Java ContentSource类代码示例

本文整理汇总了Java中com.marklogic.xcc.ContentSource的典型用法代码示例。如果您正苦于以下问题:Java ContentSource类的具体用法?Java ContentSource怎么用?Java ContentSource使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ContentSource类属于com.marklogic.xcc包,在下文中一共展示了ContentSource类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: runQuery

import com.marklogic.xcc.ContentSource; //导入依赖的package包/类
public static ResultSequence runQuery(String xccUri, String query, String queryLanguage) 
        throws XccConfigException, URISyntaxException, RequestException {
    ContentSource cs = csMap.get(xccUri);
    if (cs == null) {
        cs = ContentSourceFactory.newContentSource(new URI(
        xccUri));
        csMap.put(xccUri, cs);
    }
    session = cs.newSession();
    AdhocQuery aquery = session.newAdhocQuery(query);

    RequestOptions options = new RequestOptions();
    options.setQueryLanguage(queryLanguage);
    options.setCacheResult(false);
    options.setDefaultXQueryVersion("1.0-ml");
    aquery.setOptions(options);
    return session.submitRequest(aquery);
}
 
开发者ID:marklogic,项目名称:marklogic-contentpump,代码行数:19,代码来源:Utils.java

示例2: runQueryAgainstDb

import com.marklogic.xcc.ContentSource; //导入依赖的package包/类
public static ResultSequence runQueryAgainstDb(String xccUri, String query, String db)
    throws XccConfigException, URISyntaxException, RequestException {
    StringBuilder buf = new StringBuilder();
    buf.append("xdmp:eval('");
    buf.append(query);
    buf.append("',(),<options xmlns=\"xdmp:eval\">\n" + 
            "            <database>{xdmp:database(\"");
    buf.append(db);
    buf.append("\")}</database>\n" + 
            "          </options>)");
    ContentSource cs = csMap.get(xccUri);
    if (cs == null) {
        cs = ContentSourceFactory.newContentSource(new URI(
        xccUri));
        csMap.put(xccUri, cs);
    }
    session = cs.newSession();
    AdhocQuery aquery = session.newAdhocQuery(buf.toString());

    RequestOptions options = new RequestOptions();
    options.setCacheResult(false);
    options.setDefaultXQueryVersion("1.0-ml");
    aquery.setOptions(options);
    return session.submitRequest(aquery);
}
 
开发者ID:marklogic,项目名称:marklogic-contentpump,代码行数:26,代码来源:Utils.java

示例3: checkOutputSpecs

import com.marklogic.xcc.ContentSource; //导入依赖的package包/类
@Override
public void checkOutputSpecs(Configuration conf, ContentSource cs) 
throws IOException {
    // check for required configuration
    if (conf.get(OUTPUT_QUERY) == null) {
        throw new IllegalArgumentException(OUTPUT_QUERY + 
        " is not specified.");
    }
    // warn against unsupported configuration
    if (conf.get(BATCH_SIZE) != null) {
        LOG.warn("Config entry for " +
                "\"mapreduce.marklogic.output.batchsize\" is not " +
                "supported for " + this.getClass().getName() + 
                " and will be ignored.");
    }
    String queryLanguage = conf.get(OUTPUT_QUERY_LANGUAGE);
    if (queryLanguage != null) {
        InternalUtilities.checkQueryLanguage(queryLanguage);
    }
    // store hosts into config system
    DefaultStringifier.store(conf, queryHosts(cs), OUTPUT_FOREST_HOST);
}
 
开发者ID:marklogic,项目名称:marklogic-contentpump,代码行数:23,代码来源:KeyValueOutputFormat.java

示例4: getSession

import com.marklogic.xcc.ContentSource; //导入依赖的package包/类
/**
 * Get the session for this writer.  One writer only maintains one session.
 * 
 * @return Session for this writer.
 * @throws IOException
 */
protected Session getSession() throws IOException {
    if (session == null) {
        // start a session
        try {
            ContentSource cs = InternalUtilities.getOutputContentSource(
                    conf, hostName);
            session = cs.newSession();
            if (LOG.isDebugEnabled()) {
                LOG.debug("Connect to " + session.getConnectionUri().getHost());
            }
            if (txnSize > 1) {
                session.setTransactionMode(TransactionMode.UPDATE);
            }
        } catch (XccConfigException e) {
            LOG.error("Error creating a new session: ", e);
            throw new IOException(e);
        }    
    }
    return session;
}
 
开发者ID:marklogic,项目名称:marklogic-contentpump,代码行数:27,代码来源:MarkLogicRecordWriter.java

示例5: getInputContentSource

import com.marklogic.xcc.ContentSource; //导入依赖的package包/类
/**
 * Get input content source.
 *
 * @param conf job configuration
 * @param host host to connect to
 * @return content source
 * @throws IOException 
 * @throws XccConfigException
 */
public static ContentSource getInputContentSource(Configuration conf,
        String host) 
throws XccConfigException, IOException {      
    String user = conf.get(INPUT_USERNAME, "");
    String password = conf.get(INPUT_PASSWORD, "");
    String port = conf.get(INPUT_PORT,"8000");
    String db = conf.get(INPUT_DATABASE_NAME);
    int portInt = Integer.parseInt(port);
    boolean useSsl = conf.getBoolean(INPUT_USE_SSL, false);
    if (useSsl) {
        return getSecureContentSource(host, portInt, user, password, 
                    db, getInputSslOptions(conf));
    }
    return ContentSourceFactory.newContentSource(host, portInt, 
            user, password, db);
}
 
开发者ID:marklogic,项目名称:marklogic-contentpump,代码行数:26,代码来源:InternalUtilities.java

示例6: getSecureContentSource

import com.marklogic.xcc.ContentSource; //导入依赖的package包/类
static ContentSource getSecureContentSource(String host, int port,
        String user, String password, String db, 
        SslConfigOptions sslOptions) 
throws XccConfigException {
    ContentSource contentSource = null;
  
    // construct XCC SecurityOptions
    SecurityOptions options;
    try {
        options = new SecurityOptions(sslOptions.getSslContext());
    } catch (KeyManagementException | NoSuchAlgorithmException e) {
        throw new XccConfigException("Error constructing SecurityOptions",
                e);
    }
    options.setEnabledCipherSuites(sslOptions.getEnabledCipherSuites());
    options.setEnabledProtocols(sslOptions.getEnabledProtocols());
  
    // construct content source
    contentSource = ContentSourceFactory.newContentSource(
            host, port, user, password, db, options);        
 
    return contentSource;
}
 
开发者ID:marklogic,项目名称:marklogic-contentpump,代码行数:24,代码来源:InternalUtilities.java

示例7: getOutputContentSource

import com.marklogic.xcc.ContentSource; //导入依赖的package包/类
/**
 * Get output content source.
 *
 * @param conf job configuration
 * @param hostName host name
 * @return content source
 * @throws IOException 
 * @throws XccConfigException 
 * @throws IOException 
 */
public static ContentSource getOutputContentSource(Configuration conf,
        String hostName) 
throws XccConfigException, IOException {
    String user = conf.get(OUTPUT_USERNAME, "");
    String password = conf.get(OUTPUT_PASSWORD, "");
    String port = conf.get(OUTPUT_PORT,"8000");
    String db = conf.get(OUTPUT_DATABASE_NAME);
    int portInt = Integer.parseInt(port);
    boolean useSsl = conf.getBoolean(OUTPUT_USE_SSL, false);
    if (useSsl) {
        return getSecureContentSource(hostName, portInt, user, password,
                    db, getOutputSslOptions(conf));
    }
    return ContentSourceFactory.newContentSource(hostName, portInt, 
            user, password, db);
}
 
开发者ID:marklogic,项目名称:marklogic-contentpump,代码行数:27,代码来源:InternalUtilities.java

示例8: buildRunnable

import com.marklogic.xcc.ContentSource; //导入依赖的package包/类
protected Runnable buildRunnable(final ContentSource contentSource, final List<? extends DocumentWriteOperation> items) {
	return new Runnable() {
		@Override
		public void run() {
			Session session = contentSource.newSession();
			int count = items.size();
			Content[] array = new Content[count];
			for (int i = 0; i < count; i++) {
				array[i] = documentWriteOperationAdapter.adapt(items.get(i));
			}
			if (logger.isDebugEnabled()) {
				logger.debug("Writing " + count + " documents to MarkLogic");
			}
			try {
				session.insertContent(array);
				if (logger.isInfoEnabled()) {
					logger.info("Wrote " + count + " documents to MarkLogic");
				}
			} catch (RequestException e) {
				throw new RuntimeException("Unable to insert content: " + e.getMessage(), e);
			} finally {
				session.close();
			}
		}
	};
}
 
开发者ID:marklogic-community,项目名称:ml-javaclient-util,代码行数:27,代码来源:XccBatchWriter.java

示例9: execCommand

import com.marklogic.xcc.ContentSource; //导入依赖的package包/类
@Override
protected int execCommand(String command, Map<String, Parameter> params) throws RequestException {
       if ("insertDocument".equals(command)) {

       	ContentCreateOptions options = ContentCreateOptions.newXmlInstance();
       	//options.setNamespace("MyNameSpace");
           String collect = params.get("collect").getName();
           if (collect != null) {
           	options.setCollections(new String[] {collect});
           }
           String prefix = params.get("prefix").getName();
           if (prefix == null) {
           	prefix = "doc";
           }
           String uri = prefix + cnt.getAndIncrement() + ".xml";
           String doc = params.get("doc").getName();
       	Content content = ContentFactory.newContent(uri, doc, options);
   		ContentSource xcs = getContentSource();
   		Session xss = xcs.newSession();
       	xss.insertContent(content);       
       	xss.close();
           return 1;
       }
	return 0;
}
 
开发者ID:dsukhoroslov,项目名称:bagri,代码行数:26,代码来源:MarkLogicXCCPlugin.java

示例10: execQuery

import com.marklogic.xcc.ContentSource; //导入依赖的package包/类
@Override
protected int execQuery(String query, Map<String, Parameter> params) throws RequestException {
	
	ContentSource xcs = getContentSource();
	Session xss = xcs.newSession();
	//xss.getDefaultRequestOptions().setResultBufferSize(fetchSize);
	Request request = xss.newAdhocQuery(query);
	bindParams(params, request);
	ResultSequence rs = xss.submitRequest(request);		
    int cnt = 0;
    if (fetchSize > 0) {
    	while (rs.hasNext() && cnt < fetchSize) {
    		rs.next();
    		cnt++;
    	}
    } else {
    	while (rs.hasNext()) {
    		rs.next();
    		cnt++;
    	}
    }
    rs.close();
    xss.close();
    return cnt;
}
 
开发者ID:dsukhoroslov,项目名称:bagri,代码行数:26,代码来源:MarkLogicXCCPlugin.java

示例11: runApp

import com.marklogic.xcc.ContentSource; //导入依赖的package包/类
@Override
public void runApp() throws Exception {
    URI uri = new URI(String.format(XCC_CONNECTION_URI_TEMPLATE, config.getUsername(), config.getPassword(), config.getHost(), config.getPort(), config.getDatabaseName()));
    ContentSource contentSource = ContentSourceFactory.newContentSource(uri);
    try (Session session = contentSource.newSession()) {
        Request request = session.newAdhocQuery(readFile(config.getMainFile()));
        for (XQueryRunnerVariable variable : config.getVariables()) {
            if (variable.ACTIVE) {
                request.setNewVariable(getName(variable.NAME, variable.NAMESPACE), getXdmValue(variable.TYPE,
                        variable.VALUE));
            }
        }
        ResultSequence rs = session.submitRequest(request);
        output.println(rs.asString());
    }
}
 
开发者ID:ligasgr,项目名称:intellij-xquery,代码行数:17,代码来源:MarklogicRunnerApp.java

示例12: getRecordWriter

import com.marklogic.xcc.ContentSource; //导入依赖的package包/类
@Override
public RecordWriter<DocumentURI, VALUEOUT> getRecordWriter(
    TaskAttemptContext context) throws IOException, InterruptedException {
    Configuration conf = context.getConfiguration();
    fastLoad = Boolean.valueOf(conf.get(OUTPUT_FAST_LOAD));
    Map<String, ContentSource> sourceMap = getSourceMap(fastLoad, context);
    getMimetypesMap();
    // construct the ContentWriter
    return new TransformWriter<VALUEOUT>(conf, sourceMap, fastLoad, am);
}
 
开发者ID:marklogic,项目名称:marklogic-contentpump,代码行数:11,代码来源:TransformOutputFormat.java

示例13: checkOutputSpecs

import com.marklogic.xcc.ContentSource; //导入依赖的package包/类
@Override
public void checkOutputSpecs(Configuration conf, ContentSource cs)
    throws IOException {
    super.checkOutputSpecs(conf, cs);

    // store mimetypes map into config system
    DefaultStringifier.store(conf, getMimetypesMap(),
        ConfigConstants.CONF_MIMETYPES);
}
 
开发者ID:marklogic,项目名称:marklogic-contentpump,代码行数:10,代码来源:TransformOutputFormat.java

示例14: DatabaseContentWriter

import com.marklogic.xcc.ContentSource; //导入依赖的package包/类
public DatabaseContentWriter(Configuration conf,
        Map<String, ContentSource> hostSourceMap, boolean fastLoad,
        AssignmentManager am) {
    super(conf, hostSourceMap, fastLoad, am);

    if (countBased) {
        metadatas = new URIMetadata[1][batchSize];
    } else {
        metadatas = new URIMetadata[forestIds.length][batchSize];
    }
    isCopyProps = conf.getBoolean(CONF_COPY_PROPERTIES, true);
    isCopyPerms = conf.getBoolean(CONF_COPY_PERMISSIONS, true);
}
 
开发者ID:marklogic,项目名称:marklogic-contentpump,代码行数:14,代码来源:DatabaseContentWriter.java

示例15: getRecordWriter

import com.marklogic.xcc.ContentSource; //导入依赖的package包/类
@Override
public RecordWriter<DocumentURI, DatabaseDocumentWithMeta> getRecordWriter(
    TaskAttemptContext context) throws IOException, InterruptedException {
    Configuration conf = context.getConfiguration();
    fastLoad = Boolean.valueOf(conf.get(OUTPUT_FAST_LOAD));
    Map<String, ContentSource> sourceMap = getSourceMap(fastLoad, context);
    // construct the DatabaseTransformContentWriter
    return new DatabaseTransformWriter<DatabaseDocumentWithMeta>(conf,
        sourceMap, fastLoad, am);
}
 
开发者ID:marklogic,项目名称:marklogic-contentpump,代码行数:11,代码来源:DatabaseTransformOutputFormat.java


注:本文中的com.marklogic.xcc.ContentSource类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。