org.apache.lucene.document.FloatField Java Examples

The following examples show how to use org.apache.lucene.document.FloatField. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FloatFieldTypeDefinition.java    From incubator-retired-blur with Apache License 2.0 6 votes vote down vote up
@Override
public void configure(String fieldNameForThisInstance, Map<String, String> properties, Configuration configuration) {
  String precisionStepStr = properties.get(NUMERIC_PRECISION_STEP);
  if (precisionStepStr != null) {
    _precisionStep = Integer.parseInt(precisionStepStr);
    _typeStored = new FieldType(FloatField.TYPE_STORED);
    _typeStored.setNumericPrecisionStep(_precisionStep);
    _typeStored.freeze();
    _typeNotStored = new FieldType(FloatField.TYPE_NOT_STORED);
    _typeNotStored.setNumericPrecisionStep(_precisionStep);
    _typeNotStored.freeze();
  } else {
    _typeStored = FloatField.TYPE_STORED;
    _typeNotStored = FloatField.TYPE_NOT_STORED;
  }
}
 
Example #2
Source File: IndexedField.java    From sql-layer with GNU Affero General Public License v3.0 5 votes vote down vote up
public Field getField(ValueSource value) {
    if (value.isNull()) 
        return null;
    Field.Store store = Field.Store.NO; // Only store hkey.
    switch (fieldType) {
    case INT:
        switch (TInstance.underlyingType(value.getType())) {
        case INT_8:
            return new IntField(name, value.getInt8(), store);
        case INT_16:
            return new IntField(name, value.getInt16(), store);
        case UINT_16:
            return new IntField(name, value.getUInt16(), store);
        case INT_32:
        default:
            return new IntField(name, value.getInt32(), store);
        }
    case LONG:
        return new LongField(name, value.getInt64(), store);
    case FLOAT:
        return new FloatField(name, value.getFloat(), store);
    case DOUBLE:
        return new DoubleField(name, value.getDouble(), store);
    case STRING:
        switch (TInstance.underlyingType(value.getType())) {
        case STRING:
            return new StringField(name, value.getString(), store);
        default:
            {
                StringBuilder str = new StringBuilder();
                value.getType().format(value, AkibanAppender.of(str));
                return new StringField(name, str.toString(), store);
            }
        }
    case TEXT:
        return new TextField(name, value.getString(), store);
    default:
        return null;
    }
}
 
Example #3
Source File: FloatFieldTypeDefinition.java    From incubator-retired-blur with Apache License 2.0 5 votes vote down vote up
@Override
public Iterable<? extends Field> getFieldsForColumn(String family, Column column) {
  String name = getName(family, column.getName());
  float value = Float.parseFloat(column.getValue());
  FloatField field = new FloatField(name, value, _typeStored);
  if (isSortEnable()) {
    return addSort(name, Float.floatToRawIntBits(value), field);
  }
  return makeIterable(field);
}
 
Example #4
Source File: FloatFieldTypeDefinition.java    From incubator-retired-blur with Apache License 2.0 5 votes vote down vote up
@Override
public Iterable<? extends Field> getFieldsForSubColumn(String family, Column column, String subName) {
  String name = getName(family, column.getName(), subName);
  float value = Float.parseFloat(column.getValue());
  FloatField field = new FloatField(name, value, _typeNotStored);
  if (isSortEnable()) {
    return addSort(name, Float.floatToRawIntBits(value), field);
  }
  return makeIterable(field);
}