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


Java IndexableField.binaryValue方法代码示例

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


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

示例1: toDocs

import org.apache.lucene.index.IndexableField; //导入方法依赖的package包/类
private List<Doc> toDocs(ScoreDoc[] hits, Searcher searcher) throws IOException{
  List<Doc> documentList = new ArrayList<>();
  for (int i = 0; i < hits.length; ++i) {
    ScoreDoc scoreDoc = hits[i];
    Document doc = searcher.doc(scoreDoc.doc);
    IndexableField idField = doc.getField("_id");
    if(idField == null){
      // deleted between index hit and retrieval.
      continue;
    }
    final BytesRef ref = idField.binaryValue();
    final byte[] bytes = new byte[ref.length];
    System.arraycopy(ref.bytes, ref.offset, bytes, 0, ref.length);
    Doc outputDoc = new Doc(scoreDoc, bytes, 0);
    documentList.add(outputDoc);
  }
  return documentList;
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:19,代码来源:LuceneSearchIndex.java

示例2: getBinaryValue

import org.apache.lucene.index.IndexableField; //导入方法依赖的package包/类
public BytesRef getBinaryValue(String name) {
    for (IndexableField f : fields) {
        if (f.name().equals(name) && f.binaryValue() != null) {
            return f.binaryValue();
        }
    }
    return null;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:9,代码来源:ParseContext.java

示例3: resetFromIndexableField

import org.apache.lucene.index.IndexableField; //导入方法依赖的package包/类
public GeoPoint resetFromIndexableField(IndexableField field) {
    if (field instanceof LatLonPoint) {
        BytesRef br = field.binaryValue();
        byte[] bytes = Arrays.copyOfRange(br.bytes, br.offset, br.length);
        return this.reset(
            GeoEncodingUtils.decodeLatitude(bytes, 0),
            GeoEncodingUtils.decodeLongitude(bytes, Integer.BYTES));
    } else if (field instanceof LatLonDocValuesField) {
        long encoded = (long)(field.numericValue());
        return this.reset(
            GeoEncodingUtils.decodeLatitude((int)(encoded >>> 32)),
            GeoEncodingUtils.decodeLongitude((int)encoded));
    }
    return resetFromIndexHash(Long.parseLong(field.stringValue()));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:16,代码来源:GeoPoint.java

示例4: getBinaryValues

import org.apache.lucene.index.IndexableField; //导入方法依赖的package包/类
/**
* Returns an array of byte arrays for of the fields that have the name specified
* as the method parameter.  This method returns an empty
* array when there are no matching fields.  It never
* returns null.
*
* @param name the name of the field
* @return a <code>BytesRef[]</code> of binary field values
*/
public final BytesRef[] getBinaryValues(String name) {
  final List<BytesRef> result = new ArrayList<>();
  for (IndexableField field : fields) {
    if (field.name().equals(name)) {
      final BytesRef bytes = field.binaryValue();
      if (bytes != null) {
        result.add(bytes);
      }
    }
  }

  return result.toArray(new BytesRef[result.size()]);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:23,代码来源:Document.java

示例5: getBinaryValue

import org.apache.lucene.index.IndexableField; //导入方法依赖的package包/类
/**
* Returns an array of bytes for the first (or only) field that has the name
* specified as the method parameter. This method will return <code>null</code>
* if no binary fields with the specified name are available.
* There may be non-binary fields with the same name.
*
* @param name the name of the field.
* @return a <code>BytesRef</code> containing the binary field value or <code>null</code>
*/
public final BytesRef getBinaryValue(String name) {
  for (IndexableField field : fields) {
    if (field.name().equals(name)) {
      final BytesRef bytes = field.binaryValue();
      if (bytes != null) {
        return bytes;
      }
    }
  }
  return null;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:21,代码来源:Document.java

示例6: writeField

import org.apache.lucene.index.IndexableField; //导入方法依赖的package包/类
@Override
public void writeField(FieldInfo info, IndexableField field)
    throws IOException {

  ++numStoredFieldsInDoc;

  int bits = 0;
  final BytesRef bytes;
  final String string;

  Number number = field.numericValue();
  if (number != null) {
    if (number instanceof Byte || number instanceof Short || number instanceof Integer) {
      bits = NUMERIC_INT;
    } else if (number instanceof Long) {
      bits = NUMERIC_LONG;
    } else if (number instanceof Float) {
      bits = NUMERIC_FLOAT;
    } else if (number instanceof Double) {
      bits = NUMERIC_DOUBLE;
    } else {
      throw new IllegalArgumentException("cannot store numeric type " + number.getClass());
    }
    string = null;
    bytes = null;
  } else {
    bytes = field.binaryValue();
    if (bytes != null) {
      bits = BYTE_ARR;
      string = null;
    } else {
      bits = STRING;
      string = field.stringValue();
      if (string == null) {
        throw new IllegalArgumentException("field " + field.name() + " is stored but does not have binaryValue, stringValue nor numericValue");
      }
    }
  }

  final long infoAndBits = (((long) info.number) << TYPE_BITS) | bits;
  bufferedDocs.writeVLong(infoAndBits);

  if (bytes != null) {
    bufferedDocs.writeVInt(bytes.length);
    bufferedDocs.writeBytes(bytes.bytes, bytes.offset, bytes.length);
  } else if (string != null) {
    bufferedDocs.writeString(field.stringValue());
  } else {
    if (number instanceof Byte || number instanceof Short || number instanceof Integer) {
      bufferedDocs.writeInt(number.intValue());
    } else if (number instanceof Long) {
      bufferedDocs.writeLong(number.longValue());
    } else if (number instanceof Float) {
      bufferedDocs.writeInt(Float.floatToIntBits(number.floatValue()));
    } else if (number instanceof Double) {
      bufferedDocs.writeLong(Double.doubleToLongBits(number.doubleValue()));
    } else {
      throw new AssertionError("Cannot get here");
    }
  }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:62,代码来源:CompressingStoredFieldsWriter.java


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