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


Java AccumuloInputFormat.addIterator方法代码示例

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


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

示例1: setupAccumuloInput

import org.apache.accumulo.core.client.mapreduce.AccumuloInputFormat; //导入方法依赖的package包/类
/**
 * Sets up Accumulo input for a job: the job receives
 * ({@link org.apache.accumulo.core.data.Key},
 * {@link org.apache.accumulo.core.data.Value}) pairs from the table
 * specified by the configuration (using
 * {@link MRUtils#TABLE_PREFIX_PROPERTY} and
 * {@link MRUtils#TABLE_LAYOUT_PROP}).
 * @param   job     MapReduce Job to configure
 * @throws  AccumuloSecurityException if connecting to Accumulo with the
 *          given username and password fails.
 */
protected void setupAccumuloInput(Job job) throws AccumuloSecurityException {
    // set up accumulo input
    if (!hdfsInput) {
        job.setInputFormatClass(AccumuloInputFormat.class);
    } else {
        job.setInputFormatClass(AccumuloHDFSFileInputFormat.class);
    }
    AccumuloInputFormat.setConnectorInfo(job, userName, new PasswordToken(pwd));
    String tableName = RdfCloudTripleStoreUtils.layoutPrefixToTable(rdfTableLayout, tablePrefix);
    AccumuloInputFormat.setInputTableName(job, tableName);
    AccumuloInputFormat.setScanAuthorizations(job, authorizations);
    if (mock) {
        AccumuloInputFormat.setMockInstance(job, instance);
    } else {
        ClientConfiguration clientConfig = ClientConfiguration.loadDefault()
                .withInstance(instance).withZkHosts(zk);
        AccumuloInputFormat.setZooKeeperInstance(job, clientConfig);
    }
    if (ttl != null) {
        IteratorSetting setting = new IteratorSetting(1, "fi", AgeOffFilter.class.getName());
        AgeOffFilter.setTTL(setting, Long.valueOf(ttl));
        AccumuloInputFormat.addIterator(job, setting);
    }
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:36,代码来源:AbstractAccumuloMRTool.java

示例2: run

import org.apache.accumulo.core.client.mapreduce.AccumuloInputFormat; //导入方法依赖的package包/类
@Override
public int run(String[] args) throws Exception {
  Opts opts = new Opts();
  opts.parseArgs(getClass().getName(), args);

  Job job = Job.getInstance(getConf());
  job.setJobName(getClass().getSimpleName());
  job.setJarByClass(getClass());

  job.setInputFormatClass(AccumuloInputFormat.class);
  opts.setAccumuloConfigs(job);

  IteratorSetting regex = new IteratorSetting(50, "regex", RegExFilter.class);
  RegExFilter.setRegexs(regex, opts.rowRegex, opts.columnFamilyRegex, opts.columnQualifierRegex, opts.valueRegex, false);
  AccumuloInputFormat.addIterator(job, regex);

  job.setMapperClass(RegexMapper.class);
  job.setMapOutputKeyClass(Key.class);
  job.setMapOutputValueClass(Value.class);

  job.setNumReduceTasks(0);

  job.setOutputFormatClass(TextOutputFormat.class);
  TextOutputFormat.setOutputPath(job, new Path(opts.destination));

  System.out.println("setRowRegex: " + opts.rowRegex);
  System.out.println("setColumnFamilyRegex: " + opts.columnFamilyRegex);
  System.out.println("setColumnQualifierRegex: " + opts.columnQualifierRegex);
  System.out.println("setValueRegex: " + opts.valueRegex);

  job.waitForCompletion(true);
  return job.isSuccessful() ? 0 : 1;
}
 
开发者ID:apache,项目名称:accumulo-examples,代码行数:34,代码来源:RegexExample.java

示例3: testRFileReaderRDDAppliesIteratorCorrectly

import org.apache.accumulo.core.client.mapreduce.AccumuloInputFormat; //导入方法依赖的package包/类
@Test
public void testRFileReaderRDDAppliesIteratorCorrectly() throws IOException,
        InterruptedException, AccumuloSecurityException, AccumuloException, TableNotFoundException,
        TableExistsException, StoreException {
    // Given
    final String table = "table2";
    final MiniAccumuloCluster cluster = MiniAccumuloClusterProvider.getMiniAccumuloCluster();
    // Add some data
    final Connector connector = cluster.getConnector(MiniAccumuloClusterProvider.USER,
            MiniAccumuloClusterProvider.PASSWORD);
    connector.tableOperations().create(table);
    final BatchWriter bw = connector.createBatchWriter(table, new BatchWriterConfig());
    final Mutation m1 = new Mutation("row");
    m1.put("CF", "CQ", "value");
    bw.addMutation(m1);
    final Mutation m2 = new Mutation("row2");
    m2.put("CF", "CQ", "not");
    bw.addMutation(m2);
    bw.close();
    // Compact to ensure an RFile is created, sleep to give it a little time to do it
    connector.tableOperations().compact(table, new CompactionConfig());
    Thread.sleep(1000L);
    // Create an iterator and an option to grep for "val"
    final Map<String, String> options = new HashMap<>();
    options.put("term", "val");
    final Configuration conf = new Configuration();
    final Job job = Job.getInstance(conf);
    AccumuloInputFormat.addIterator(job, new IteratorSetting(2, "NAME", GrepIterator.class.getName(), options));
    InputConfigurator.fetchColumns(AccumuloInputFormat.class, job.getConfiguration(),
            Sets.newHashSet(new Pair<>(new Text("CF"), new Text("CQ"))));

    // When
    final SparkSession sparkSession = SparkSessionProvider.getSparkSession();
    final RFileReaderRDD rdd = new RFileReaderRDD(sparkSession.sparkContext(),
            cluster.getInstanceName(), cluster.getZooKeepers(), MiniAccumuloClusterProvider.USER,
            MiniAccumuloClusterProvider.PASSWORD, table, new HashSet<>(),
            serialiseConfiguration(job.getConfiguration()));
    final long count = rdd.count();

    // Then
    assertEquals(1L, count);
}
 
开发者ID:gchq,项目名称:Gaffer,代码行数:43,代码来源:RFileReaderRddIT.java

示例4: configureInputFormat

import org.apache.accumulo.core.client.mapreduce.AccumuloInputFormat; //导入方法依赖的package包/类
@Override
protected void configureInputFormat(Job job) {
    AccumuloInputFormat.addIterator(job, new IteratorSetting(100,
            WholeRowIterator.class));
}
 
开发者ID:sigmoidanalytics,项目名称:spork,代码行数:6,代码来源:AccumuloStorage.java


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