Class TableRecordReaderImpl
java.lang.Object
org.apache.hadoop.hbase.mapreduce.TableRecordReaderImpl
Iterate over an HBase table data, return (ImmutableBytesWritable, Result) pairs.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate org.apache.hadoop.mapreduce.TaskAttemptContextprivate Scan(package private) static final Stringprivate Tableprivate ImmutableBytesWritableprivate byte[]private static final org.slf4j.Loggerstatic final Stringprivate intprivate booleanprivate longprivate longprivate intprivate Scanprivate ResultScannerprivate longprivate Result -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes the split.Returns the current key.Returns the current value.floatThe current progress of the record reader through its data.voidinitialize(org.apache.hadoop.mapreduce.InputSplit inputsplit, org.apache.hadoop.mapreduce.TaskAttemptContext context) Build the scanner.booleanPositions the record reader to the next record.voidrestart(byte[] firstRow) Restart from survivable exceptions by creating a new scanner.protected static MethodretrieveGetCounterWithStringsParams(org.apache.hadoop.mapreduce.TaskAttemptContext context) Deprecated.since 2.4.0 and 2.3.2, will be removed in 4.0.0voidSets the HBase table.voidSets the scan defining the actual details like columns etc.private voidIf hbase runs on new version of mapreduce, RecordReader has access to counters thus can update counters based on scanMetrics.protected static voidupdateCounters(ScanMetrics scanMetrics, long numScannerRestarts, Method getCounter, org.apache.hadoop.mapreduce.TaskAttemptContext context, long numStale) Deprecated.since 2.4.0 and 2.3.2, will be removed in 4.0.0 UseupdateCounters(ScanMetrics, long, TaskAttemptContext, long)instead.protected static voidupdateCounters(ScanMetrics scanMetrics, long numScannerRestarts, org.apache.hadoop.mapreduce.TaskAttemptContext context, long numStale)
-
Field Details
-
LOG_PER_ROW_COUNT
- See Also:
-
LOG
-
HBASE_COUNTER_GROUP_NAME
- See Also:
-
scanner
-
scan
-
currentScan
-
htable
-
lastSuccessfulRow
-
key
-
value
-
context
-
numRestarts
-
numStale
-
timestamp
-
rowcount
-
logScannerActivity
-
logPerRowCount
-
-
Constructor Details
-
TableRecordReaderImpl
public TableRecordReaderImpl()
-
-
Method Details
-
restart
Restart from survivable exceptions by creating a new scanner.- Parameters:
firstRow- The first row to start at.- Throws:
IOException- When restarting fails.
-
retrieveGetCounterWithStringsParams
@Deprecated protected static Method retrieveGetCounterWithStringsParams(org.apache.hadoop.mapreduce.TaskAttemptContext context) throws IOException Deprecated.since 2.4.0 and 2.3.2, will be removed in 4.0.0In new mapreduce APIs, TaskAttemptContext has two getCounter methods Check if getCounter(String, String) method is available.- Returns:
- The getCounter method or null if not available.
- Throws:
IOException
-
setHTable
Sets the HBase table.- Parameters:
htable- TheHTableDescriptorto scan.
-
setScan
Sets the scan defining the actual details like columns etc.- Parameters:
scan- The scan to set.
-
initialize
public void initialize(org.apache.hadoop.mapreduce.InputSplit inputsplit, org.apache.hadoop.mapreduce.TaskAttemptContext context) throws IOException, InterruptedException Build the scanner. Not done in constructor to allow for extension.- Throws:
IOExceptionInterruptedException
-
close
Closes the split. -
getCurrentKey
Returns the current key.- Returns:
- The current key.
- Throws:
InterruptedException- When the job is aborted.IOException
-
getCurrentValue
Returns the current value.- Returns:
- The current value.
- Throws:
IOException- When the value is faulty.InterruptedException- When the job is aborted.
-
nextKeyValue
Positions the record reader to the next record.- Returns:
trueif there was another record.- Throws:
IOException- When reading the record failed.InterruptedException- When the job was aborted.
-
updateCounters
If hbase runs on new version of mapreduce, RecordReader has access to counters thus can update counters based on scanMetrics. If hbase runs on old version of mapreduce, it won't be able to get access to counters and TableRecorderReader can't update counter values. -
updateCounters
@Deprecated protected static void updateCounters(ScanMetrics scanMetrics, long numScannerRestarts, Method getCounter, org.apache.hadoop.mapreduce.TaskAttemptContext context, long numStale) Deprecated.since 2.4.0 and 2.3.2, will be removed in 4.0.0 UseupdateCounters(ScanMetrics, long, TaskAttemptContext, long)instead. -
updateCounters
protected static void updateCounters(ScanMetrics scanMetrics, long numScannerRestarts, org.apache.hadoop.mapreduce.TaskAttemptContext context, long numStale) -
getProgress
The current progress of the record reader through its data.- Returns:
- A number between 0.0 and 1.0, the fraction of the data read.
-