[jira] [Commented] (SOLR-4048) Add a "findRecursive" method to NamedList

2013-05-20 Thread Shawn Heisey (JIRA)

[ 
https://issues.apache.org/jira/browse/SOLR-4048?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13662225#comment-13662225
 ] 

Shawn Heisey commented on SOLR-4048:


On 4x, two solr-core tests failed with 500 server errors during shard 
splitting.  I've seen this over and over in Jenkins, so I'm pretty sure it's 
not my changes.  All solr-solrj tests pass fine, and precommit passes.  The 
branch_4x commit is r1484548.

> Add a "findRecursive" method to NamedList
> -
>
> Key: SOLR-4048
> URL: https://issues.apache.org/jira/browse/SOLR-4048
> Project: Solr
>  Issue Type: New Feature
>Affects Versions: 4.0
>Reporter: Shawn Heisey
>Assignee: Shawn Heisey
>Priority: Minor
> Fix For: 4.4
>
> Attachments: SOLR-4048-cleanup.patch, SOLR-4048.patch, 
> SOLR-4048.patch, SOLR-4048.patch, SOLR-4048.patch, SOLR-4048.patch, 
> SOLR-4048.patch, SOLR-4048.patch
>
>
> Most of the time when accessing data from a NamedList, what you'll be doing 
> is using get() to retrieve another NamedList, and doing so over and over 
> until you reach the final level, where you'll actually retrieve the value you 
> want.
> I propose adding a method to NamedList which would do all that heavy lifting 
> for you.  I created the following method for my own code.  It could be 
> adapted fairly easily for inclusion into NamedList itself.  The only reason I 
> did not include it as a patch is because I figure you'll want to ensure it 
> meets all your particular coding guidelines, and that the JavaDoc is much 
> better than I have done here:
> {code}
>   /**
>* Recursively parse a NamedList and return the value at the last level,
>* assuming that the object found at each level is also a NamedList. For
>* example, if "response" is the NamedList response from the Solr4 mbean
>* handler, the following code makes sense:
>* 
>* String coreName = (String) getRecursiveFromResponse(response, new
>* String[] { "solr-mbeans", "CORE", "core", "stats", "coreName" });
>* 
>* 
>* @param namedList the NamedList to parse
>* @param args A list of values to recursively request
>* @return the object at the last level.
>* @throws SolrServerException
>*/
>   @SuppressWarnings("unchecked")
>   private final Object getRecursiveFromResponse(
>   NamedList namedList, String[] args)
>   throws SolrServerException
>   {
>   NamedList list = null;
>   Object value = null;
>   try
>   {
>   for (String key : args)
>   {
>   if (list == null)
>   {
>   list = namedList;
>   }
>   else
>   {
>   list = (NamedList) value;
>   }
>   value = list.get(key);
>   }
>   return value;
>   }
>   catch (Exception e)
>   {
>   throw new SolrServerException(
>   "Failed to recursively parse 
> NamedList", e);
>   }
>   }
> {code}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

-
To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org
For additional commands, e-mail: dev-h...@lucene.apache.org



[jira] [Commented] (SOLR-4048) Add a "findRecursive" method to NamedList

2013-05-20 Thread Uwe Schindler (JIRA)

[ 
https://issues.apache.org/jira/browse/SOLR-4048?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13661883#comment-13661883
 ] 

Uwe Schindler commented on SOLR-4048:
-

All fine now!

> Add a "findRecursive" method to NamedList
> -
>
> Key: SOLR-4048
> URL: https://issues.apache.org/jira/browse/SOLR-4048
> Project: Solr
>  Issue Type: New Feature
>Affects Versions: 4.0
>Reporter: Shawn Heisey
>Assignee: Shawn Heisey
>Priority: Minor
> Fix For: 4.4
>
> Attachments: SOLR-4048-cleanup.patch, SOLR-4048.patch, 
> SOLR-4048.patch, SOLR-4048.patch, SOLR-4048.patch, SOLR-4048.patch, 
> SOLR-4048.patch, SOLR-4048.patch
>
>
> Most of the time when accessing data from a NamedList, what you'll be doing 
> is using get() to retrieve another NamedList, and doing so over and over 
> until you reach the final level, where you'll actually retrieve the value you 
> want.
> I propose adding a method to NamedList which would do all that heavy lifting 
> for you.  I created the following method for my own code.  It could be 
> adapted fairly easily for inclusion into NamedList itself.  The only reason I 
> did not include it as a patch is because I figure you'll want to ensure it 
> meets all your particular coding guidelines, and that the JavaDoc is much 
> better than I have done here:
> {code}
>   /**
>* Recursively parse a NamedList and return the value at the last level,
>* assuming that the object found at each level is also a NamedList. For
>* example, if "response" is the NamedList response from the Solr4 mbean
>* handler, the following code makes sense:
>* 
>* String coreName = (String) getRecursiveFromResponse(response, new
>* String[] { "solr-mbeans", "CORE", "core", "stats", "coreName" });
>* 
>* 
>* @param namedList the NamedList to parse
>* @param args A list of values to recursively request
>* @return the object at the last level.
>* @throws SolrServerException
>*/
>   @SuppressWarnings("unchecked")
>   private final Object getRecursiveFromResponse(
>   NamedList namedList, String[] args)
>   throws SolrServerException
>   {
>   NamedList list = null;
>   Object value = null;
>   try
>   {
>   for (String key : args)
>   {
>   if (list == null)
>   {
>   list = namedList;
>   }
>   else
>   {
>   list = (NamedList) value;
>   }
>   value = list.get(key);
>   }
>   return value;
>   }
>   catch (Exception e)
>   {
>   throw new SolrServerException(
>   "Failed to recursively parse 
> NamedList", e);
>   }
>   }
> {code}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

-
To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org
For additional commands, e-mail: dev-h...@lucene.apache.org



[jira] [Commented] (SOLR-4048) Add a "findRecursive" method to NamedList

2013-05-20 Thread Shawn Heisey (JIRA)

[ 
https://issues.apache.org/jira/browse/SOLR-4048?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13661832#comment-13661832
 ] 

Shawn Heisey commented on SOLR-4048:


Trunk commit r1484386 to improve and clean up new method.  All tests and 
precommit passed.  Will run tests and precommit on 4x before backporting 
tomorrow.


> Add a "findRecursive" method to NamedList
> -
>
> Key: SOLR-4048
> URL: https://issues.apache.org/jira/browse/SOLR-4048
> Project: Solr
>  Issue Type: New Feature
>Affects Versions: 4.0
>Reporter: Shawn Heisey
>Assignee: Shawn Heisey
>Priority: Minor
> Fix For: 4.4
>
> Attachments: SOLR-4048-cleanup.patch, SOLR-4048.patch, 
> SOLR-4048.patch, SOLR-4048.patch, SOLR-4048.patch, SOLR-4048.patch, 
> SOLR-4048.patch, SOLR-4048.patch
>
>
> Most of the time when accessing data from a NamedList, what you'll be doing 
> is using get() to retrieve another NamedList, and doing so over and over 
> until you reach the final level, where you'll actually retrieve the value you 
> want.
> I propose adding a method to NamedList which would do all that heavy lifting 
> for you.  I created the following method for my own code.  It could be 
> adapted fairly easily for inclusion into NamedList itself.  The only reason I 
> did not include it as a patch is because I figure you'll want to ensure it 
> meets all your particular coding guidelines, and that the JavaDoc is much 
> better than I have done here:
> {code}
>   /**
>* Recursively parse a NamedList and return the value at the last level,
>* assuming that the object found at each level is also a NamedList. For
>* example, if "response" is the NamedList response from the Solr4 mbean
>* handler, the following code makes sense:
>* 
>* String coreName = (String) getRecursiveFromResponse(response, new
>* String[] { "solr-mbeans", "CORE", "core", "stats", "coreName" });
>* 
>* 
>* @param namedList the NamedList to parse
>* @param args A list of values to recursively request
>* @return the object at the last level.
>* @throws SolrServerException
>*/
>   @SuppressWarnings("unchecked")
>   private final Object getRecursiveFromResponse(
>   NamedList namedList, String[] args)
>   throws SolrServerException
>   {
>   NamedList list = null;
>   Object value = null;
>   try
>   {
>   for (String key : args)
>   {
>   if (list == null)
>   {
>   list = namedList;
>   }
>   else
>   {
>   list = (NamedList) value;
>   }
>   value = list.get(key);
>   }
>   return value;
>   }
>   catch (Exception e)
>   {
>   throw new SolrServerException(
>   "Failed to recursively parse 
> NamedList", e);
>   }
>   }
> {code}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

-
To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org
For additional commands, e-mail: dev-h...@lucene.apache.org



[jira] [Commented] (SOLR-4048) Add a "findRecursive" method to NamedList

2013-05-19 Thread Uwe Schindler (JIRA)

[ 
https://issues.apache.org/jira/browse/SOLR-4048?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13661683#comment-13661683
 ] 

Uwe Schindler commented on SOLR-4048:
-

bq. The cleanup patch also fixes all warnings at the 1.7 compliance level in 
trunk.

Warnings are disabled in Solr because the whole Solr is a single huge warning 
:-)

> Add a "findRecursive" method to NamedList
> -
>
> Key: SOLR-4048
> URL: https://issues.apache.org/jira/browse/SOLR-4048
> Project: Solr
>  Issue Type: New Feature
>Affects Versions: 4.0
>Reporter: Shawn Heisey
>Assignee: Shawn Heisey
>Priority: Minor
> Fix For: 4.4
>
> Attachments: SOLR-4048-cleanup.patch, SOLR-4048.patch, 
> SOLR-4048.patch, SOLR-4048.patch, SOLR-4048.patch, SOLR-4048.patch, 
> SOLR-4048.patch, SOLR-4048.patch
>
>
> Most of the time when accessing data from a NamedList, what you'll be doing 
> is using get() to retrieve another NamedList, and doing so over and over 
> until you reach the final level, where you'll actually retrieve the value you 
> want.
> I propose adding a method to NamedList which would do all that heavy lifting 
> for you.  I created the following method for my own code.  It could be 
> adapted fairly easily for inclusion into NamedList itself.  The only reason I 
> did not include it as a patch is because I figure you'll want to ensure it 
> meets all your particular coding guidelines, and that the JavaDoc is much 
> better than I have done here:
> {code}
>   /**
>* Recursively parse a NamedList and return the value at the last level,
>* assuming that the object found at each level is also a NamedList. For
>* example, if "response" is the NamedList response from the Solr4 mbean
>* handler, the following code makes sense:
>* 
>* String coreName = (String) getRecursiveFromResponse(response, new
>* String[] { "solr-mbeans", "CORE", "core", "stats", "coreName" });
>* 
>* 
>* @param namedList the NamedList to parse
>* @param args A list of values to recursively request
>* @return the object at the last level.
>* @throws SolrServerException
>*/
>   @SuppressWarnings("unchecked")
>   private final Object getRecursiveFromResponse(
>   NamedList namedList, String[] args)
>   throws SolrServerException
>   {
>   NamedList list = null;
>   Object value = null;
>   try
>   {
>   for (String key : args)
>   {
>   if (list == null)
>   {
>   list = namedList;
>   }
>   else
>   {
>   list = (NamedList) value;
>   }
>   value = list.get(key);
>   }
>   return value;
>   }
>   catch (Exception e)
>   {
>   throw new SolrServerException(
>   "Failed to recursively parse 
> NamedList", e);
>   }
>   }
> {code}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

-
To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org
For additional commands, e-mail: dev-h...@lucene.apache.org



[jira] [Commented] (SOLR-4048) Add a "findRecursive" method to NamedList

2013-05-19 Thread Uwe Schindler (JIRA)

[ 
https://issues.apache.org/jira/browse/SOLR-4048?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13661682#comment-13661682
 ] 

Uwe Schindler commented on SOLR-4048:
-

Looks much better! The return type seems to be correct. The instanceof check 
was also fixed to be effective.

> Add a "findRecursive" method to NamedList
> -
>
> Key: SOLR-4048
> URL: https://issues.apache.org/jira/browse/SOLR-4048
> Project: Solr
>  Issue Type: New Feature
>Affects Versions: 4.0
>Reporter: Shawn Heisey
>Assignee: Shawn Heisey
>Priority: Minor
> Fix For: 4.4
>
> Attachments: SOLR-4048-cleanup.patch, SOLR-4048.patch, 
> SOLR-4048.patch, SOLR-4048.patch, SOLR-4048.patch, SOLR-4048.patch, 
> SOLR-4048.patch, SOLR-4048.patch
>
>
> Most of the time when accessing data from a NamedList, what you'll be doing 
> is using get() to retrieve another NamedList, and doing so over and over 
> until you reach the final level, where you'll actually retrieve the value you 
> want.
> I propose adding a method to NamedList which would do all that heavy lifting 
> for you.  I created the following method for my own code.  It could be 
> adapted fairly easily for inclusion into NamedList itself.  The only reason I 
> did not include it as a patch is because I figure you'll want to ensure it 
> meets all your particular coding guidelines, and that the JavaDoc is much 
> better than I have done here:
> {code}
>   /**
>* Recursively parse a NamedList and return the value at the last level,
>* assuming that the object found at each level is also a NamedList. For
>* example, if "response" is the NamedList response from the Solr4 mbean
>* handler, the following code makes sense:
>* 
>* String coreName = (String) getRecursiveFromResponse(response, new
>* String[] { "solr-mbeans", "CORE", "core", "stats", "coreName" });
>* 
>* 
>* @param namedList the NamedList to parse
>* @param args A list of values to recursively request
>* @return the object at the last level.
>* @throws SolrServerException
>*/
>   @SuppressWarnings("unchecked")
>   private final Object getRecursiveFromResponse(
>   NamedList namedList, String[] args)
>   throws SolrServerException
>   {
>   NamedList list = null;
>   Object value = null;
>   try
>   {
>   for (String key : args)
>   {
>   if (list == null)
>   {
>   list = namedList;
>   }
>   else
>   {
>   list = (NamedList) value;
>   }
>   value = list.get(key);
>   }
>   return value;
>   }
>   catch (Exception e)
>   {
>   throw new SolrServerException(
>   "Failed to recursively parse 
> NamedList", e);
>   }
>   }
> {code}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

-
To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org
For additional commands, e-mail: dev-h...@lucene.apache.org



[jira] [Commented] (SOLR-4048) Add a "findRecursive" method to NamedList

2013-05-19 Thread Shawn Heisey (JIRA)

[ 
https://issues.apache.org/jira/browse/SOLR-4048?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13661653#comment-13661653
 ] 

Shawn Heisey commented on SOLR-4048:


The cleanup patch also fixes all warnings at the 1.7 compliance level in trunk.

> Add a "findRecursive" method to NamedList
> -
>
> Key: SOLR-4048
> URL: https://issues.apache.org/jira/browse/SOLR-4048
> Project: Solr
>  Issue Type: New Feature
>Affects Versions: 4.0
>Reporter: Shawn Heisey
>Assignee: Shawn Heisey
>Priority: Minor
> Fix For: 4.4
>
> Attachments: SOLR-4048-cleanup.patch, SOLR-4048.patch, 
> SOLR-4048.patch, SOLR-4048.patch, SOLR-4048.patch, SOLR-4048.patch, 
> SOLR-4048.patch, SOLR-4048.patch
>
>
> Most of the time when accessing data from a NamedList, what you'll be doing 
> is using get() to retrieve another NamedList, and doing so over and over 
> until you reach the final level, where you'll actually retrieve the value you 
> want.
> I propose adding a method to NamedList which would do all that heavy lifting 
> for you.  I created the following method for my own code.  It could be 
> adapted fairly easily for inclusion into NamedList itself.  The only reason I 
> did not include it as a patch is because I figure you'll want to ensure it 
> meets all your particular coding guidelines, and that the JavaDoc is much 
> better than I have done here:
> {code}
>   /**
>* Recursively parse a NamedList and return the value at the last level,
>* assuming that the object found at each level is also a NamedList. For
>* example, if "response" is the NamedList response from the Solr4 mbean
>* handler, the following code makes sense:
>* 
>* String coreName = (String) getRecursiveFromResponse(response, new
>* String[] { "solr-mbeans", "CORE", "core", "stats", "coreName" });
>* 
>* 
>* @param namedList the NamedList to parse
>* @param args A list of values to recursively request
>* @return the object at the last level.
>* @throws SolrServerException
>*/
>   @SuppressWarnings("unchecked")
>   private final Object getRecursiveFromResponse(
>   NamedList namedList, String[] args)
>   throws SolrServerException
>   {
>   NamedList list = null;
>   Object value = null;
>   try
>   {
>   for (String key : args)
>   {
>   if (list == null)
>   {
>   list = namedList;
>   }
>   else
>   {
>   list = (NamedList) value;
>   }
>   value = list.get(key);
>   }
>   return value;
>   }
>   catch (Exception e)
>   {
>   throw new SolrServerException(
>   "Failed to recursively parse 
> NamedList", e);
>   }
>   }
> {code}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

-
To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org
For additional commands, e-mail: dev-h...@lucene.apache.org



[jira] [Commented] (SOLR-4048) Add a "findRecursive" method to NamedList

2013-05-18 Thread Uwe Schindler (JIRA)

[ 
https://issues.apache.org/jira/browse/SOLR-4048?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13661438#comment-13661438
 ] 

Uwe Schindler commented on SOLR-4048:
-

Just merge it after you committed to trunk, no need to revert. I just wanted to 
fix the compile failure.

The test with Integer and int is somehow not really useful, because it does not 
test NamedList, it just tests autoboxing and the java compiler. I would reduce 
it to one integer test and use (Integer) as cast.

> Add a "findRecursive" method to NamedList
> -
>
> Key: SOLR-4048
> URL: https://issues.apache.org/jira/browse/SOLR-4048
> Project: Solr
>  Issue Type: New Feature
>Affects Versions: 4.0
>Reporter: Shawn Heisey
>Assignee: Shawn Heisey
>Priority: Minor
> Fix For: 4.4
>
> Attachments: SOLR-4048.patch, SOLR-4048.patch, SOLR-4048.patch, 
> SOLR-4048.patch, SOLR-4048.patch, SOLR-4048.patch, SOLR-4048.patch
>
>
> Most of the time when accessing data from a NamedList, what you'll be doing 
> is using get() to retrieve another NamedList, and doing so over and over 
> until you reach the final level, where you'll actually retrieve the value you 
> want.
> I propose adding a method to NamedList which would do all that heavy lifting 
> for you.  I created the following method for my own code.  It could be 
> adapted fairly easily for inclusion into NamedList itself.  The only reason I 
> did not include it as a patch is because I figure you'll want to ensure it 
> meets all your particular coding guidelines, and that the JavaDoc is much 
> better than I have done here:
> {code}
>   /**
>* Recursively parse a NamedList and return the value at the last level,
>* assuming that the object found at each level is also a NamedList. For
>* example, if "response" is the NamedList response from the Solr4 mbean
>* handler, the following code makes sense:
>* 
>* String coreName = (String) getRecursiveFromResponse(response, new
>* String[] { "solr-mbeans", "CORE", "core", "stats", "coreName" });
>* 
>* 
>* @param namedList the NamedList to parse
>* @param args A list of values to recursively request
>* @return the object at the last level.
>* @throws SolrServerException
>*/
>   @SuppressWarnings("unchecked")
>   private final Object getRecursiveFromResponse(
>   NamedList namedList, String[] args)
>   throws SolrServerException
>   {
>   NamedList list = null;
>   Object value = null;
>   try
>   {
>   for (String key : args)
>   {
>   if (list == null)
>   {
>   list = namedList;
>   }
>   else
>   {
>   list = (NamedList) value;
>   }
>   value = list.get(key);
>   }
>   return value;
>   }
>   catch (Exception e)
>   {
>   throw new SolrServerException(
>   "Failed to recursively parse 
> NamedList", e);
>   }
>   }
> {code}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

-
To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org
For additional commands, e-mail: dev-h...@lucene.apache.org



[jira] [Commented] (SOLR-4048) Add a "findRecursive" method to NamedList

2013-05-18 Thread Shawn Heisey (JIRA)

[ 
https://issues.apache.org/jira/browse/SOLR-4048?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13661437#comment-13661437
 ] 

Shawn Heisey commented on SOLR-4048:


[~thetaphi] I appreciate your assist on the 4x build failure from my commit.  
I'd like to commit a slightly different fix in trunk and have the same code in 
4x, but I don't feel comfortable with the idea of reverting your commit, 
especially without your permission.  Could you do that?  I'll be watching, I'm 
ready with my trunk commit.


> Add a "findRecursive" method to NamedList
> -
>
> Key: SOLR-4048
> URL: https://issues.apache.org/jira/browse/SOLR-4048
> Project: Solr
>  Issue Type: New Feature
>Affects Versions: 4.0
>Reporter: Shawn Heisey
>Assignee: Shawn Heisey
>Priority: Minor
> Fix For: 4.4
>
> Attachments: SOLR-4048.patch, SOLR-4048.patch, SOLR-4048.patch, 
> SOLR-4048.patch, SOLR-4048.patch, SOLR-4048.patch, SOLR-4048.patch
>
>
> Most of the time when accessing data from a NamedList, what you'll be doing 
> is using get() to retrieve another NamedList, and doing so over and over 
> until you reach the final level, where you'll actually retrieve the value you 
> want.
> I propose adding a method to NamedList which would do all that heavy lifting 
> for you.  I created the following method for my own code.  It could be 
> adapted fairly easily for inclusion into NamedList itself.  The only reason I 
> did not include it as a patch is because I figure you'll want to ensure it 
> meets all your particular coding guidelines, and that the JavaDoc is much 
> better than I have done here:
> {code}
>   /**
>* Recursively parse a NamedList and return the value at the last level,
>* assuming that the object found at each level is also a NamedList. For
>* example, if "response" is the NamedList response from the Solr4 mbean
>* handler, the following code makes sense:
>* 
>* String coreName = (String) getRecursiveFromResponse(response, new
>* String[] { "solr-mbeans", "CORE", "core", "stats", "coreName" });
>* 
>* 
>* @param namedList the NamedList to parse
>* @param args A list of values to recursively request
>* @return the object at the last level.
>* @throws SolrServerException
>*/
>   @SuppressWarnings("unchecked")
>   private final Object getRecursiveFromResponse(
>   NamedList namedList, String[] args)
>   throws SolrServerException
>   {
>   NamedList list = null;
>   Object value = null;
>   try
>   {
>   for (String key : args)
>   {
>   if (list == null)
>   {
>   list = namedList;
>   }
>   else
>   {
>   list = (NamedList) value;
>   }
>   value = list.get(key);
>   }
>   return value;
>   }
>   catch (Exception e)
>   {
>   throw new SolrServerException(
>   "Failed to recursively parse 
> NamedList", e);
>   }
>   }
> {code}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

-
To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org
For additional commands, e-mail: dev-h...@lucene.apache.org



[jira] [Commented] (SOLR-4048) Add a "findRecursive" method to NamedList

2013-05-18 Thread Adrien Grand (JIRA)

[ 
https://issues.apache.org/jira/browse/SOLR-4048?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13661435#comment-13661435
 ] 

Adrien Grand commented on SOLR-4048:


Indeed I think the return type of the method is wrong since the return type of 
the method cannot be known at compile time. For example a 
NamedList> would return NamedList> if the 
array length is 0, NamedList if the array length is 1 and Integer if 
the array length is 2. There is a similar problem for intermediate NamedLists 
which are all casted to a NamedList although it's not their type. So the 
return type should probably be Object and the intermediate NamedLists should be 
casted to NamedList instead of NamedList.

> Add a "findRecursive" method to NamedList
> -
>
> Key: SOLR-4048
> URL: https://issues.apache.org/jira/browse/SOLR-4048
> Project: Solr
>  Issue Type: New Feature
>Affects Versions: 4.0
>Reporter: Shawn Heisey
>Assignee: Shawn Heisey
>Priority: Minor
> Fix For: 4.4
>
> Attachments: SOLR-4048.patch, SOLR-4048.patch, SOLR-4048.patch, 
> SOLR-4048.patch, SOLR-4048.patch, SOLR-4048.patch, SOLR-4048.patch
>
>
> Most of the time when accessing data from a NamedList, what you'll be doing 
> is using get() to retrieve another NamedList, and doing so over and over 
> until you reach the final level, where you'll actually retrieve the value you 
> want.
> I propose adding a method to NamedList which would do all that heavy lifting 
> for you.  I created the following method for my own code.  It could be 
> adapted fairly easily for inclusion into NamedList itself.  The only reason I 
> did not include it as a patch is because I figure you'll want to ensure it 
> meets all your particular coding guidelines, and that the JavaDoc is much 
> better than I have done here:
> {code}
>   /**
>* Recursively parse a NamedList and return the value at the last level,
>* assuming that the object found at each level is also a NamedList. For
>* example, if "response" is the NamedList response from the Solr4 mbean
>* handler, the following code makes sense:
>* 
>* String coreName = (String) getRecursiveFromResponse(response, new
>* String[] { "solr-mbeans", "CORE", "core", "stats", "coreName" });
>* 
>* 
>* @param namedList the NamedList to parse
>* @param args A list of values to recursively request
>* @return the object at the last level.
>* @throws SolrServerException
>*/
>   @SuppressWarnings("unchecked")
>   private final Object getRecursiveFromResponse(
>   NamedList namedList, String[] args)
>   throws SolrServerException
>   {
>   NamedList list = null;
>   Object value = null;
>   try
>   {
>   for (String key : args)
>   {
>   if (list == null)
>   {
>   list = namedList;
>   }
>   else
>   {
>   list = (NamedList) value;
>   }
>   value = list.get(key);
>   }
>   return value;
>   }
>   catch (Exception e)
>   {
>   throw new SolrServerException(
>   "Failed to recursively parse 
> NamedList", e);
>   }
>   }
> {code}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

-
To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org
For additional commands, e-mail: dev-h...@lucene.apache.org



[jira] [Commented] (SOLR-4048) Add a "findRecursive" method to NamedList

2013-05-17 Thread Shawn Heisey (JIRA)

[ 
https://issues.apache.org/jira/browse/SOLR-4048?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13660903#comment-13660903
 ] 

Shawn Heisey commented on SOLR-4048:


I'm going to add at least one more test - to validate what happens with some 
different object types.

After updating the patch for that, I'm planning to commit this in the next few 
hours unless there's a reasonable objection.  Even if I did something wrong in 
the new method, the patch won't break anything.  Due to the test additions, I'm 
reasonably confident that the coding is correct.


> Add a "findRecursive" method to NamedList
> -
>
> Key: SOLR-4048
> URL: https://issues.apache.org/jira/browse/SOLR-4048
> Project: Solr
>  Issue Type: New Feature
>Affects Versions: 4.0
>Reporter: Shawn Heisey
>Priority: Minor
> Fix For: 4.4
>
> Attachments: SOLR-4048.patch, SOLR-4048.patch, SOLR-4048.patch, 
> SOLR-4048.patch, SOLR-4048.patch, SOLR-4048.patch
>
>
> Most of the time when accessing data from a NamedList, what you'll be doing 
> is using get() to retrieve another NamedList, and doing so over and over 
> until you reach the final level, where you'll actually retrieve the value you 
> want.
> I propose adding a method to NamedList which would do all that heavy lifting 
> for you.  I created the following method for my own code.  It could be 
> adapted fairly easily for inclusion into NamedList itself.  The only reason I 
> did not include it as a patch is because I figure you'll want to ensure it 
> meets all your particular coding guidelines, and that the JavaDoc is much 
> better than I have done here:
> {code}
>   /**
>* Recursively parse a NamedList and return the value at the last level,
>* assuming that the object found at each level is also a NamedList. For
>* example, if "response" is the NamedList response from the Solr4 mbean
>* handler, the following code makes sense:
>* 
>* String coreName = (String) getRecursiveFromResponse(response, new
>* String[] { "solr-mbeans", "CORE", "core", "stats", "coreName" });
>* 
>* 
>* @param namedList the NamedList to parse
>* @param args A list of values to recursively request
>* @return the object at the last level.
>* @throws SolrServerException
>*/
>   @SuppressWarnings("unchecked")
>   private final Object getRecursiveFromResponse(
>   NamedList namedList, String[] args)
>   throws SolrServerException
>   {
>   NamedList list = null;
>   Object value = null;
>   try
>   {
>   for (String key : args)
>   {
>   if (list == null)
>   {
>   list = namedList;
>   }
>   else
>   {
>   list = (NamedList) value;
>   }
>   value = list.get(key);
>   }
>   return value;
>   }
>   catch (Exception e)
>   {
>   throw new SolrServerException(
>   "Failed to recursively parse 
> NamedList", e);
>   }
>   }
> {code}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

-
To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org
For additional commands, e-mail: dev-h...@lucene.apache.org