Example usage for org.apache.lucene.document Document getBinaryValues

List of usage examples for org.apache.lucene.document Document getBinaryValues

Introduction

In this page you can find the example usage for org.apache.lucene.document Document getBinaryValues.

Prototype

public final BytesRef[] getBinaryValues(String name) 

Source Link

Document

Returns an array of byte arrays for of the fields that have the name specified as the method parameter.

Usage

From source file:com.google.gerrit.lucene.LuceneChangeIndex.java

License:Apache License

private static <T> List<T> decodeProtos(Document doc, String fieldName, ProtobufCodec<T> codec) {
    BytesRef[] bytesRefs = doc.getBinaryValues(fieldName);
    if (bytesRefs.length == 0) {
        return Collections.emptyList();
    }//from  w w w.  j  a  v  a 2s. c  o m
    List<T> result = new ArrayList<>(bytesRefs.length);
    for (BytesRef r : bytesRefs) {
        result.add(codec.decode(r.bytes, r.offset, r.length));
    }
    return result;
}