org.apache.flink.addons.hbase.TableInputFormat Java Examples
The following examples show how to use
org.apache.flink.addons.hbase.TableInputFormat.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: HBaseReadMain.java From flink-learning with Apache License 2.0 | 6 votes |
public static void main(String[] args) throws Exception { ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); env.createInput(new TableInputFormat<Tuple2<String, String>>() { private Tuple2<String, String> reuse = new Tuple2<String, String>(); @Override protected Scan getScanner() { Scan scan = new Scan(); scan.addColumn(INFO, BAR); return scan; } @Override protected String getTableName() { return HBASE_TABLE_NAME; } @Override protected Tuple2<String, String> mapResultToTuple(Result result) { String key = Bytes.toString(result.getRow()); String val = Bytes.toString(result.getValue(INFO, BAR)); reuse.setField(key, 0); reuse.setField(val, 1); return reuse; } }).filter(new FilterFunction<Tuple2<String, String>>() { @Override public boolean filter(Tuple2<String, String> value) throws Exception { return value.f1.startsWith("zhisheng"); } }).print(); }
Example #2
Source File: FlinkGHBaseByDataSet.java From flinkDemo with Apache License 2.0 | 5 votes |
public static void main(String[] args) { final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); DataSet<Tuple2<String, String>> hbaseInput = env.createInput(new TableInputFormat<Tuple2<String, String>>(){ @Override protected Scan getScanner() { Scan scan = new Scan(); scan.setStartRow(Bytes.toBytes("lastSpeed1")); scan.setStopRow(Bytes.toBytes("lastSpeed4")); return scan; } @Override protected String getTableName() { return "dfdq_rhm_aly:f_turbine_event_data"; } @Override protected Tuple2<String, String> mapResultToTuple(Result result) { Tuple2<String,String> tup = new Tuple2<String,String>(); tup.setField(Bytes.toString(result.getRow()),0); tup.setField(Bytes.toString(result.getValue("f".getBytes(), "slv".getBytes())), 1); return tup; } }); try { hbaseInput.print(); } catch (Exception e) { e.printStackTrace(); } }
Example #3
Source File: HBaseReadMain.java From flink-learning with Apache License 2.0 | 5 votes |
public static void main(String[] args) throws Exception { ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); env.createInput(new TableInputFormat<Tuple2<String, String>>() { private Tuple2<String, String> reuse = new Tuple2<String, String>(); @Override protected Scan getScanner() { Scan scan = new Scan(); scan.addColumn(INFO, BAR); return scan; } @Override protected String getTableName() { return HBASE_TABLE_NAME; } @Override protected Tuple2<String, String> mapResultToTuple(Result result) { String key = Bytes.toString(result.getRow()); String val = Bytes.toString(result.getValue(INFO, BAR)); reuse.setField(key, 0); reuse.setField(val, 1); return reuse; } }).filter(new FilterFunction<Tuple2<String, String>>() { @Override public boolean filter(Tuple2<String, String> value) throws Exception { return value.f1.startsWith("zhisheng"); } }).print(); }