What is Mapreduce equivalent to top() function in Spark?
I am trying to find the equivalent solution to top() and take() functions in spark, for Mapreduce implementation. I want to extract the top k values, without saving the whole key, value pairs.
apache-spark mapreduce
add a comment |
I am trying to find the equivalent solution to top() and take() functions in spark, for Mapreduce implementation. I want to extract the top k values, without saving the whole key, value pairs.
apache-spark mapreduce
add a comment |
I am trying to find the equivalent solution to top() and take() functions in spark, for Mapreduce implementation. I want to extract the top k values, without saving the whole key, value pairs.
apache-spark mapreduce
I am trying to find the equivalent solution to top() and take() functions in spark, for Mapreduce implementation. I want to extract the top k values, without saving the whole key, value pairs.
apache-spark mapreduce
apache-spark mapreduce
edited Nov 21 '18 at 6:47
Ram Ghadiyaram
16.4k64477
16.4k64477
asked Nov 21 '18 at 4:32
Sadaf TafazoliSadaf Tafazoli
1
1
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
There is not a direct equivalent. If you need to do something similar without having Spark, I generally use Pig
It requires at least two map reduce phases. One to process the data, then another to collect the data you actually want
In the mapper, you set null writable (or some, single valued key), then emit all values, forcing them to a single reducer.
In the reducer, you collect all values you want to sort or emit into a limited size collection. I recommend a TreeMap or Binary Heap, because they auto-sort. Then, you loop over the size of that collection for K values
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53405293%2fwhat-is-mapreduce-equivalent-to-top-function-in-spark%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
There is not a direct equivalent. If you need to do something similar without having Spark, I generally use Pig
It requires at least two map reduce phases. One to process the data, then another to collect the data you actually want
In the mapper, you set null writable (or some, single valued key), then emit all values, forcing them to a single reducer.
In the reducer, you collect all values you want to sort or emit into a limited size collection. I recommend a TreeMap or Binary Heap, because they auto-sort. Then, you loop over the size of that collection for K values
add a comment |
There is not a direct equivalent. If you need to do something similar without having Spark, I generally use Pig
It requires at least two map reduce phases. One to process the data, then another to collect the data you actually want
In the mapper, you set null writable (or some, single valued key), then emit all values, forcing them to a single reducer.
In the reducer, you collect all values you want to sort or emit into a limited size collection. I recommend a TreeMap or Binary Heap, because they auto-sort. Then, you loop over the size of that collection for K values
add a comment |
There is not a direct equivalent. If you need to do something similar without having Spark, I generally use Pig
It requires at least two map reduce phases. One to process the data, then another to collect the data you actually want
In the mapper, you set null writable (or some, single valued key), then emit all values, forcing them to a single reducer.
In the reducer, you collect all values you want to sort or emit into a limited size collection. I recommend a TreeMap or Binary Heap, because they auto-sort. Then, you loop over the size of that collection for K values
There is not a direct equivalent. If you need to do something similar without having Spark, I generally use Pig
It requires at least two map reduce phases. One to process the data, then another to collect the data you actually want
In the mapper, you set null writable (or some, single valued key), then emit all values, forcing them to a single reducer.
In the reducer, you collect all values you want to sort or emit into a limited size collection. I recommend a TreeMap or Binary Heap, because they auto-sort. Then, you loop over the size of that collection for K values
answered Nov 21 '18 at 4:36
cricket_007cricket_007
80.8k1142110
80.8k1142110
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53405293%2fwhat-is-mapreduce-equivalent-to-top-function-in-spark%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown