lucenenet-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Iliev Andrei (JIRA)" <j...@apache.org>
Subject [jira] Commented: (LUCENENET-151) Bug in Lucene.Net.Search.MultiPhraseQuery.ExtractTerms(System.Collections.Hashtable terms)
Date Tue, 16 Sep 2008 12:36:44 GMT

    [ https://issues.apache.org/jira/browse/LUCENENET-151?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12631368#action_12631368
] 

Iliev Andrei commented on LUCENENET-151:
----------------------------------------

There are many other places in Lucent.Net source code where Hashtable/SortedDictionary add-method
used, but key's existence does not checked. I tried to fix it:

WordlistLoader.cs:
public static System.Collections.Hashtable GetWordSet(System.IO.TextReader reader)
                    if(!result.ContainsKey(tmp)){
                    result.Add(tmp, tmp);
                    }

FieldSortedTermVectorMapper.cs:

public override void Map(System.String term, int frequency, TermVectorOffsetInfo[] offsets,
int[] positions)
{
TermVectorEntry entry = new TermVectorEntry(currentField, term, frequency, offsets, positions);
                        if(!currentSet.ContainsKey(entry)){
currentSet.Add(entry, entry);
                        }
}

IndexFileNameFilter.cs:
public IndexFileNameFilter()
{
extensions = new System.Collections.Hashtable();
for (int i = 0; i < IndexFileNames.INDEX_EXTENSIONS.Length; i++)
{
                                if(!extensions.ContainsKey(IndexFileNames.INDEX_EXTENSIONS[i]){
extensions.Add(IndexFileNames.INDEX_EXTENSIONS[i], IndexFileNames.INDEX_EXTENSIONS[i]);
                                }
}
extensionsInCFS = new System.Collections.Hashtable();
for (int i = 0; i < IndexFileNames.INDEX_EXTENSIONS_IN_COMPOUND_FILE.Length; i++)
{
                           if(!extensionsInCFS.ContainsKey(IndexFileNames.INDEX_EXTENSIONS_IN_COMPOUND_FILE[i]){
                             extensionsInCFS.Add(IndexFileNames.INDEX_EXTENSIONS_IN_COMPOUND_FILE[i],
IndexFileNames.INDEX_EXTENSIONS_IN_COMPOUND_FILE[i]);
                           }
}
}

IndexWriter.cs:
                    if (!segmentsToOptimize.ContainsKey(segmentInfos.Info(i))){
                        segmentsToOptimize.Add(segmentInfos.Info(i), segmentInfos.Info(i));
                    }

                                        if(!runningMerges.ContainsKey(merge)){
runningMerges.Add(merge, merge);
                                        }

                                        if (!segmentsToOptimize.ContainsKey (merge.info)){
segmentsToOptimize.Add(merge.info, merge.info);
                                        }


SegmentReader.cs:
public override System.Collections.ICollection GetFieldNames(IndexReader.FieldOption fieldOption)
{
EnsureOpen();

            System.Collections.Hashtable fieldSet = new System.Collections.Hashtable();
for (int i = 0; i < fieldInfos.Size(); i++)
{
FieldInfo fi = fieldInfos.FieldInfo(i);
if (fieldOption == IndexReader.FieldOption.ALL)
{
                                  if(!fieldSet.ContainsKey(fi.name)){fieldSet.Add(fi.name,
fi.name);}
}
else if (!fi.isIndexed && fieldOption == IndexReader.FieldOption.UNINDEXED)
{
if(!fieldSet.ContainsKey(fi.name)){fieldSet.Add(fi.name, fi.name);}
}
else if (fi.storePayloads && fieldOption == IndexReader.FieldOption.STORES_PAYLOADS)
{
if(!fieldSet.ContainsKey(fi.name)){fieldSet.Add(fi.name, fi.name);}
}
else if (fi.isIndexed && fieldOption == IndexReader.FieldOption.INDEXED)
{
                                  if(!fieldSet.ContainsKey(fi.name)){fieldSet.Add(fi.name,
fi.name);}
}
else if (fi.isIndexed && fi.storeTermVector == false && fieldOption == IndexReader.FieldOption.INDEXED_NO_TERMVECTOR)
{
                                  if(!fieldSet.ContainsKey(fi.name)){fieldSet.Add(fi.name,
fi.name);}
}
else if (fi.storeTermVector == true && fi.storePositionWithTermVector == false &&
fi.storeOffsetWithTermVector == false && fieldOption == IndexReader.FieldOption.TERMVECTOR)
{
                                  if(!fieldSet.ContainsKey(fi.name)){fieldSet.Add(fi.name,
fi.name);}
}
else if (fi.isIndexed && fi.storeTermVector && fieldOption == IndexReader.FieldOption.INDEXED_WITH_TERMVECTOR)
{
                                  if(!fieldSet.ContainsKey(fi.name)){fieldSet.Add(fi.name,
fi.name);}
}
else if (fi.storePositionWithTermVector && fi.storeOffsetWithTermVector == false &&
fieldOption == IndexReader.FieldOption.TERMVECTOR_WITH_POSITION)
{
                                  if(!fieldSet.ContainsKey(fi.name)){fieldSet.Add(fi.name,
fi.name);}
}
else if (fi.storeOffsetWithTermVector && fi.storePositionWithTermVector == false &&
fieldOption == IndexReader.FieldOption.TERMVECTOR_WITH_OFFSET)
{
                                  if(!fieldSet.ContainsKey(fi.name)){fieldSet.Add(fi.name,
fi.name);}
}
else if ((fi.storeOffsetWithTermVector && fi.storePositionWithTermVector) &&
fieldOption == IndexReader.FieldOption.TERMVECTOR_WITH_POSITION_OFFSET)
{
                                  if(!fieldSet.ContainsKey(fi.name)){fieldSet.Add(fi.name,
fi.name);}
}
}
return fieldSet;
}


SortedTermVectorMapper.cs:
                                if(!currentSet.ContainsKey(entry){
currentSet.Add(entry, entry);
                                }

FilterManager.cs:
                                if(!sortedFilterItems.ContainsKey(entries.Entry.Key){
                                  sortedFilterItems.Add(entries.Entry.Key, entries.Entry.Value);
                                }

Query.cs:
                                        if(!allClauses.ContainsKey(clauses[j])){
allClauses.Add(clauses[j], clauses[j]);
                                        }
NativeFSLockFactory.cs:
                                                        if(!LOCK_HELD.ContainsKey (canonicalPath)){
LOCK_HELD.Add(canonicalPath, canonicalPath);
                                                        } 

> Bug in Lucene.Net.Search.MultiPhraseQuery.ExtractTerms(System.Collections.Hashtable terms)
> ------------------------------------------------------------------------------------------
>
>                 Key: LUCENENET-151
>                 URL: https://issues.apache.org/jira/browse/LUCENENET-151
>             Project: Lucene.Net
>          Issue Type: Bug
>         Environment: any/all
>            Reporter: Doug Sale
>            Priority: Minor
>         Attachments: MultiPhraseQuery.patch
>
>   Original Estimate: 0h
>  Remaining Estimate: 0h
>
> when a query contains duplicate terms, attempting to add them to the Hashtable argument
results in a thrown System.ArgumentException containing the message: "Item has already been
added."

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message