lucene-dev mailing list archives

[jira] Updated: (LUCENE-1217) use isBinary cached variable instead of instanceof in Field

Date

Wed, 12 Mar 2008 16:58:46 GMT

[ https://issues.apache.org/jira/browse/LUCENE-1217?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Doug Cutting updated LUCENE-1217:
---------------------------------
Description:
Field class can hold three types of values,
See: AbstractField.java protected Object fieldsData = null;
currently, mainly RTTI (instanceof) is used to determine the type of the value stored in particular
instance of the Field, but for binary value we have mixed RTTI and cached variable "boolean
isBinary"
This patch makes consistent use of cached variable isBinary.
Benefit: consistent usage of method to determine run-time type for binary case (reduces chance
to get out of sync on cached variable). It should be slightly faster as well.
Thinking aloud:
Would it not make sense to maintain type with some integer/byte"poor man's enum" (Interface
with a couple of constants)
code:java{
public static final interface Type{
public static final byte BOOLEAN = 0;
public static final byte STRING = 1;
public static final byte READER = 2;
....
}
}
and use that instead of isBinary + instanceof?
was:
Filed class can hold three types of values,
See: AbstractField.java protected Object fieldsData = null;
currently, mainly RTTI (instanceof) is used to determine the type of the value stored in particular
instance of the Field, but for binary value we have mixed RTTI and cached variable "boolean
isBinary"
This patch makes consistent use of cached variable isBinary.
Benefit: consistent usage of method to determine run-time type for binary case (reduces chance
to get out of sync on cached variable). It should be slightly faster as well.
Thinking aloud:
Would it not make sense to maintain type with some integer/byte"poor man's enum" (Interface
with a couple of constants)
code:java{
public static final interface Type{
public static final byte BOOLEAN = 0;
public static final byte STRING = 1;
public static final byte READER = 2;
....
}
}
and use that instead of isBinary + instanceof?
Lucene Fields: [New, Patch Available] (was: [Patch Available, New])
Summary: use isBinary cached variable instead of instanceof in Field (was: use
isBinary cached variable instead of instanceof in Filed)
fix typo that's been bugging me
> use isBinary cached variable instead of instanceof in Field
> -----------------------------------------------------------
>
> Key: LUCENE-1217
> URL: https://issues.apache.org/jira/browse/LUCENE-1217
> Project: Lucene - Java
> Issue Type: Improvement
> Components: Other
> Reporter: Eks Dev
> Assignee: Michael McCandless
> Priority: Trivial
> Attachments: Lucene-1217-take1.patch, LUCENE-1217.patch
>
>
> Field class can hold three types of values,
> See: AbstractField.java protected Object fieldsData = null;
> currently, mainly RTTI (instanceof) is used to determine the type of the value stored
in particular instance of the Field, but for binary value we have mixed RTTI and cached variable
"boolean isBinary"
> This patch makes consistent use of cached variable isBinary.
> Benefit: consistent usage of method to determine run-time type for binary case (reduces
chance to get out of sync on cached variable). It should be slightly faster as well.
> Thinking aloud:
> Would it not make sense to maintain type with some integer/byte"poor man's enum" (Interface
with a couple of constants)
> code:java{
> public static final interface Type{
> public static final byte BOOLEAN = 0;
> public static final byte STRING = 1;
> public static final byte READER = 2;
> ....
> }
> }
> and use that instead of isBinary + instanceof?
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-dev-help@lucene.apache.org