[
https://issues.apache.org/jira/browse/LUCENE-1312?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12607838#action_12607838
]
Jason Rutherglen commented on LUCENE-1312:
------------------------------------------
Because the patch looks like a mess with the various changes I copied and
pasted the alterations to InstantiatedIndexReader to allow the following code
which works. Basically saving a copy of normsByFieldNameAndDocumentNumber into
the OceanInstantiatedIndexReader fixes the problem.
{code}
protected Map<String,List<NormUpdate>> updatedNormsByFieldNameAndDocumentNumber
= null;
public static class NormUpdate {
public int doc;
public byte value;
public NormUpdate(int doc, byte value) {
this.doc = doc;
this.value = value;
}
}
{code}
{code}
public class OceanInstantiatedIndexReader extends InstantiatedIndexReader {
private int maxDoc;
private Set<Integer> deletedDocs;
private Map<String,byte[]> normsByFieldNameAndDocumentNumber;
public OceanInstantiatedIndexReader(int maxDoc, InstantiatedIndex index,
Set<Integer> deletedDocs) {
super(index);
this.maxDoc = maxDoc;
this.deletedDocs = deletedDocs;
normsByFieldNameAndDocumentNumber = new
HashMap<String,byte[]>(index.getNormsByFieldNameAndDocumentNumber());
}
public int maxDoc() {
return maxDoc;
}
protected void doSetNorm(int doc, String field, byte value) throws
IOException {
if (updatedNormsByFieldNameAndDocumentNumber == null) {
updatedNormsByFieldNameAndDocumentNumber = new
HashMap<String,List<NormUpdate>>(normsByFieldNameAndDocumentNumber.size());
}
List<NormUpdate> list = updatedNormsByFieldNameAndDocumentNumber.get(field);
if (list == null) {
list = new LinkedList<NormUpdate>();
updatedNormsByFieldNameAndDocumentNumber.put(field, list);
}
list.add(new NormUpdate(doc, value));
}
public byte[] norms(String field) throws IOException {
byte[] norms = normsByFieldNameAndDocumentNumber.get(field);
if (updatedNormsByFieldNameAndDocumentNumber != null) {
norms = norms.clone();
List<NormUpdate> updated =
updatedNormsByFieldNameAndDocumentNumber.get(field);
if (updated != null) {
for (NormUpdate normUpdate : updated) {
norms[normUpdate.doc] = normUpdate.value;
}
}
}
return norms;
}
public void norms(String field, byte[] bytes, int offset) throws IOException {
byte[] norms = normsByFieldNameAndDocumentNumber.get(field);
System.arraycopy(norms, offset, bytes, 0, norms.length);
}
public int numDocs() {
return maxDoc() - deletedDocs.size();
}
public boolean isDeleted(int n) {
if (n >= maxDoc)
return true;
if (deletedDocs != null && deletedDocs.contains(n))
return true;
return false;
}
public boolean hasDeletions() {
return true;
}
}
{code}
> InstantiatedIndexReader does not implement getFieldNames properly
> -----------------------------------------------------------------
>
> Key: LUCENE-1312
> URL: https://issues.apache.org/jira/browse/LUCENE-1312
> Project: Lucene - Java
> Issue Type: Bug
> Components: contrib/*
> Reporter: Jason Rutherglen
> Assignee: Karl Wettin
> Attachments: lucene-1312.patch, lucene-1312.patch, lucene-1312.patch,
> lucene-1312.patch, lucene-1312.patch
>
>
> Causes error in org.apache.lucene.index.SegmentMerger.mergeFields
--
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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]