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


Java SolrOutputFormat类代码示例

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


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

示例1: listSortedOutputShardDirs

import org.apache.solr.hadoop.SolrOutputFormat; //导入依赖的package包/类
private FileStatus[] listSortedOutputShardDirs(Job job, Path outputReduceDir, FileSystem fs) throws FileNotFoundException,
        IOException {

    final String dirPrefix = SolrOutputFormat.getOutputName(job);
    FileStatus[] dirs = fs.listStatus(outputReduceDir, new PathFilter() {
        @Override
        public boolean accept(Path path) {
            return path.getName().startsWith(dirPrefix);
        }
    });
    for (FileStatus dir : dirs) {
        if (!dir.isDirectory()) {
            throw new IllegalStateException("Not a directory: " + dir.getPath());
        }
    }

    // use alphanumeric sort (rather than lexicographical sort) to properly handle more than 99999 shards
    Arrays.sort(dirs, new Comparator<FileStatus>() {
        @Override
        public int compare(FileStatus f1, FileStatus f2) {
            return new PublicAlphaNumericComparator().compare(f1.getPath().getName(), f2.getPath().getName());
        }
    });

    return dirs;
}
 
开发者ID:NGDATA,项目名称:hbase-indexer,代码行数:27,代码来源:HBaseMapReduceIndexerTool.java

示例2: SolrRecordWriter

import org.apache.solr.hadoop.SolrOutputFormat; //导入依赖的package包/类
public SolrRecordWriter(TaskAttemptContext context, Path outputShardDir, int batchSize) {
  this.batchSize = batchSize;
  this.batch = new ArrayList(batchSize);
  Configuration conf = context.getConfiguration();

  // setLogLevel("org.apache.solr.core", "WARN");
  // setLogLevel("org.apache.solr.update", "WARN");

  heartBeater = new HeartBeater(context);
  try {
    heartBeater.needHeartBeat();

    Path solrHomeDir = SolrRecordWriter.findSolrConfig(conf);
    FileSystem fs = outputShardDir.getFileSystem(conf);
    EmbeddedSolrServer solr = createEmbeddedSolrServer(solrHomeDir, fs, outputShardDir);
    batchWriter = new BatchWriter(solr, batchSize,
        context.getTaskAttemptID().getTaskID(),
        SolrOutputFormat.getSolrWriterThreadCount(conf),
        SolrOutputFormat.getSolrWriterQueueSize(conf));

  } catch (Exception e) {
    throw new IllegalStateException(String.format(Locale.ENGLISH,
        "Failed to initialize record writer for %s, %s", context.getJobName(), conf
            .get("mapred.task.id")), e);
  } finally {
    heartBeater.cancelHeartBeat();
  }
}
 
开发者ID:yintaoxue,项目名称:read-open-source-code,代码行数:29,代码来源:SolrRecordWriter.java

示例3: wrapInBufferedWriter

import org.apache.solr.hadoop.SolrOutputFormat; //导入依赖的package包/类
private SolrInputDocumentWriter wrapInBufferedWriter(Context context, SolrInputDocumentWriter writer)
        throws MalformedURLException {
    int bufferSize = context.getConfiguration().getInt(SolrOutputFormat.SOLR_RECORD_WRITER_BATCH_SIZE, 100);

    return new BufferedSolrInputDocumentWriter(
            writer,
            bufferSize,
            context.getCounter(HBaseIndexerCounters.OUTPUT_INDEX_DOCUMENTS),
            context.getCounter(HBaseIndexerCounters.OUTPUT_INDEX_DOCUMENT_BATCHES));
}
 
开发者ID:NGDATA,项目名称:hbase-indexer,代码行数:11,代码来源:HBaseIndexerMapper.java

示例4: findSolrConfig

import org.apache.solr.hadoop.SolrOutputFormat; //导入依赖的package包/类
public static Path findSolrConfig(Configuration conf) throws IOException {
  Path solrHome = null;
  // FIXME when mrunit supports the new cache apis
  //URI[] localArchives = context.getCacheArchives();
  Path[] localArchives = DistributedCache.getLocalCacheArchives(conf);
  if (localArchives.length == 0) {
    throw new IOException(String.format(Locale.ENGLISH,
        "No local cache archives, where is %s:%s", SolrOutputFormat
            .getSetupOk(), SolrOutputFormat.getZipName(conf)));
  }
  for (Path unpackedDir : localArchives) {
    // Only logged if debugging
    if (LOG.isDebugEnabled()) {
      LOG.debug(String.format(Locale.ENGLISH, "Examining unpack directory %s for %s",
          unpackedDir, SolrOutputFormat.getZipName(conf)));

      ProcessBuilder lsCmd = new ProcessBuilder(new String[] { "/bin/ls",
          "-lR", unpackedDir.toString() });
      lsCmd.redirectErrorStream();
      Process ls = lsCmd.start();
      byte[] buf = new byte[16 * 1024];
      InputStream all = ls.getInputStream();
      try {
        int count;
        while ((count = all.read(buf)) >= 0) {
          System.err.write(buf, 0, count);
        }
      } catch (IOException ignore) {
      } finally {
        all.close();
      }
      String exitValue;
      try {
        exitValue = String.valueOf(ls.waitFor());
      } catch (InterruptedException e) {
        exitValue = "interrupted";
      }
      System.err.format(Locale.ENGLISH, "Exit value of 'ls -lR' is %s%n", exitValue);
    }
    if (unpackedDir.getName().equals(SolrOutputFormat.getZipName(conf))) {
      LOG.info("Using this unpacked directory as solr home: {}", unpackedDir);
      solrHome = unpackedDir;
      break;
    }
  }

  return solrHome;
}
 
开发者ID:yintaoxue,项目名称:read-open-source-code,代码行数:49,代码来源:SolrRecordWriter.java


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