[
https://issues.apache.org/jira/browse/LUCENE-3065?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13028677#comment-13028677
]
Uwe Schindler commented on LUCENE-3065:
---------------------------------------
Mike:
I reviewed the patch again: You are currently using 3 bits already. 1 bit is
solely for detecting numerics, the other two are the type.
In my opinion, to check if its a numeric field, use a MASK of 3 bits and check
for !=0. As soon as any bit in this mask is set, its numeric. The actual
numeric fields have values !=0:
{code}
private static final int _NUMERIC_BIT_SHIFT = 3;
static final byte FIELD_IS_NUMERIC_MASK = 0x07 << _NUMERIC_BIT_SHIFT;
static final byte FIELD_IS_NUMERIC_INT = 1 << _NUMERIC_BIT_SHIFT;
static final byte FIELD_IS_NUMERIC_LONG = 2 << _NUMERIC_BIT_SHIFT;
static final byte FIELD_IS_NUMERIC_FLOAT = 3 << _NUMERIC_BIT_SHIFT;
static final byte FIELD_IS_NUMERIC_DOUBLE = 4 << _NUMERIC_BIT_SHIFT;
// unused: static final byte FIELD_IS_NUMERIC_SHORT = 5 << _NUMERIC_BIT_SHIFT;
// unused: static final byte FIELD_IS_NUMERIC_BYTE = 6 << _NUMERIC_BIT_SHIFT;
// and we have still one more over :-) 7 << _NUMERIC_BIT_SHIFT
// check if field is numeric:
if ((bits & FIELD_IS_NUMERIC_MASK) != 0) {}
// parse type:
switch (bits & FIELD_IS_NUMERIC_MASK) {
case FIELD_IS_NUMERIC_INT: ...
}
{code}
> NumericField should be stored in binary format in index (matching Solr's
> format)
> --------------------------------------------------------------------------------
>
> Key: LUCENE-3065
> URL: https://issues.apache.org/jira/browse/LUCENE-3065
> Project: Lucene - Java
> Issue Type: Bug
> Components: Index
> Reporter: Michael McCandless
> Priority: Minor
> Fix For: 3.2, 4.0
>
> Attachments: LUCENE-3065.patch
>
>
> (Spinoff of LUCENE-3001)
> Today when writing stored fields we don't record that the field was a
> NumericField, and so at IndexReader time you get back an "ordinary" Field and
> your number has turned into a string. See
> https://issues.apache.org/jira/browse/LUCENE-1701?focusedCommentId=12721972&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-12721972
> We have spare bits already in stored fields, so, we should use one to record
> that the field is numeric, and then encode the numeric field in Solr's
> more-compact binary format.
> A nice side-effect is we fix the long standing issue that you don't get a
> NumericField back when loading your document.
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]