Class TableRecordReaderImpl
java.lang.Object
org.apache.hadoop.hbase.mapreduce.TableRecordReaderImpl
Iterate over an HBase table data, return (ImmutableBytesWritable, Result) pairs.
-
Field Summary
Modifier and TypeFieldDescriptionprivate org.apache.hadoop.mapreduce.TaskAttemptContext
private Scan
(package private) static final String
private Table
private ImmutableBytesWritable
private byte[]
private static final org.slf4j.Logger
static final String
private int
private boolean
private long
private long
private int
private Scan
private ResultScanner
private long
private Result
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Closes the split.Returns the current key.Returns the current value.float
The current progress of the record reader through its data.void
initialize
(org.apache.hadoop.mapreduce.InputSplit inputsplit, org.apache.hadoop.mapreduce.TaskAttemptContext context) Build the scanner.boolean
Positions the record reader to the next record.void
restart
(byte[] firstRow) Restart from survivable exceptions by creating a new scanner.protected static Method
retrieveGetCounterWithStringsParams
(org.apache.hadoop.mapreduce.TaskAttemptContext context) Deprecated.since 2.4.0 and 2.3.2, will be removed in 4.0.0void
Sets the HBase table.void
Sets the scan defining the actual details like columns etc.private void
If hbase runs on new version of mapreduce, RecordReader has access to counters thus can update counters based on scanMetrics.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.protected static void
updateCounters
(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
- The table to 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:
IOException
InterruptedException
-
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:
true
if 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.
-