*/
private void openScanner(final HttpServletRequest request,
final HttpServletResponse response, final String [] pathSegments)
throws IOException, ServletException {
// get the table
HTable table = getTable(getTableName(pathSegments));
// get the list of columns we're supposed to interact with
String[] raw_columns = request.getParameterValues(COLUMN);
Text [] columns = null;
if (raw_columns != null) {
columns = new Text [raw_columns.length];
for (int i = 0; i < raw_columns.length; i++) {
// I think this decoding is redundant.
columns[i] =
new Text(URLDecoder.decode(raw_columns[i], HConstants.UTF8_ENCODING));
}
} else {
// TODO: Need to put into the scanner all of the table's column
// families. TODO: Verify this returns all rows. For now just fail.
doMethodNotAllowed(response, "Unspecified columns parameter currently not supported!");
return;
}
// TODO: Parse according to the timestamp format we agree on.
String raw_ts = request.getParameter(TIMESTAMP);
// TODO: Are these decodings redundant?
Text startRow = request.getParameter(START_ROW) == null?
HConstants.EMPTY_START_ROW:
new Text(URLDecoder.decode(request.getParameter(START_ROW),
HConstants.UTF8_ENCODING));
// Empty start row is same value as empty end row.
Text endRow = request.getParameter(END_ROW) == null?
HConstants.EMPTY_START_ROW:
new Text(URLDecoder.decode(request.getParameter(END_ROW),
HConstants.UTF8_ENCODING));
HScannerInterface scanner = (request.getParameter(END_ROW) == null)?
table.obtainScanner(columns, startRow):
table.obtainScanner(columns, startRow, endRow);
// Make a scanner id by hashing the object toString value (object name +
// an id). Will make identifier less burdensome and more url friendly.
String scannerid =
Integer.toHexString(JenkinsHash.hash(scanner.toString().getBytes(), -1));