forked from apache/hbase
-
Notifications
You must be signed in to change notification settings - Fork 7
HBASE-28440: Add support for using mapreduce sort in HFileOutputFormat2 (not yet merged upstream) #197
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
HBASE-28440: Add support for using mapreduce sort in HFileOutputFormat2 (not yet merged upstream) #197
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
a5aa940
Revert "HubSpot Backport: HBASE-29386 SnapshotProcedure and EnableTab…
hgromer 7c2356d
HubSpot Backport: HBASE-29447: Fix WAL archives cause incremental bac…
hgromer f4f990f
HubSpot Backport: Rack aware incremental backup (not yet proposed ups…
a2f7b66
HubSpot Edit: Use branched buildpack
ritika03494 85a319d
HBASE-29502: Skip meta cache in RegionReplicaReplicationEndpoint when…
charlesconnell a022e11
HBASE-29386 SnapshotProcedure and EnableTableProcedure can cause a de…
hgromer 6690644
HubSpot Backport: HBASE-29469 Add metrics with more detail for RpcThr…
sidkhillon 6dc9e9d
HBASE-28440: Add support for using mapreduce sort in HFileOutputForma…
0079a6d
merge conflicts
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
91 changes: 91 additions & 0 deletions
91
hbase-mapreduce/src/main/java/org/apache/hadoop/hbase/mapreduce/KeyOnlyCellComparable.java
This file contains hidden or 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,91 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF 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.apache.hadoop.hbase.mapreduce; | ||
|
||
import java.io.ByteArrayInputStream; | ||
import java.io.DataInput; | ||
import java.io.DataInputStream; | ||
import java.io.DataOutput; | ||
import java.io.IOException; | ||
import org.apache.hadoop.hbase.CellComparator; | ||
import org.apache.hadoop.hbase.ExtendedCell; | ||
import org.apache.hadoop.hbase.KeyValue; | ||
import org.apache.hadoop.hbase.PrivateCellUtil; | ||
import org.apache.hadoop.io.WritableComparable; | ||
import org.apache.hadoop.io.WritableComparator; | ||
import org.apache.yetus.audience.InterfaceAudience; | ||
|
||
@InterfaceAudience.Private | ||
public class KeyOnlyCellComparable implements WritableComparable<KeyOnlyCellComparable> { | ||
|
||
static { | ||
WritableComparator.define(KeyOnlyCellComparable.class, new KeyOnlyCellComparator()); | ||
} | ||
|
||
private ExtendedCell cell = null; | ||
|
||
public KeyOnlyCellComparable() { | ||
} | ||
|
||
public KeyOnlyCellComparable(ExtendedCell cell) { | ||
this.cell = cell; | ||
} | ||
|
||
public ExtendedCell getCell() { | ||
return cell; | ||
} | ||
|
||
@Override | ||
public int compareTo(KeyOnlyCellComparable o) { | ||
return CellComparator.getInstance().compare(cell, o.cell); | ||
} | ||
|
||
@Override | ||
public void write(DataOutput out) throws IOException { | ||
int keyLen = PrivateCellUtil.estimatedSerializedSizeOfKey(cell); | ||
int valueLen = 0; // We avoid writing value here. So just serialize as if an empty value. | ||
out.writeInt(keyLen + valueLen + KeyValue.KEYVALUE_INFRASTRUCTURE_SIZE); | ||
out.writeInt(keyLen); | ||
out.writeInt(valueLen); | ||
PrivateCellUtil.writeFlatKey(cell, out); | ||
out.writeLong(cell.getSequenceId()); | ||
} | ||
|
||
@Override | ||
public void readFields(DataInput in) throws IOException { | ||
cell = KeyValue.create(in); | ||
long seqId = in.readLong(); | ||
cell.setSequenceId(seqId); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wanted to avoid creating a new class, and wanted to use the CellWritableComparable but it write/read the sequenceId which caused issues with sorting. So this entire class exists to write the cell coordinates + the sequenceId |
||
} | ||
|
||
public static class KeyOnlyCellComparator extends WritableComparator { | ||
|
||
@Override | ||
public int compare(byte[] b1, int s1, int l1, byte[] b2, int s2, int l2) { | ||
try { | ||
KeyOnlyCellComparable kv1 = new KeyOnlyCellComparable(); | ||
kv1.readFields(new DataInputStream(new ByteArrayInputStream(b1, s1, l1))); | ||
KeyOnlyCellComparable kv2 = new KeyOnlyCellComparable(); | ||
kv2.readFields(new DataInputStream(new ByteArrayInputStream(b2, s2, l2))); | ||
return compare(kv1, kv2); | ||
} catch (IOException e) { | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
} | ||
} |
46 changes: 46 additions & 0 deletions
46
hbase-mapreduce/src/main/java/org/apache/hadoop/hbase/mapreduce/PreSortedCellsReducer.java
This file contains hidden or 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,46 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF 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.apache.hadoop.hbase.mapreduce; | ||
|
||
import java.io.IOException; | ||
import org.apache.hadoop.hbase.Cell; | ||
import org.apache.hadoop.hbase.CellUtil; | ||
import org.apache.hadoop.hbase.io.ImmutableBytesWritable; | ||
import org.apache.hadoop.hbase.util.MapReduceExtendedCell; | ||
import org.apache.hadoop.mapreduce.Reducer; | ||
import org.apache.yetus.audience.InterfaceAudience; | ||
|
||
@InterfaceAudience.Private | ||
public class PreSortedCellsReducer | ||
extends Reducer<KeyOnlyCellComparable, Cell, ImmutableBytesWritable, Cell> { | ||
|
||
@Override | ||
protected void reduce(KeyOnlyCellComparable key, Iterable<Cell> values, Context context) | ||
throws IOException, InterruptedException { | ||
|
||
int index = 0; | ||
for (Cell cell : values) { | ||
context.write(new ImmutableBytesWritable(CellUtil.cloneRow(key.getCell())), | ||
new MapReduceExtendedCell(cell)); | ||
|
||
if (++index % 100 == 0) { | ||
context.setStatus("Wrote " + index + " cells"); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
maybe paranoid, but it could be worth a debug log indicating the gate status here
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.
Makes sense, I'll add it in the underlying method so we log everytime we poll the config.