Java源码示例:org.apache.accumulo.core.client.mapreduce.RangeInputSplit
示例1
private static Scanner setupScanner(final Context context, final String tableName, final Configuration config) throws IOException {
final RangeInputSplit split = (RangeInputSplit) context.getInputSplit();
final Range splitRange = split.getRange();
final Scanner scanner = AccumuloRyaUtils.getScanner(tableName, config);
scanner.setRange(splitRange);
return scanner;
}
示例2
@Override
protected void setupIterators(TaskAttemptContext context, Scanner scanner, String tableName,
RangeInputSplit split) {
}
示例3
/**
* getSplits will retrieve all the splits for a job given a zoom level.
*
* @param context - the Job context.
* @return The list of splits from the table.
* @throws IOException when there is an issue getting the splits for the job.
*/
@Override
public List<InputSplit> getSplits(JobContext context) throws IOException
{
// get the configuration
Configuration conf = context.getConfiguration();
// get the input context for the image
ImageInputFormatContext tifc = ImageInputFormatContext.load(conf);
// get the zoom level of the pyramid
//int zl = tifc.getZoomLevel();
// get the splits from the super (Accumulo InputFormatBase)
List<InputSplit> splits = super.getSplits(context);
// prepare the return list
List<InputSplit> retList = new ArrayList<InputSplit>(splits.size());
// TODO: make this pull back integer pairs - so there is no need to smooth and go through things again
// make sure all the splits will conform to the splits type expected by the core
//List<RangeInputSplit>splits2 = smoothSplits(splits);
// go through all the splits and create the output splits
for (InputSplit is : splits)
{
// an Accumulo split is a RangeInputSplit
org.apache.accumulo.core.client.mapreduce.RangeInputSplit ris =
(org.apache.accumulo.core.client.mapreduce.RangeInputSplit) is;
// get the range
Range r = ris.getRange();
log.info("Range: " + r.toString());
// get the start
Key sk = r.getStartKey();
// get the end
Key ek = r.getEndKey();
// get the tile ids at the start and end of the range
long sl = 0;
long el = Long.MAX_VALUE >> 8;
// check the start of the range - make sure it is a usable value
if (sk != null)
{
Text sr = sk.getRow();
if (sr.toString().equals(MrGeoAccumuloConstants.MRGEO_ACC_METADATA))
{
continue;
}
sl = AccumuloUtils.toLong(sr);
}
// check the end of the range - make sure it is a usable value
if (ek != null)
{
Text er = ek.getRow();
if (er.toString().equals(MrGeoAccumuloConstants.MRGEO_ACC_METADATA))
{
continue;
}
el = AccumuloUtils.toLong(er);
}
// build the split used by core
TiledInputSplit tis = new TiledInputSplit(
is, // input split
sl, // start tile id
el, // end tile id
tifc.getZoomLevel(), // zoom level
tifc.getTileSize() // tile size
);
retList.add(tis);
Tile tile1 = TMSUtils.tileid(sl, tifc.getZoomLevel());
Tile tile2 = TMSUtils.tileid(el, tifc.getZoomLevel());
log.info("\tSplit starting at " + sl + " (" + tile1.tx + "," + tile1.ty + ")" + " and ending at " + el + " (" +
tile2.tx + "," + tile2.ty + ")");
}
return retList;
}