Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Override RDD count with a fast ES call
This avoids having to instantiate all the docs and it does take into account the associated query relates #526
- Loading branch information
Showing
9 changed files
with
73 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
mr/src/main/java/org/elasticsearch/hadoop/rest/commonshttp/GetMethodWithBody.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* Licensed to Elasticsearch under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
package org.elasticsearch.hadoop.rest.commonshttp; | ||
|
||
import org.apache.commons.httpclient.methods.EntityEnclosingMethod; | ||
|
||
public class GetMethodWithBody extends EntityEnclosingMethod { | ||
|
||
public GetMethodWithBody() { | ||
// not supported out of the box for EntityEnclosingMethods | ||
setFollowRedirects(false); | ||
} | ||
|
||
public GetMethodWithBody(String uri) { | ||
super(uri); | ||
// not supported out of the box for EntityEnclosingMethods | ||
setFollowRedirects(false); | ||
} | ||
|
||
public String getName() { | ||
return "GET"; | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
eb371b7
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@costin I like the idea of a "fast count" method for an ES RDD... but overriding
RDD.count
seems to me like it could easily cause some problems for users. For example, a very common pattern in Spark when caching an RDD for use multiple times (e.g. machine learning or interactive analytics) is to callRDD.count
on the cached RDD, in order to force all records to be materialized.Would it not be better to have a separate method for this? Or at least be very explicit about the fact that
count
now doesn't do what you might think it does via docs...eb371b7
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@MLnick I see. I'll revert the change and implement the optimized count method separately to preserve the semantics in place.
eb371b7
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@costin sounds good !