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


Java Config.get方法代码示例

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


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

示例1: configureWriter

import org.apache.lucene.benchmark.byTask.utils.Config; //导入方法依赖的package包/类
public static IndexWriter configureWriter(Config config, PerfRunData runData, OpenMode mode, IndexCommit commit) throws IOException {
  IndexWriterConfig iwc = createWriterConfig(config, runData, mode, commit);
  String infoStreamVal = config.get("writer.info.stream", null);
  if (infoStreamVal != null) {
    if (infoStreamVal.equals("SystemOut")) {
      iwc.setInfoStream(System.out);
    } else if (infoStreamVal.equals("SystemErr")) {
      iwc.setInfoStream(System.err);
    } else {
      File f = new File(infoStreamVal).getAbsoluteFile();
      iwc.setInfoStream(new PrintStream(new BufferedOutputStream(new FileOutputStream(f)), false, Charset.defaultCharset().name()));
    }
  }
  IndexWriter writer = new IndexWriter(runData.getDirectory(), iwc);
  return writer;
}
 
开发者ID:europeana,项目名称:search,代码行数:17,代码来源:CreateIndexTask.java

示例2: PerfTask

import org.apache.lucene.benchmark.byTask.utils.Config; //导入方法依赖的package包/类
public PerfTask(PerfRunData runData) {
  this();
  this.runData = runData;
  Config config = runData.getConfig();
  this.maxDepthLogStart = config.get("task.max.depth.log",0);

  String logStepAtt = "log.step";
  String taskLogStepAtt = "log.step." + name;
  if (config.get(taskLogStepAtt, null) != null) {
    logStepAtt = taskLogStepAtt;
  }

  // It's important to read this from Config, to support vals-by-round.
  logStep = config.get(logStepAtt, DEFAULT_LOG_STEP);
  // To avoid the check 'if (logStep > 0)' in tearDown(). This effectively
  // turns logging off.
  if (logStep <= 0) {
    logStep = Integer.MAX_VALUE;
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:21,代码来源:PerfTask.java

示例3: makeSpatialStrategy

import org.apache.lucene.benchmark.byTask.utils.Config; //导入方法依赖的package包/类
/**
 * Builds a SpatialStrategy from configuration options.
 */
protected SpatialStrategy makeSpatialStrategy(final Config config) {
  //A Map view of Config that prefixes keys with "spatial."
  Map<String, String> configMap = new AbstractMap<String, String>() {
    @Override
    public Set<Entry<String, String>> entrySet() {
      throw new UnsupportedOperationException();
    }

    @Override
    public String get(Object key) {
      return config.get("spatial." + key, null);
    }
  };

  SpatialContext ctx = SpatialContextFactory.makeSpatialContext(configMap, null);

  //Some day the strategy might be initialized with a factory but such a factory
  // is non-existent.
  return makeSpatialStrategy(config, configMap, ctx);
}
 
开发者ID:europeana,项目名称:search,代码行数:24,代码来源:SpatialDocMaker.java

示例4: setConfig

import org.apache.lucene.benchmark.byTask.utils.Config; //导入方法依赖的package包/类
@Override
public void setConfig(Config config) {
  super.setConfig(config);
  
  File workDir = new File(config.get("work.dir", "work"));
  String d = config.get("docs.dir", "dir-out");
  dataDir = new File(d);
  if (!dataDir.isAbsolute()) {
    dataDir = new File(workDir, d);
  }

  inputFiles = new Iterator(dataDir);

  if (inputFiles == null) {
    throw new RuntimeException("No txt files in dataDir: " + dataDir.getAbsolutePath());
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:18,代码来源:DirContentSource.java

示例5: makeSpatialStrategy

import org.apache.lucene.benchmark.byTask.utils.Config; //导入方法依赖的package包/类
protected SpatialStrategy makeSpatialStrategy(final Config config, Map<String, String> configMap,
                                              SpatialContext ctx) {
  //A factory for the prefix tree grid
  SpatialPrefixTree grid = SpatialPrefixTreeFactory.makeSPT(configMap, null, ctx);

  RecursivePrefixTreeStrategy strategy = new RecursivePrefixTreeStrategy(grid, SPATIAL_FIELD) {
    {
      //protected field
      this.pointsOnly = config.get("spatial.docPointsOnly", false);
    }
  };

  int prefixGridScanLevel = config.get("query.spatial.prefixGridScanLevel", -4);
  if (prefixGridScanLevel < 0)
    prefixGridScanLevel = grid.getMaxLevels() + prefixGridScanLevel;
  strategy.setPrefixGridScanLevel(prefixGridScanLevel);

  double distErrPct = config.get("spatial.distErrPct", .025);//doc & query; a default
  strategy.setDistErrPct(distErrPct);
  return strategy;
}
 
开发者ID:yintaoxue,项目名称:read-open-source-code,代码行数:22,代码来源:SpatialDocMaker.java

示例6: WriteLineDocTask

import org.apache.lucene.benchmark.byTask.utils.Config; //导入方法依赖的package包/类
public WriteLineDocTask(PerfRunData runData) throws Exception {
  super(runData);
  Config config = runData.getConfig();
  fname = config.get("line.file.out", null);
  if (fname == null) {
    throw new IllegalArgumentException("line.file.out must be set");
  }
  OutputStream out = StreamUtils.outputStream(new File(fname));
  lineFileOut = new PrintWriter(new BufferedWriter(new OutputStreamWriter(out, StandardCharsets.UTF_8), StreamUtils.BUFFER_SIZE));
  docMaker = runData.getDocMaker();
  
  // init fields 
  String f2r = config.get("line.fields",null);
  if (f2r == null) {
    fieldsToWrite = DEFAULT_FIELDS;
  } else {
    if (f2r.indexOf(SEP)>=0) {
      throw new IllegalArgumentException("line.fields "+f2r+" should not contain the separator char: "+SEP);
    }
    fieldsToWrite = f2r.split(","); 
  }
  
  // init sufficient fields
  sufficientFields = new boolean[fieldsToWrite.length];
  String suff = config.get("sufficient.fields",DEFAULT_SUFFICIENT_FIELDS);
  if (",".equals(suff)) {
    checkSufficientFields = false;
  } else {
    checkSufficientFields = true;
    HashSet<String> sf = new HashSet<>(Arrays.asList(suff.split(",")));
    for (int i=0; i<fieldsToWrite.length; i++) {
      if (sf.contains(fieldsToWrite[i])) {
        sufficientFields[i] = true;
      }
    }
  }
  
  writeHeader(lineFileOut);
}
 
开发者ID:europeana,项目名称:search,代码行数:40,代码来源:WriteLineDocTask.java

示例7: getIndexDeletionPolicy

import org.apache.lucene.benchmark.byTask.utils.Config; //导入方法依赖的package包/类
public static IndexDeletionPolicy getIndexDeletionPolicy(Config config) {
  String deletionPolicyName = config.get("deletion.policy", "org.apache.lucene.index.KeepOnlyLastCommitDeletionPolicy");
  if (deletionPolicyName.equals(NoDeletionPolicy.class.getName())) {
    return NoDeletionPolicy.INSTANCE;
  } else {
    try {
      return Class.forName(deletionPolicyName).asSubclass(IndexDeletionPolicy.class).newInstance();
    } catch (Exception e) {
      throw new RuntimeException("unable to instantiate class '" + deletionPolicyName + "' as IndexDeletionPolicy", e);
    }
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:13,代码来源:CreateIndexTask.java

示例8: setup

import org.apache.lucene.benchmark.byTask.utils.Config; //导入方法依赖的package包/类
@Override
public void setup() throws Exception {
  super.setup();
  //check to make sure either the doc is being stored
  PerfRunData runData = getRunData();
  Config config = runData.getConfig();
  clnName = config.get("collector.class", "");
}
 
开发者ID:europeana,项目名称:search,代码行数:9,代码来源:SearchWithCollectorTask.java

示例9: setConfig

import org.apache.lucene.benchmark.byTask.utils.Config; //导入方法依赖的package包/类
@Override
public void setConfig(Config config) {
  super.setConfig(config);
  String fileName = config.get("docs.file", null);
  if (fileName == null) {
    throw new IllegalArgumentException("docs.file must be set");
  }
  file = new File(fileName).getAbsoluteFile();
  if (encoding == null) {
    encoding = IOUtils.UTF_8;
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:13,代码来源:LineDocSource.java

示例10: setConfig

import org.apache.lucene.benchmark.byTask.utils.Config; //导入方法依赖的package包/类
@Override
public void setConfig(Config config) {
  super.setConfig(config);
  File workDir = new File(config.get("work.dir", "work"));
  String d = config.get("docs.dir", "reuters-out");
  dataDir = new File(d);
  if (!dataDir.isAbsolute()) {
    dataDir = new File(workDir, d);
  }
  inputFiles.clear();
  collectFiles(dataDir, inputFiles);
  if (inputFiles.size() == 0) {
    throw new RuntimeException("No txt files in dataDir: "+dataDir.getAbsolutePath());
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:16,代码来源:ReutersContentSource.java

示例11: setConfig

import org.apache.lucene.benchmark.byTask.utils.Config; //导入方法依赖的package包/类
@Override
public void setConfig(Config config) {
  super.setConfig(config);
  keepImages = config.get("keep.image.only.docs", true);
  String fileName = config.get("docs.file", null);
  if (fileName != null) {
    file = new File(fileName).getAbsoluteFile();
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:10,代码来源:EnwikiContentSource.java

示例12: setConfig

import org.apache.lucene.benchmark.byTask.utils.Config; //导入方法依赖的package包/类
/**
 * Sets the {@link Config} for this content source. If you override this
 * method, you must call super.setConfig.
 */
public void setConfig(Config config) {
  this.config = config;
  forever = config.get("content.source.forever", true);
  logStep = config.get("content.source.log.step", 0);
  verbose = config.get("content.source.verbose", false);
  encoding = config.get("content.source.encoding", null);
}
 
开发者ID:europeana,项目名称:search,代码行数:12,代码来源:ContentItemsSource.java

示例13: setConfig

import org.apache.lucene.benchmark.byTask.utils.Config; //导入方法依赖的package包/类
@Override
public void setConfig(Config config) {
  super.setConfig(config);
  random = new Random(config.get("rand.seed", 13));
  maxDocFacets = config.get("max.doc.facets", 10);
  maxDims = config.get("max.doc.facets.dims", 5);
  maxFacetDepth = config.get("max.facet.depth", 3);
  if (maxFacetDepth < 2) {
    throw new IllegalArgumentException("max.facet.depth must be at least 2; got: " + maxFacetDepth);
  }
  maxValue = maxDocFacets * maxFacetDepth;
}
 
开发者ID:europeana,项目名称:search,代码行数:13,代码来源:RandomFacetSource.java

示例14: makeShapeConverter

import org.apache.lucene.benchmark.byTask.utils.Config; //导入方法依赖的package包/类
/**
 * Optionally converts points to circles, and optionally bbox'es result.
 */
public static ShapeConverter makeShapeConverter(final SpatialStrategy spatialStrategy,
                                                Config config, String configKeyPrefix) {
  //by default does no conversion
  final double radiusDegrees = config.get(configKeyPrefix+"radiusDegrees", 0.0);
  final double plusMinus = config.get(configKeyPrefix+"radiusDegreesRandPlusMinus", 0.0);
  final boolean bbox = config.get(configKeyPrefix + "bbox", false);

  return new ShapeConverter() {
    @Override
    public Shape convert(Shape shape) {
      if (shape instanceof Point && (radiusDegrees != 0.0 || plusMinus != 0.0)) {
        Point point = (Point)shape;
        double radius = radiusDegrees;
        if (plusMinus > 0.0) {
          Random random = new Random(point.hashCode());//use hashCode so it's reproducibly random
          radius += random.nextDouble() * 2 * plusMinus - plusMinus;
          radius = Math.abs(radius);//can happen if configured plusMinus > radiusDegrees
        }
        shape = spatialStrategy.getSpatialContext().makeCircle(point, radius);
      }
      if (bbox)
        shape = shape.getBoundingBox();
      return shape;
    }
  };
}
 
开发者ID:europeana,项目名称:search,代码行数:30,代码来源:SpatialDocMaker.java

示例15: setConfig

import org.apache.lucene.benchmark.byTask.utils.Config; //导入方法依赖的package包/类
@Override
public void setConfig(Config config) throws Exception {
  strategy = SpatialDocMaker.getSpatialStrategy(config.getRoundNumber());
  shapeConverter = SpatialDocMaker.makeShapeConverter(strategy, config, "query.spatial.");

  distErrPct = config.get("query.spatial.distErrPct", Double.NaN);
  operation = SpatialOperation.get(config.get("query.spatial.predicate", "Intersects"));
  score = config.get("query.spatial.score", false);

  super.setConfig(config);//call last, will call prepareQueries()
}
 
开发者ID:europeana,项目名称:search,代码行数:12,代码来源:SpatialFileQueryMaker.java


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