Codota Logo
org.elasticsearch.common.io
Code IndexAdd Codota to your IDE (free)

How to use org.elasticsearch.common.io

Best Java code snippets using org.elasticsearch.common.io (Showing top 20 results out of 450)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
Charset c =
  • Codota IconString charsetName;Charset.forName(charsetName)
  • Codota IconCharset.defaultCharset()
  • Codota IconContentType contentType;contentType.getCharset()
  • Smart code suggestions by Codota
}
origin: medcl/elasticsearch-analysis-ik

public Path getConfigInPluginDir() {
  return PathUtils
      .get(new File(AnalysisIkPlugin.class.getProtectionDomain().getCodeSource().getLocation().getPath())
          .getParent(), "config")
      .toAbsolutePath();
}
origin: richardwilly98/elasticsearch-river-mongodb

public static String getRiverVersion() {
  String version = "Undefined";
  try {
    String properties = Streams.copyToStringFromClasspath("/org/elasticsearch/river/mongodb/es-build.properties");
    Properties props = new Properties();
    props.load(new FastStringReader(properties));
    String ver = props.getProperty("version", "undefined");
    String hash = props.getProperty("hash", "undefined");
    if (!"undefined".equals(hash)) {
      hash = hash.substring(0, 7);
    }
    String timestamp = "undefined";
    String gitTimestampRaw = props.getProperty("timestamp");
    if (gitTimestampRaw != null) {
      timestamp = ISODateTimeFormat.dateTimeNoMillis().withZone(DateTimeZone.UTC).print(Long.parseLong(gitTimestampRaw));
    }
    version = String.format("version[%s] - hash[%s] - time[%s]", ver, hash, timestamp);
  } catch (Exception ex) {
  }
  return version;
}
origin: apache/flume

 @Override
 protected void prepareIndexRequest(IndexRequestBuilder indexRequest,
   String indexName, String indexType, Event event) throws IOException {
  BytesStream contentBuilder = serializer.getContentBuilder(event);
  indexRequest.setIndex(indexName)
    .setType(indexType)
    .setSource(contentBuilder.bytes());
 }
}
origin: org.elasticsearch/elasticsearch

/**
 * read <i>length</i> bytes from <i>position</i> of a file channel
 */
public static byte[] readFromFileChannel(FileChannel channel, long position, int length) throws IOException {
  byte[] res = new byte[length];
  readFromFileChannelWithEofException(channel, position, res, 0, length);
  return res;
}
origin: org.elasticsearch/elasticsearch

/**
 * Writes part of a byte array to a {@link java.nio.channels.WritableByteChannel}
 *
 * @param source  byte array to copy from
 * @param channel target WritableByteChannel
 */
public static void writeToChannel(byte[] source, WritableByteChannel channel) throws IOException {
  writeToChannel(source, 0, source.length, channel);
}
origin: apache/usergrid

@Override
public void start(Description description) throws Exception {
  FileSystemUtils.deleteRecursively(new File(embedded.getConfig().getDataDir()));
  embedded.start();
}
origin: org.elasticsearch/elasticsearch

/**
 * Wraps the given {@link BytesStream} in a {@link StreamOutput} that simply flushes when
 * close is called.
 */
public static BytesStream flushOnCloseStream(BytesStream os) {
  return new FlushOnCloseOutputStream(os);
}
origin: medcl/elasticsearch-analysis-ik

/**
 * 加载用户配置的扩展词典到主词库表
 */
private void loadExtDict() {
  // 加载扩展词典配置
  List<String> extDictFiles = getExtDictionarys();
  if (extDictFiles != null) {
    for (String extDictName : extDictFiles) {
      // 读取扩展词典文件
      logger.info("[Dict Loading] " + extDictName);
      Path file = PathUtils.get(extDictName);
      loadDictFile(_MainDict, file, false, "Extra Dict");
    }
  }
}
origin: apache/flume

@Override
public void addEvent(Event event, IndexNameBuilder indexNameBuilder, String indexType,
           long ttlMs) throws Exception {
 BytesReference content = serializer.getContentBuilder(event).bytes();
 Map<String, Map<String, String>> parameters = new HashMap<String, Map<String, String>>();
 Map<String, String> indexParameters = new HashMap<String, String>();
 indexParameters.put(INDEX_PARAM, indexNameBuilder.getIndexName(event));
 indexParameters.put(TYPE_PARAM, indexType);
 if (ttlMs > 0) {
  indexParameters.put(TTL_PARAM, Long.toString(ttlMs));
 }
 parameters.put(INDEX_OPERATION_NAME, indexParameters);
 Gson gson = new Gson();
 synchronized (bulkBuilder) {
  bulkBuilder.append(gson.toJson(parameters));
  bulkBuilder.append("\n");
  bulkBuilder.append(content.toBytesArray().toUtf8());
  bulkBuilder.append("\n");
 }
}
origin: apache/usergrid

@Override
public void stop(Description description) {
  embedded.stop();
  FileSystemUtils.deleteRecursively(new File(embedded.getConfig().getDataDir()));
}
origin: medcl/elasticsearch-analysis-ik

public List<String> getExtStopWordDictionarys() {
  List<String> extStopWordDictFiles = new ArrayList<String>(2);
  String extStopWordDictCfg = getProperty(EXT_STOP);
  if (extStopWordDictCfg != null) {
    String[] filePaths = extStopWordDictCfg.split(";");
    for (String filePath : filePaths) {
      if (filePath != null && !"".equals(filePath.trim())) {
        Path file = PathUtils.get(getDictRoot(), filePath.trim());
        walkFileTree(extStopWordDictFiles, file);
      }
    }
  }
  return extStopWordDictFiles;
}
origin: apache/flume

@Override
public void addEvent(Event event, IndexNameBuilder indexNameBuilder,
  String indexType, long ttlMs) throws Exception {
 if (bulkRequestBuilder == null) {
  bulkRequestBuilder = client.prepareBulk();
 }
 IndexRequestBuilder indexRequestBuilder = null;
 if (indexRequestBuilderFactory == null) {
  indexRequestBuilder = client
    .prepareIndex(indexNameBuilder.getIndexName(event), indexType)
    .setSource(serializer.getContentBuilder(event).bytes());
 } else {
  indexRequestBuilder = indexRequestBuilderFactory.createIndexRequest(
    client, indexNameBuilder.getIndexPrefix(event), indexType, event);
 }
 if (ttlMs > 0) {
  indexRequestBuilder.setTTL(ttlMs);
 }
 bulkRequestBuilder.add(indexRequestBuilder);
}
origin: medcl/elasticsearch-analysis-ik

public List<String> getExtDictionarys() {
  List<String> extDictFiles = new ArrayList<String>(2);
  String extDictCfg = getProperty(EXT_DICT);
  if (extDictCfg != null) {
    String[] filePaths = extDictCfg.split(";");
    for (String filePath : filePaths) {
      if (filePath != null && !"".equals(filePath.trim())) {
        Path file = PathUtils.get(getDictRoot(), filePath.trim());
        walkFileTree(extDictFiles, file);
      }
    }
  }
  return extDictFiles;
}
origin: medcl/elasticsearch-analysis-ik

private void loadSurnameDict() {
  _SurnameDict = new DictSegment((char) 0);
  Path file = PathUtils.get(getDictRoot(), Dictionary.PATH_DIC_SURNAME);
  loadDictFile(_SurnameDict, file, true, "Surname");
}
origin: medcl/elasticsearch-analysis-ik

private void loadPrepDict() {
  _PrepDict = new DictSegment((char) 0);
  Path file = PathUtils.get(getDictRoot(), Dictionary.PATH_DIC_PREP);
  loadDictFile(_PrepDict, file, true, "Preposition");
}
origin: medcl/elasticsearch-analysis-ik

private void loadSuffixDict() {
  _SuffixDict = new DictSegment((char) 0);
  Path file = PathUtils.get(getDictRoot(), Dictionary.PATH_DIC_SUFFIX);
  loadDictFile(_SuffixDict, file, true, "Suffix");
}
origin: medcl/elasticsearch-analysis-ik

/**
 * 加载量词词典
 */
private void loadQuantifierDict() {
  // 建立一个量词典实例
  _QuantifierDict = new DictSegment((char) 0);
  // 读取量词词典文件
  Path file = PathUtils.get(getDictRoot(), Dictionary.PATH_DIC_QUANTIFIER);
  loadDictFile(_QuantifierDict, file, false, "Quantifier");
}
origin: medcl/elasticsearch-analysis-ik

Path file = PathUtils.get(getDictRoot(), Dictionary.PATH_DIC_STOP);
loadDictFile(_StopWords, file, false, "Main Stopwords");
    file = PathUtils.get(extStopWordDictName);
    loadDictFile(_StopWords, file, false, "Extra Stopwords");
origin: medcl/elasticsearch-analysis-ik

/**
 * 加载主词典及扩展词典
 */
private void loadMainDict() {
  // 建立一个主词典实例
  _MainDict = new DictSegment((char) 0);
  // 读取主词典文件
  Path file = PathUtils.get(getDictRoot(), Dictionary.PATH_DIC_MAIN);
  loadDictFile(_MainDict, file, false, "Main Dict");
  // 加载扩展词典
  this.loadExtDict();
  // 加载远程自定义词库
  this.loadRemoteExtDict();
}
origin: org.elasticsearch/elasticsearch

/**
 * Resolves the specified location against the list of configured repository roots
 *
 * If the specified location doesn't match any of the roots, returns null.
 */
public Path resolveRepoFile(String location) {
  return PathUtils.get(repoFiles, location);
}
org.elasticsearch.common.io

Most used classes

  • StreamInput
  • StreamOutput
    A stream from another node to this node. Technically, it can also be streamed from a byte array but
  • BytesStreamOutput
    A @link StreamOutput that uses BigArrays to acquire pages of bytes, which avoids frequent reallocati
  • Streams
    Simple utility methods for file and stream copying. All copy methods use a block size of 4096 bytes,
  • NamedWriteableAwareStreamInput
    Wraps a StreamInput and associates it with a NamedWriteableRegistry
  • ReleasableBytesStreamOutput,
  • FileSystemUtils,
  • ByteBufferStreamInput,
  • NamedWriteableRegistry,
  • FastStringReader,
  • InputStreamStreamInput,
  • UTF8StreamWriter,
  • OutputStreamStreamOutput,
  • BytesStream,
  • Streamable,
  • Writeable,
  • Channels,
  • FastCharArrayReader,
  • BytesStreamInput
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now