@@ -80,11 +80,7 @@ public void flatMap(CRow value, Collector<CRow> out) throws Exception {
8080 for (Integer conValIndex : sideInfo .getEqualValIndex ()) {
8181 Object equalObj = value .row ().getField (conValIndex );
8282 if (equalObj == null ) {
83- if (sideInfo .getJoinType () == JoinType .LEFT ) {
84- Row row = fillData (value .row (), null );
85- out .collect (new CRow (row , value .change ()));
86- }
87-
83+ sendOutputRow (value , null , out );
8884 return ;
8985 }
9086
@@ -94,18 +90,12 @@ public void flatMap(CRow value, Collector<CRow> out) throws Exception {
9490 String key = buildKey (inputParams );
9591 List <Map <String , Object >> cacheList = cacheRef .get ().get (key );
9692 if (CollectionUtils .isEmpty (cacheList )) {
97- if (sideInfo .getJoinType () == JoinType .LEFT ) {
98- Row row = fillData (value .row (), null );
99- out .collect (new CRow (row , value .change ()));
100- } else {
101- return ;
102- }
103-
93+ sendOutputRow (value , null , out );
10494 return ;
10595 }
10696
10797 for (Map <String , Object > one : cacheList ) {
108- out . collect ( new CRow ( fillData ( value . row () , one ), value . change ()) );
98+ sendOutputRow ( value , one , out );
10999 }
110100 }
111101
@@ -155,7 +145,7 @@ private String buildKey(Map<String, Object> val, List<String> equalFieldList) {
155145 }
156146
157147 @ Override
158- protected void initCache () throws SQLException {
148+ protected void initCache () {
159149 Map <String , List <Map <String , Object >>> newCache = Maps .newConcurrentMap ();
160150 cacheRef .set (newCache );
161151 try {
@@ -165,6 +155,7 @@ protected void initCache() throws SQLException {
165155 loadData (newCache );
166156 } catch (Exception e ) {
167157 LOG .error ("" , e );
158+ throw new RuntimeException (e );
168159 }
169160 }
170161
@@ -176,6 +167,7 @@ protected void reloadCache() {
176167 loadData (newCache );
177168 } catch (Exception e ) {
178169 LOG .error ("" , e );
170+ throw new RuntimeException (e );
179171 }
180172
181173 cacheRef .set (newCache );
@@ -210,6 +202,7 @@ private void loadData(Map<String, List<Map<String, Object>>> tmpCache) throws IO
210202
211203 } catch (Exception e ) {
212204 LOG .error ("" , e );
205+ throw new RuntimeException (e );
213206 } finally {
214207
215208 if (rhlClient != null ) {
@@ -220,18 +213,18 @@ private void loadData(Map<String, List<Map<String, Object>>> tmpCache) throws IO
220213
221214 // initialize searchSourceBuilder
222215 private SearchSourceBuilder initConfiguration (BoolQueryBuilder boolQueryBuilder ){
223- SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder ();
224- if (boolQueryBuilder != null ) {
225- searchSourceBuilder .query (boolQueryBuilder );
226- }
216+ SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder ();
217+ if (boolQueryBuilder != null ) {
218+ searchSourceBuilder .query (boolQueryBuilder );
219+ }
227220
228- searchSourceBuilder .size (getFetchSize ());
229- searchSourceBuilder .sort ("_id" , SortOrder .DESC );
221+ searchSourceBuilder .size (getFetchSize ());
222+ searchSourceBuilder .sort ("_id" , SortOrder .DESC );
230223
231- // fields included in the source data
232- String [] sideFieldNames = StringUtils .split (sideInfo .getSideSelectFields ().trim (), "," );
233- searchSourceBuilder .fetchSource (sideFieldNames , null );
234- return searchSourceBuilder ;
224+ // fields included in the source data
225+ String [] sideFieldNames = StringUtils .split (sideInfo .getSideSelectFields ().trim (), "," );
226+ searchSourceBuilder .fetchSource (sideFieldNames , null );
227+ return searchSourceBuilder ;
235228 }
236229
237230
@@ -247,6 +240,7 @@ private void searchData(SearchSourceBuilder searchSourceBuilder, Map<String, Lis
247240 // set search mark
248241 searchSourceBuilder .searchAfter (searchAfterParameter );
249242 }
243+
250244 searchRequest .source (searchSourceBuilder );
251245 searchResponse = rhlClient .search (searchRequest , RequestOptions .DEFAULT );
252246 searchHits = searchResponse .getHits ().getHits ();
@@ -267,6 +261,7 @@ private void searchData(SearchSourceBuilder searchSourceBuilder, Map<String, Lis
267261 private void loadToCache (SearchHit [] searchHits , Map <String , List <Map <String , Object >>> tmpCache ) {
268262 String [] sideFieldNames = StringUtils .split (sideInfo .getSideSelectFields ().trim (), "," );
269263 String [] sideFieldTypes = sideInfo .getSideTableInfo ().getFieldTypes ();
264+
270265 for (SearchHit searchHit : searchHits ) {
271266 Map <String , Object > oneRow = Maps .newHashMap ();
272267 for (String fieldName : sideFieldNames ) {
@@ -275,6 +270,7 @@ private void loadToCache(SearchHit[] searchHits, Map<String, List<Map<String, Ob
275270 object = SwitchUtil .getTarget (object , sideFieldTypes [fieldIndex ]);
276271 oneRow .put (fieldName .trim (), object );
277272 }
273+
278274 String cacheKey = buildKey (oneRow , sideInfo .getEqualFieldList ());
279275 List <Map <String , Object >> list = tmpCache .computeIfAbsent (cacheKey , key -> Lists .newArrayList ());
280276 list .add (oneRow );
0 commit comments