aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/parallelai/spyglass/hbase/HBaseConfigUtils.java
blob: 598a988360361a055b4b653efcf4d8db47fb7a3c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package parallelai.spyglass.hbase;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import java.io.IOException;

/**
 * Created with IntelliJ IDEA.
 * User: chand_000
 * Date: 29/08/13
 * Time: 17:25
 * To change this template use File | Settings | File Templates.
 */
public class HBaseConfigUtils {
    static final Log LOG = LogFactory.getLog(HBaseConfigUtils.class);

    public static void setRecordReaderParms(HBaseRecordReaderBase trr, HBaseTableSplitBase tSplit) throws IOException {
        switch (tSplit.getSourceMode()) {
            case SCAN_ALL:
            case SCAN_RANGE: {
                LOG.debug(String.format(
                        "For split [%s] we have start key (%s) and stop key (%s)",
                        tSplit, tSplit.getStartRow(), tSplit.getEndRow()));

                trr.setStartRow(tSplit.getStartRow());
                trr.setEndRow(tSplit.getEndRow());
                trr.setEndRowInclusive(tSplit.getEndRowInclusive());
                trr.setUseSalt(tSplit.getUseSalt());
            }

            break;

            case GET_LIST: {
                LOG.debug(String.format("For split [%s] we have key list (%s)",
                        tSplit, tSplit.getKeyList()));

                trr.setKeyList(tSplit.getKeyList());
                trr.setVersions(tSplit.getVersions());
                trr.setUseSalt(tSplit.getUseSalt());
            }

            break;

            default:
                throw new IOException("Unknown source mode : "
                        + tSplit.getSourceMode());
        }

        trr.setSourceMode(tSplit.getSourceMode());
    }

}