lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Uwe Schindler (JIRA)" <j...@apache.org>
Subject [jira] Updated: (LUCENE-1257) Port to Java5
Date Wed, 21 Oct 2009 08:49:00 GMT

     [ https://issues.apache.org/jira/browse/LUCENE-1257?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Uwe Schindler updated LUCENE-1257:
----------------------------------

    Comment: was deleted

(was: OK, thought I'd jump in and help out here with one of my Java 5 favourites. Haven't
seen anyone discuss this, and don't believe any of the patches address this, so thought I'd
throw a patch out there (against SVN HEAD @ revision 827821) which uses Java 5 covariant return
types for (almost) all of the Object#clone() implementations in core.

i.e. this:

  public Object clone() {
changes to:
  public SpanNotQuery clone() {

which lets us get rid of a whole bunch of now-unnecessary casts, so e.g.

      if (clone == null) clone = (SpanNotQuery) this.clone();
becomes
      if (clone == null) clone = this.clone();

Almost everything has been done and all downcasts removed, in core, with the exception of

* Some SpanQuery stuff, where it's assumed that it's safe to cast the clone() of a SpanQuery
to a SpanQuery -- this can't be made covariant without declaring "abstract SpanQuery clone()"
in SpanQuery itself, which breaks those SpanQuerys that don't declare their own clone()
* Some IndexReaders, e.g. DirectoryReader -- we can't be more specific than changing .clone()
to return IndexReader, because it returns the result of IndexReader.clone(boolean). We could
use covariant types for THAT, which would work fine, but that didn't follow the pattern of
the others so that could be a later commit.

Two changes were also made in contrib/, where not making the changes would have broken code
by trying to widen IndexInput#clone() back out to returning Object, which is not permitted.
contrib/ was otherwise left untouched.

Let me know what you think, or if you have any other questions.
)

> Port to Java5
> -------------
>
>                 Key: LUCENE-1257
>                 URL: https://issues.apache.org/jira/browse/LUCENE-1257
>             Project: Lucene - Java
>          Issue Type: Improvement
>          Components: Analysis, Examples, Index, Other, Query/Scoring, QueryParser, Search,
Store, Term Vectors
>    Affects Versions: 3.0
>            Reporter: C├ędric Champeau
>            Assignee: Uwe Schindler
>            Priority: Minor
>             Fix For: 3.0
>
>         Attachments: instantiated_fieldable.patch, LUCENE-1257-BooleanQuery.patch, LUCENE-1257-BooleanScorer_2.patch,
LUCENE-1257-BufferedDeletes_DocumentsWriter.patch, LUCENE-1257-CheckIndex.patch, LUCENE-1257-CloseableThreadLocal.patch,
LUCENE-1257-CompoundFileReaderWriter.patch, LUCENE-1257-ConcurrentMergeScheduler.patch, LUCENE-1257-DirectoryReader.patch,
LUCENE-1257-DisjunctionMaxQuery-more_type_safety.patch, LUCENE-1257-DocFieldProcessorPerThread.patch,
LUCENE-1257-Document.patch, LUCENE-1257-FieldCacheImpl.patch, LUCENE-1257-FieldCacheRangeFilter.patch,
LUCENE-1257-IndexDeleter.patch, LUCENE-1257-IndexDeletionPolicy_IndexFileDeleter.patch, LUCENE-1257-iw.patch,
LUCENE-1257-MTQWF.patch, LUCENE-1257-NormalizeCharMap.patch, LUCENE-1257-o.a.l.util.patch,
LUCENE-1257-org_apache_lucene_document.patch, LUCENE-1257-org_apache_lucene_document.patch,
LUCENE-1257-org_apache_lucene_document.patch, LUCENE-1257-SegmentInfos.patch, LUCENE-1257-StringBuffer.patch,
LUCENE-1257-StringBuffer.patch, LUCENE-1257-StringBuffer.patch, LUCENE-1257-TopDocsCollector.patch,
LUCENE-1257-WordListLoader.patch, LUCENE-1257_analysis.patch, LUCENE-1257_BooleanFilter_Generics.patch,
LUCENE-1257_contrib_highlighting.patch, LUCENE-1257_javacc_upgrade.patch, LUCENE-1257_messages.patch,
LUCENE-1257_more_unnecessary_casts.patch, LUCENE-1257_MultiFieldQueryParser.patch, LUCENE-1257_o.a.l.queryParser.patch,
LUCENE-1257_o.a.l.store.patch, LUCENE-1257_o_a_l_index_test.patch, LUCENE-1257_o_a_l_index_test.patch,
LUCENE-1257_o_a_l_search.patch, LUCENE-1257_o_a_l_search_spans.patch, LUCENE-1257_org_apache_lucene_index.patch,
LUCENE-1257_org_apache_lucene_index.patch, LUCENE-1257_queryParser_jj.patch, LUCENE-1257_unnecessary_casts.patch,
lucene1257surround1.patch, lucene1257surround1.patch, shinglematrixfilter_generified.patch
>
>
> For my needs I've updated Lucene so that it uses Java 5 constructs. I know Java 5 migration
had been planned for 2.1 someday in the past, but don't know when it is planned now. This
patch against the trunk includes :
> - most obvious generics usage (there are tons of usages of sets, ... Those which are
commonly used have been generified)
> - PriorityQueue generification
> - replacement of indexed for loops with for each constructs
> - removal of unnececessary unboxing
> The code is to my opinion much more readable with those features (you actually *know*
what is stored in collections reading the code, without the need to lookup for field definitions
everytime) and it simplifies many algorithms.
> Note that this patch also includes an interface for the Query class. This has been done
for my company's needs for building custom Query classes which add some behaviour to the base
Lucene queries. It prevents multiple unnnecessary casts. I know this introduction is not wanted
by the team, but it really makes our developments easier to maintain. If you don't want to
use this, replace all /Queriable/ calls with standard /Query/.

-- 
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


Mime
View raw message