[ https://issues.apache.org/jira/browse/SO
LR-272?page=com.atlassian.jira.plugin.system.issuetabpanels:
comment-tabpanel#action_12508614 ]
Yonik Seeley commented on SOLR-272:
-----------------------------------
An alternate way to do SolrDocument would be to only add a
Collection if there were multiple values... something along
the lines of:
public class SolrDocument2 {
private final HashMap<String,Object> _fields = new
HashMap<String,Object>();
public SolrDocument2() {
}
public Collection<String> getFieldNames() {
return _fields.keySet();
}
public void clear() {
_fields.clear();
}
public Object removeFields(String name) {
return _fields.remove( name ) != null;
}
public void setField(String name, Object value) {
_fields.put(name, value);
}
public void addField(String name, Object value)
{
Object existing = _fields.put(name, value);
if (existing == null) return;
if (existing instanceof Collection) {
Collection c = (Collection)existing;
c.add(value);
_fields.put(name, c);
}
}
/**
* returns the first value for this field
*/
public Object getFieldValue(String name) {
Object v = _fields.get( name );
if (v == null || !(v instanceof Collection)) return v;
Collection c = (Collection)v;
if (c.size() > 0 ) {
return c.iterator().next();
}
return null;
}
/**
* Get the value(s) for a given field... a Collection, or
an Object
*/
public Object getFieldValues(String name) {
return _fields.get( name );
}
}
> SolrDocument performance testing
> --------------------------------
>
> Key: SOLR-272
> URL: https:
//issues.apache.org/jira/browse/SOLR-272
> Project: Solr
> Issue Type: Test
> Affects Versions: 1.3
> Reporter: Ryan McKinley
> Attachments:
SOLR-272-SolrDocumentPerformanceTesting.patch,
SOLR-272-SolrDocumentPerformanceTesting.patch,
SolrDocumentPerformanceTester.java,
SolrDocumentPerformanceTester.java, SolrInputDoc.patch
>
>
> In 1.3, we added SolrInputDocument -- a temporary class
to hold document information. There is concern that this
may be less then ideal performance-wise.
> To settle some concerns (mine included) I want to
compare a few SolrDocument implementations to make sure we
are not doing something crazy.
> I implemented a LuceneInputDocument subclass of
SolrInputDocument that stores its values directly in Lucene
Document (rather then a Map<String,Collection>).
> This is a quick test comparing:
> 1. Building documents with SolrInputDocument
> 2. Building documents with LuceneInputDocument (same
interface writing directly to Document)
> 3. using DocumentBuilder (solr 1.2, solr 1.1)
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue
online.
|