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


Java ResultSequence.next方法代码示例

本文整理汇总了Java中com.marklogic.xcc.ResultSequence.next方法的典型用法代码示例。如果您正苦于以下问题:Java ResultSequence.next方法的具体用法?Java ResultSequence.next怎么用?Java ResultSequence.next使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.marklogic.xcc.ResultSequence的用法示例。


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

示例1: getForestSplits

import com.marklogic.xcc.ResultSequence; //导入方法依赖的package包/类
protected void getForestSplits(JobContext jobContext,
        ResultSequence result, 
        List<ForestSplit> forestSplits,
        List<String> ruleUris,
        String[] inputHosts) throws IOException {
    Configuration jobConf = jobContext.getConfiguration();
    super.getForestSplits(jobContext, result, forestSplits, ruleUris, inputHosts);
    // Third while loop: audit settings
    while (result.hasNext()) {
        ResultItem item = result.next();
        if (ItemType.XS_STRING != item.getItemType()) {
            throw new IOException("Unexpected item type " + item.getItemType().toString());
        }
        String itemStr = ((XSString)item.getItem()).asString();
        if ("AUDIT".equals(itemStr)) {
            continue;
        } else if (ConfigConstants.AUDIT_MLCPSTART_EVENT.
                equalsIgnoreCase(itemStr)) {
            mlcpStartEventEnabled = true;
        } else if (ConfigConstants.AUDIT_MLCPFINISH_EVENT.
                equalsIgnoreCase(itemStr)) {
            mlcpFinishEventEnabled = true;
        } else {
            throw new IOException("Unrecognized audit event " + itemStr);
        }                
    }
    if (ruleUris != null && ruleUris.size() > 0) {
        AuditUtil.prepareAuditMlcpFinish(jobConf, ruleUris.size());
        if (LOG.isDebugEnabled()) {
            // TODO: Use this version if only JAVA 8 is supported
            // String logMessage = String.join(", ", ruleUris);
            LOG.debug("Redaction rules applied: " + StringUtils.join(ruleUris, ", "));
        }
    }
    if (mlcpStartEventEnabled) {
        AuditUtil.auditMlcpStart(jobConf, jobContext.getJobName());
    }
    jobConf.setBoolean(ConfigConstants.CONF_AUDIT_MLCPFINISH_ENABLED, mlcpFinishEventEnabled);
}
 
开发者ID:marklogic,项目名称:marklogic-contentpump,代码行数:40,代码来源:DocumentInputFormat.java

示例2: testImportMixedDocs

import com.marklogic.xcc.ResultSequence; //导入方法依赖的package包/类
@Test
public void testImportMixedDocs() throws Exception {
    String cmd = "IMPORT -password admin -username admin -host localhost"
        + " -input_file_path " + Constants.TEST_PATH.toUri() + "/wiki"
        + " -output_uri_prefix test/"
        + " -output_collections test,ML"
        + " -fastload false"
        + " -output_uri_replace wiki,'wiki1'"
        + " -port " + Constants.port + " -database " + Constants.testDb;
    String[] args = cmd.split(" +");
    assertFalse(args.length == 0);

    Utils.clearDB(Utils.getTestDbXccUri(), Constants.testDb);

    String[] expandedArgs = null;
    expandedArgs = OptionsFileUtil.expandArguments(args);
    ContentPump.runCommand(expandedArgs);

    ResultSequence result = Utils.runQuery(
        Utils.getTestDbXccUri(),
        "fn:count(fn:collection(\"ML\"))");
    assertTrue(result.hasNext());
    assertEquals("93", result.next().asString());
    Utils.closeSession();
    
    result = Utils.runQuery(Utils.getTestDbXccUri(),
        "xdmp:directory(\"test/\", \"infinity\")");
    int count = 0;
    while (result.hasNext()) {
        ResultItem item = result.next();
        String uri = item.getDocumentURI();
        assertTrue(uri.contains("wiki1"));
        count++;
    }
    assertTrue(count == 93);
    Utils.closeSession();
}
 
开发者ID:marklogic,项目名称:marklogic-contentpump,代码行数:38,代码来源:TestImportDocs.java

示例3: testImportMixedDocsIncorrectHost

import com.marklogic.xcc.ResultSequence; //导入方法依赖的package包/类
public void testImportMixedDocsIncorrectHost() throws Exception {
    String cmd = "IMPORT -password admin -username admin -host localhost"
        + " -input_file_path " + Constants.TEST_PATH.toUri() + "/wiki"
        + " -output_uri_prefix test/"
        + " -output_collections test,ML  "
        + " -output_uri_replace wiki,'wiki1'"
        + " -port " + Constants.port + " -database " + Constants.testDb;
    String[] args = cmd.split(" +");
    assertFalse(args.length == 0);

    Utils.clearDB(Utils.getTestDbXccUri(), Constants.testDb);

    String[] expandedArgs = null;
    expandedArgs = OptionsFileUtil.expandArguments(args);
    ContentPump.runCommand(expandedArgs);

    ResultSequence result = Utils.runQuery(
        Utils.getTestDbXccUri(),
        "fn:count(fn:collection(\"ML\"))");
    assertTrue(result.hasNext());
    assertEquals("93", result.next().asString());
    Utils.closeSession();
    
    result = Utils.runQuery(Utils.getTestDbXccUri(),
        "xdmp:directory(\"test/\", \"infinity\")");
    int count = 0;
    while (result.hasNext()) {
        ResultItem item = result.next();
        String uri = item.getDocumentURI();
        assertTrue(uri.contains("wiki1"));
        count++;
    }
    assertTrue(count == 93);
    Utils.closeSession();
}
 
开发者ID:marklogic,项目名称:marklogic-contentpump,代码行数:36,代码来源:TestImportDocs.java

示例4: testCopy

import com.marklogic.xcc.ResultSequence; //导入方法依赖的package包/类
@Test
public void testCopy() throws Exception {
    String cmd = 
        "IMPORT -host localhost -username admin -password admin"
        + " -input_file_path " + Constants.TEST_PATH.toUri() + "/csv2.zip"
        + " -delimited_uri_id first"
        + " -input_compressed -input_compression_codec zip"
        + " -input_file_type delimited_text"
        + " -output_uri_suffix .xml"
        + " -output_uri_prefix test/"
        + " -port " + Constants.port + " -database " + Constants.testDb;
        
    
    String[] args = cmd.split(" ");

    Utils.clearDB(Utils.getTestDbXccUri(), Constants.testDb);
    Utils.clearDB(Utils.getTestDbXccUri(), Constants.copyDst);
    
    String[] expandedArgs = null;
    expandedArgs = OptionsFileUtil.expandArguments(args);
    ContentPump.runCommand(expandedArgs);

    ResultSequence result = Utils.runQuery(
        Utils.getTestDbXccUri(), "fn:count(fn:collection())");
    assertTrue(result.hasNext());
    assertEquals("5", result.next().asString());
    Utils.closeSession();
    
    //copy
    cmd = "COPY -input_host localhost"
        + " -input_username admin -input_password admin"
        + " -output_host localhost"
        + " -output_username admin -output_password admin"
        + " -output_uri_suffix .suffix"
        + " -output_uri_prefix prefix/"
        + " -input_port " + Constants.port + " -input_database " + Constants.testDb
        + " -output_port " + Constants.port + " -output_database " + Constants.copyDst;
    args = cmd.split(" ");
    expandedArgs = OptionsFileUtil.expandArguments(args);
    ContentPump.runCommand(expandedArgs);
    
    result = Utils.runQuery(
        Utils.getTestDbXccUri(), "fn:count(fn:collection())");
    assertTrue(result.hasNext());
    assertEquals("5", result.next().asString());
    Utils.closeSession();
    
    result = Utils.runQueryAgainstDb(
            Utils.getTestDbXccUri(), "fn:doc()", Constants.copyDst);
    while (result.hasNext()) {
        ResultItem item = result.next();
        String uri = item.getDocumentURI();
        assertTrue(uri.endsWith(".xml.suffix"));
        assertTrue(uri.startsWith("prefix/test/"));
    }
    Utils.closeSession();
}
 
开发者ID:marklogic,项目名称:marklogic-contentpump,代码行数:58,代码来源:TestCopy.java

示例5: testCopyWOProps

import com.marklogic.xcc.ResultSequence; //导入方法依赖的package包/类
@Test
public void testCopyWOProps() throws Exception {
    String cmd = 
        "IMPORT -host localhost -username admin -password admin"
        + " -input_file_path " + Constants.TEST_PATH.toUri() + "/csv2.zip"
        + " -delimited_uri_id first"
        + " -input_compressed -input_compression_codec zip"
        + " -input_file_type delimited_text"
        + " -output_uri_suffix .xml"
        + " -output_uri_prefix test/"
        + " -port " + Constants.port + " -database " + Constants.testDb;
    
    String[] args = cmd.split(" ");

    Utils.clearDB(Utils.getTestDbXccUri(), Constants.testDb);
    Utils.clearDB(Utils.getTestDbXccUri(), Constants.copyDst);
    
    String[] expandedArgs = null;
    expandedArgs = OptionsFileUtil.expandArguments(args);
    ContentPump.runCommand(expandedArgs);

    ResultSequence result = Utils.runQuery(
        Utils.getTestDbXccUri(), "fn:count(fn:collection())");
    assertTrue(result.hasNext());
    assertEquals("5", result.next().asString());
    Utils.closeSession();
    
    //copy
    cmd = "COPY -input_host localhost"
        + " -input_username admin -input_password admin"
        + " -output_host localhost"
        + " -output_username admin -output_password admin"
        + " -output_uri_suffix .suffix"
        + " -output_uri_prefix prefix/"
        + " -copy_properties false"
        + " -batch_size 1"
        + " -input_port " + Constants.port + " -input_database " + Constants.testDb
        + " -output_port " + Constants.port + " -output_database " + Constants.copyDst;
    args = cmd.split(" ");
    expandedArgs = OptionsFileUtil.expandArguments(args);
    ContentPump.runCommand(expandedArgs);
    
    result = Utils.runQuery(
        Utils.getTestDbXccUri(), "fn:count(fn:collection())");
    assertTrue(result.hasNext());
    assertEquals("5", result.next().asString());
    Utils.closeSession();
    
    result = Utils.runQueryAgainstDb(
            Utils.getTestDbXccUri(), "fn:doc()", Constants.copyDst);
    while (result.hasNext()) {
        ResultItem item = result.next();
        String uri = item.getDocumentURI();
        assertTrue(uri.endsWith(".xml.suffix"));
        assertTrue(uri.startsWith("prefix/test/"));
    }
    Utils.closeSession();
}
 
开发者ID:marklogic,项目名称:marklogic-contentpump,代码行数:59,代码来源:TestCopy.java

示例6: testCopyTransform

import com.marklogic.xcc.ResultSequence; //导入方法依赖的package包/类
@Test
public void testCopyTransform() throws Exception {
    Utils.prepareModule(Utils.getTestDbXccUri(), "/lc.xqy");
    String cmd = 
        "IMPORT -host localhost -username admin -password admin"
        + " -input_file_path " + Constants.TEST_PATH.toUri() + "/csv2.zip"
        + " -delimited_uri_id first"
        + " -input_compressed -input_compression_codec zip"
        + " -input_file_type delimited_text"
        + " -output_uri_suffix .xml -output_collections import"
        + " -output_uri_prefix test/"
        + " -port " + Constants.port + " -database " + Constants.testDb;
    
    String[] args = cmd.split(" ");

    Utils.clearDB(Utils.getTestDbXccUri(), Constants.testDb);
    Utils.clearDB(Utils.getTestDbXccUri(), Constants.copyDst);
    
    String[] expandedArgs = null;
    expandedArgs = OptionsFileUtil.expandArguments(args);
    ContentPump.runCommand(expandedArgs);

    ResultSequence result = Utils.runQuery(
        Utils.getTestDbXccUri(), "fn:count(fn:collection())");
    assertTrue(result.hasNext());
    assertEquals("5", result.next().asString());
    Utils.closeSession();
    
    //copy
    cmd = "COPY -input_host localhost"
        + " -input_username admin -input_password admin"
        + " -output_host localhost"
        + " -output_username admin -output_password admin"
        + " -output_uri_suffix .suffix"
        + " -output_uri_prefix prefix/ -output_collections copy"
        + " -transform_namespace http://marklogic.com/module_invoke"
        + " -transform_module /lc.xqy"
        + " -input_port " + Constants.port + " -input_database " + Constants.testDb
        + " -output_port " + Constants.port + " -output_database " + Constants.copyDst;
    args = cmd.split(" ");
    expandedArgs = OptionsFileUtil.expandArguments(args);
    ContentPump.runCommand(expandedArgs);
    
    result = Utils.runQuery(
        Utils.getTestDbXccUri(), "fn:count(fn:collection())");
    assertTrue(result.hasNext());
    assertEquals("5", result.next().asString());
    Utils.closeSession();
    
    result = Utils.runQueryAgainstDb(
            Utils.getTestDbXccUri(), "fn:doc()", Constants.copyDst);
    while (result.hasNext()) {
        ResultItem item = result.next();
        String uri = item.getDocumentURI();
        assertTrue(uri.endsWith(".xml.suffix"));
        assertTrue(uri.startsWith("prefix/test/"));
    }
    Utils.closeSession();
}
 
开发者ID:marklogic,项目名称:marklogic-contentpump,代码行数:60,代码来源:TestCopy.java

示例7: testCopyTransformFast

import com.marklogic.xcc.ResultSequence; //导入方法依赖的package包/类
@Test
public void testCopyTransformFast() throws Exception {
    Utils.prepareModule(Utils.getTestDbXccUri(), "/lc.xqy");
    String cmd = 
        "IMPORT -host localhost -username admin -password admin"
        + " -input_file_path " + Constants.TEST_PATH.toUri() + "/csv2.zip"
        + " -delimited_uri_id first"
        + " -input_compressed -input_compression_codec zip"
        + " -input_file_type delimited_text"
        + " -output_uri_suffix .xml -output_collections import"
        + " -output_uri_prefix test/"
        + " -port " + Constants.port + " -database " + Constants.testDb;
    
    String[] args = cmd.split(" ");

    Utils.clearDB(Utils.getTestDbXccUri(), Constants.testDb);
    Utils.clearDB(Utils.getTestDbXccUri(), Constants.copyDst);
    
    String[] expandedArgs = null;
    expandedArgs = OptionsFileUtil.expandArguments(args);
    ContentPump.runCommand(expandedArgs);

    ResultSequence result = Utils.runQuery(
        Utils.getTestDbXccUri(), "fn:count(fn:collection())");
    assertTrue(result.hasNext());
    assertEquals("5", result.next().asString());
    Utils.closeSession();
    
    //copy
    cmd = "COPY -input_host localhost"
        + " -input_username admin -input_password admin"
        + " -output_host localhost"
        + " -output_username admin -output_password admin"
        + " -fastload"
        + " -output_uri_suffix .suffix"
        + " -output_uri_prefix prefix/ -output_collections copy"
        + " -transform_namespace http://marklogic.com/module_invoke"
        + " -transform_module /lc.xqy"
        + " -input_port " + Constants.port + " -input_database " + Constants.testDb
        + " -output_port " + Constants.port + " -output_database " + Constants.copyDst;
    args = cmd.split(" ");
    expandedArgs = OptionsFileUtil.expandArguments(args);
    ContentPump.runCommand(expandedArgs);
    
    result = Utils.runQuery(
        Utils.getTestDbXccUri(), "fn:count(fn:collection())");
    assertTrue(result.hasNext());
    assertEquals("5", result.next().asString());
    Utils.closeSession();
    
    result = Utils.runQueryAgainstDb(
            Utils.getTestDbXccUri(), "fn:doc()", Constants.copyDst);
    while (result.hasNext()) {
        ResultItem item = result.next();
        String uri = item.getDocumentURI();
        assertTrue(uri.endsWith(".xml.suffix"));
        assertTrue(uri.startsWith("prefix/test/"));
    }
    Utils.closeSession();
    AssignmentManager.getInstance().setInitialized(false);
}
 
开发者ID:marklogic,项目名称:marklogic-contentpump,代码行数:62,代码来源:TestCopy.java

示例8: testCopyFast

import com.marklogic.xcc.ResultSequence; //导入方法依赖的package包/类
@Test
public void testCopyFast() throws Exception {
    String cmd = 
        "IMPORT -host localhost -username admin -password admin"
        + " -input_file_path " + Constants.TEST_PATH.toUri() + "/csv2.zip"
        + " -delimited_uri_id first"
        + " -input_compressed -input_compression_codec zip"
        + " -fastload true -batch_size 1"
        + " -input_file_type delimited_text"
        + " -output_uri_suffix .xml"
        + " -output_uri_prefix test/"
        + " -port " + Constants.port + " -database " + Constants.testDb;
    
    String[] args = cmd.split(" ");

    Utils.clearDB(Utils.getTestDbXccUri(), Constants.testDb);
    Utils.clearDB(Utils.getTestDbXccUri(), Constants.copyDst);
    
    String[] expandedArgs = null;
    expandedArgs = OptionsFileUtil.expandArguments(args);
    ContentPump.runCommand(expandedArgs);

    ResultSequence result = Utils.runQuery(
        Utils.getTestDbXccUri(), "fn:count(fn:collection())");
    assertTrue(result.hasNext());
    assertEquals("5", result.next().asString());
    Utils.closeSession();
    
    AssignmentManager.getInstance().setInitialized(false);
    //copy
    cmd = "COPY -input_host localhost"
        + " -input_username admin -input_password admin"
        + " -output_host localhost"
        + " -output_username admin -output_password admin"
        + " -fastload -batch_size 1"
        + " -output_uri_suffix .suffix"
        + " -output_uri_prefix prefix/"
        + " -input_port " + Constants.port + " -input_database " + Constants.testDb
        + " -output_port " + Constants.port + " -output_database " + Constants.copyDst;
    args = cmd.split(" ");
    expandedArgs = OptionsFileUtil.expandArguments(args);
    ContentPump.runCommand(expandedArgs);
    
    result = Utils.runQuery(
        Utils.getTestDbXccUri(), "fn:count(fn:collection())");
    assertTrue(result.hasNext());
    assertEquals("5", result.next().asString());
    Utils.closeSession();
    
    result = Utils.runQueryAgainstDb(
            Utils.getTestDbXccUri(), "fn:doc()", Constants.copyDst);
    while (result.hasNext()) {
        ResultItem item = result.next();
        String uri = item.getDocumentURI();
        assertTrue(uri.endsWith(".xml.suffix"));
        assertTrue(uri.startsWith("prefix/test/"));
    }
    Utils.closeSession();
    AssignmentManager.getInstance().setInitialized(false);
}
 
开发者ID:marklogic,项目名称:marklogic-contentpump,代码行数:61,代码来源:TestCopy.java

示例9: initialize

import com.marklogic.xcc.ResultSequence; //导入方法依赖的package包/类
/**
 * Initialize initial server host name, assignment policy and fastload.
 * 
 * @param session
 * @throws IOException
 * @throws RequestException
 */
protected void initialize(Session session, boolean restrictHosts)
    throws IOException, RequestException {
    AdhocQuery query = session.newAdhocQuery(INIT_QUERY);
    RequestOptions options = new RequestOptions();
    options.setDefaultXQueryVersion("1.0-ml");
    query.setOptions(options);
    ResultSequence result = null;
    result = session.submitRequest(query);

    ResultItem item = result.next();
    initHostName = item.asString();
    item = result.next();
    am.setEffectiveVersion(((XSInteger)item.getItem()).asLong());
    item = result.next();
    failover = !restrictHosts && item.asString().equals("true");
    if (result.hasNext()) {
        item = result.next();
        String policyStr = item.asString();
        conf.set(ASSIGNMENT_POLICY, policyStr);
        policy = AssignmentPolicy.Kind.forName(policyStr);
        item = result.next();
        allowFastLoad = Boolean.parseBoolean(item.asString());
        if ((policy == AssignmentPolicy.Kind.STATISTICAL 
            || policy == AssignmentPolicy.Kind.RANGE
            || policy == AssignmentPolicy.Kind.QUERY)
            && !allowFastLoad && conf.getBoolean(OUTPUT_FAST_LOAD, false)) {
            throw new IOException(
                "Fastload can't be used: rebalancer is on and "
                    + "forests are imbalanced in a database with "
                    + "statistics-based assignment policy");
        }
    } else {
    	policy = AssignmentPolicy.Kind.LEGACY;
    	legacy = true;
    }
    
    // initialize fastload mode
    if (conf.get(OUTPUT_FAST_LOAD) == null) {
        // fastload not set
        if (conf.get(OUTPUT_DIRECTORY) != null) {
            // output_dir is set, attempt to do fastload
            if(conf.get(OUTPUT_PARTITION) == null && 
               (policy == AssignmentPolicy.Kind.RANGE ||
                policy == AssignmentPolicy.Kind.QUERY)) {
                fastLoad = false;
            } else if (policy == AssignmentPolicy.Kind.RANGE ||
                       policy == AssignmentPolicy.Kind.QUERY ||
            	   policy == AssignmentPolicy.Kind.STATISTICAL) {
                fastLoad = allowFastLoad;
            } else {
            	fastLoad = true;
            }
        } else {
            //neither fastload nor output_dir is set
            fastLoad = false;
        }
    } else {
        fastLoad = conf.getBoolean(OUTPUT_FAST_LOAD, false);
        if (fastLoad && conf.get(OUTPUT_PARTITION) == null
            && (policy == AssignmentPolicy.Kind.RANGE ||
                policy == AssignmentPolicy.Kind.QUERY)) {
            throw new IllegalArgumentException(
                "output_partition is required for fastload mode.");
        }
    }
    conf.setBoolean(OUTPUT_FAST_LOAD, fastLoad);
}
 
开发者ID:marklogic,项目名称:marklogic-contentpump,代码行数:75,代码来源:ContentOutputFormat.java

示例10: queryHosts

import com.marklogic.xcc.ResultSequence; //导入方法依赖的package包/类
protected TextArrayWritable queryHosts(ContentSource cs, String matchHost,
		String replaceHost)
    throws IOException {
    Session session = null;
    ResultSequence result = null;
    try {
        session = cs.newSession();
        AdhocQuery query = session.newAdhocQuery(HOSTS_QUERY);
        // query hosts
        RequestOptions options = new RequestOptions();
        options.setDefaultXQueryVersion("1.0-ml");
        query.setOptions(options);
        result = session.submitRequest(query);

        ArrayList<Text> hosts = new ArrayList<Text>();
        while (result.hasNext()) {
            ResultItem item = result.next();
            String host = item.asString();
            if (matchHost != null && host.equals(matchHost)) {
            	hosts.add(new Text(replaceHost));
            } else {
                hosts.add(new Text(host));
            }
        }
        if (hosts.isEmpty()) {
            throw new IOException("Target database has no forests attached: "
                    + "check forests in database");
        }
        return new TextArrayWritable(hosts.toArray(new Text[hosts.size()]));
    } catch (RequestException e) {
        LOG.error(e.getMessage(), e);
        throw new IOException(e);
    } finally {
        if (result != null) {
            result.close();
        }
        if (session != null) {
            session.close();
        }
    }
}
 
开发者ID:marklogic,项目名称:marklogic-contentpump,代码行数:42,代码来源:MarkLogicOutputFormat.java


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