1+ package com .jthink .spring .boot .starter .hbase .api ;
2+
3+ import org .apache .hadoop .hbase .client .Mutation ;
4+ import org .apache .hadoop .hbase .client .Scan ;
5+
6+ import java .util .List ;
7+
8+ /**
9+ * Interface that specifies a basic set of Hbase operations, implemented by {@link HbaseTemplate}. Not often used,
10+ * but a useful option to enhance testability, as it can easily be mocked or stubbed.
11+ *
12+ * @author Costin Leau
13+ * @author Shaun Elliott
14+ */
15+ /**
16+ * JThink@JThink
17+ *
18+ * @author JThink
19+ * @version 0.0.1
20+ * @desc copy from spring data hadoop hbase, modified by JThink, remove the unuse interface
21+ * @date 2016-11-15 14:49:52
22+ */
23+ public interface HbaseOperations {
24+
25+ /**
26+ * Executes the given action against the specified table handling resource management.
27+ * <p>
28+ * Application exceptions thrown by the action object get propagated to the caller (can only be unchecked).
29+ * Allows for returning a result object (typically a domain object or collection of domain objects).
30+ *
31+ * @param tableName the target table
32+ * @param action callback object that specifies the action
33+ * @param <T> action type
34+ * @return the result object of the callback action, or null
35+ */
36+ <T > T execute (String tableName , TableCallback <T > mapper );
37+
38+ /**
39+ * Scans the target table, using the given column family.
40+ * The content is processed row by row by the given action, returning a list of domain objects.
41+ *
42+ * @param tableName target table
43+ * @param family column family
44+ * @param action row mapper handling the scanner results
45+ * @param <T> action type
46+ * @return a list of objects mapping the scanned rows
47+ */
48+ <T > List <T > find (String tableName , String family , final RowMapper <T > mapper );
49+
50+ /**
51+ * Scans the target table, using the given column family.
52+ * The content is processed row by row by the given action, returning a list of domain objects.
53+ *
54+ * @param tableName target table
55+ * @param family column family
56+ * @param qualifier column qualifier
57+ * @param action row mapper handling the scanner results
58+ * @param <T> action type
59+ * @return a list of objects mapping the scanned rows
60+ */
61+ <T > List <T > find (String tableName , String family , String qualifier , final RowMapper <T > mapper );
62+
63+ /**
64+ * Scans the target table using the given {@link Scan} object. Suitable for maximum control over the scanning
65+ * process.
66+ * The content is processed row by row by the given action, returning a list of domain objects.
67+ *
68+ * @param tableName target table
69+ * @param scan table scanner
70+ * @param action row mapper handling the scanner results
71+ * @param <T> action type
72+ * @return a list of objects mapping the scanned rows
73+ */
74+ <T > List <T > find (String tableName , final Scan scan , final RowMapper <T > mapper );
75+
76+ /**
77+ * Gets an individual row from the given table. The content is mapped by the given action.
78+ *
79+ * @param tableName target table
80+ * @param rowName row name
81+ * @param mapper row mapper
82+ * @param <T> mapper type
83+ * @return object mapping the target row
84+ */
85+ <T > T get (String tableName , String rowName , final RowMapper <T > mapper );
86+
87+ /**
88+ * Gets an individual row from the given table. The content is mapped by the given action.
89+ *
90+ * @param tableName target table
91+ * @param rowName row name
92+ * @param familyName column family
93+ * @param mapper row mapper
94+ * @param <T> mapper type
95+ * @return object mapping the target row
96+ */
97+ <T > T get (String tableName , String rowName , String familyName , final RowMapper <T > mapper );
98+
99+ /**
100+ * Gets an individual row from the given table. The content is mapped by the given action.
101+ *
102+ * @param tableName target table
103+ * @param rowName row name
104+ * @param familyName family
105+ * @param qualifier column qualifier
106+ * @param mapper row mapper
107+ * @param <T> mapper type
108+ * @return object mapping the target row
109+ */
110+ <T > T get (String tableName , final String rowName , final String familyName , final String qualifier , final RowMapper <T > mapper );
111+
112+ /**
113+ * 执行put update or delete
114+ * @param tableName
115+ * @param action
116+ */
117+ void execute (String tableName , MutatorCallback action );
118+
119+ /**
120+ *
121+ * @param tableName
122+ * @param mutation
123+ */
124+ void saveOrUpdate (String tableName , Mutation mutation );
125+
126+ /**
127+ *
128+ * @param tableName
129+ * @param mutations
130+ */
131+ void saveOrUpdates (String tableName , List <Mutation > mutations );
132+ }
0 commit comments