org.elasticsearch.common.text.Text.hasBytes()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(4.0k)|赞(0)|评价(0)|浏览(92)

本文整理了Java中org.elasticsearch.common.text.Text.hasBytes()方法的一些代码示例,展示了Text.hasBytes()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Text.hasBytes()方法的具体详情如下:
包路径:org.elasticsearch.common.text.Text
类名称:Text
方法名:hasBytes

Text.hasBytes介绍

[英]Whether a BytesReference view of the data is already materialized.
[中]数据的字节引用视图是否已经具体化。

代码示例

代码示例来源:origin: org.elasticsearch/elasticsearch

public void writeText(Text text) throws IOException {
  if (!text.hasBytes()) {
    final String string = text.string();
    spare.copyChars(string);
    writeInt(spare.length());
    write(spare.bytes(), 0, spare.length());
  } else {
    BytesReference bytes = text.bytes();
    writeInt(bytes.length());
    bytes.writeTo(this);
  }
}

代码示例来源:origin: com.strapdata.elasticsearch/elasticsearch

public void writeText(Text text) throws IOException {
  if (!text.hasBytes()) {
    final String string = text.string();
    spare.copyChars(string);
    writeInt(spare.length());
    write(spare.bytes(), 0, spare.length());
  } else {
    BytesReference bytes = text.bytes();
    writeInt(bytes.length());
    bytes.writeTo(this);
  }
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.elasticsearch

public void writeText(Text text) throws IOException {
  if (!text.hasBytes()) {
    final String string = text.string();
    spare.copyChars(string);
    writeInt(spare.length());
    write(spare.bytes(), 0, spare.length());
  } else {
    BytesReference bytes = text.bytes();
    writeInt(bytes.length());
    bytes.writeTo(this);
  }
}

代码示例来源:origin: apache/servicemix-bundles

public void writeText(Text text) throws IOException {
  if (!text.hasBytes()) {
    final String string = text.string();
    spare.copyChars(string);
    writeInt(spare.length());
    write(spare.bytes(), 0, spare.length());
  } else {
    BytesReference bytes = text.bytes();
    writeInt(bytes.length());
    bytes.writeTo(this);
  }
}

代码示例来源:origin: harbby/presto-connectors

public void writeText(Text text) throws IOException {
  if (!text.hasBytes()) {
    final String string = text.string();
    spare.copyChars(string);
    writeInt(spare.length());
    write(spare.bytes(), 0, spare.length());
  } else {
    BytesReference bytes = text.bytes();
    writeInt(bytes.length());
    bytes.writeTo(this);
  }
}

代码示例来源:origin: harbby/presto-connectors

public XContentBuilder field(XContentBuilderString name, Text value) throws IOException {
  field(name);
  if (value.hasBytes() && value.bytes().hasArray()) {
    generator.writeUTF8String(value.bytes().array(), value.bytes().arrayOffset(), value.bytes().length());
    return this;
  }
  if (value.hasString()) {
    generator.writeString(value.string());
    return this;
  }
  // TODO: TextBytesOptimization we can use a buffer here to convert it? maybe add a request to jackson to support InputStream as well?
  BytesArray bytesArray = value.bytes().toBytesArray();
  generator.writeUTF8String(bytesArray.array(), bytesArray.arrayOffset(), bytesArray.length());
  return this;
}

代码示例来源:origin: harbby/presto-connectors

public XContentBuilder field(String name, Text value) throws IOException {
  field(name);
  if (value.hasBytes() && value.bytes().hasArray()) {
    generator.writeUTF8String(value.bytes().array(), value.bytes().arrayOffset(), value.bytes().length());
    return this;
  }
  if (value.hasString()) {
    generator.writeString(value.string());
    return this;
  }
  // TODO: TextBytesOptimization we can use a buffer here to convert it? maybe add a request to jackson to support InputStream as well?
  BytesArray bytesArray = value.bytes().toBytesArray();
  generator.writeUTF8String(bytesArray.array(), bytesArray.arrayOffset(), bytesArray.length());
  return this;
}

代码示例来源:origin: harbby/presto-connectors

public XContentBuilder value(Text value) throws IOException {
  if (value == null) {
    return nullValue();
  }
  if (value.hasBytes() && value.bytes().hasArray()) {
    generator.writeUTF8String(value.bytes().array(), value.bytes().arrayOffset(), value.bytes().length());
    return this;
  }
  if (value.hasString()) {
    generator.writeString(value.string());
    return this;
  }
  BytesArray bytesArray = value.bytes().toBytesArray();
  generator.writeUTF8String(bytesArray.array(), bytesArray.arrayOffset(), bytesArray.length());
  return this;
}

代码示例来源:origin: harbby/presto-connectors

} else if (value instanceof Text) {
  Text text = (Text) value;
  if (text.hasBytes() && text.bytes().hasArray()) {
    generator.writeUTF8String(text.bytes().array(), text.bytes().arrayOffset(), text.bytes().length());
  } else if (text.hasString()) {

相关文章