@@ -36,59 +36,58 @@ public DataMovementServices setClient(DatabaseClient client) {
3636 return this ;
3737 }
3838
39- QueryConfig initConfig (String method , SearchQueryDefinition qdef ) {
40- logger .debug ("initializing forest configuration with query" );
41- if (qdef == null ) throw new IllegalArgumentException ("null query definition" );
42-
43- JsonNode result = ((DatabaseClientImpl ) this .client ).getServices ()
44- .forestInfo (null , method , new RequestParameters (), qdef , new JacksonHandle ())
45- .get ();
46- // System.out.println(result.toPrettyString());
47-
48- QueryConfig queryConfig = new QueryConfig ();
49-
50- try {
51- ObjectMapper mapper = new ObjectMapper ();
52- JsonNode queryResult = result .get ("query" );
53- if (queryResult != null && queryResult .isObject () && queryResult .has ("ctsquery" )) {
54- queryConfig .serializedCtsQuery = mapper .writeValueAsString (queryResult );
55- logger .debug ("initialized query to: {}" , queryConfig .serializedCtsQuery );
56- }
57- JsonNode filteredResult = result .get ("filtered" );
58- if (filteredResult != null && filteredResult .isBoolean ()) {
59- queryConfig .filtered = filteredResult .asBoolean ();
60- logger .debug ("initialized filtering to: {}" , queryConfig .filtered .toString ());
61- }
62- JsonNode maxDocToUriBatchRatio = result .get ("maxDocToUriBatchRatio" );
63- if (maxDocToUriBatchRatio != null && maxDocToUriBatchRatio .isInt ()) {
64- queryConfig .maxDocToUriBatchRatio = maxDocToUriBatchRatio .asInt ();
65- logger .debug ("initialized maxDocToUriBatchRatio to : {}" , queryConfig .maxDocToUriBatchRatio );
66- } else {
67- queryConfig .maxDocToUriBatchRatio = -1 ;
68- }
69- JsonNode defaultDocBatchSize = result .get ("defaultDocBatchSize" );
70- if (defaultDocBatchSize != null && defaultDocBatchSize .isInt ()) {
71- queryConfig .defaultDocBatchSize = defaultDocBatchSize .asInt ();
72- logger .debug ("initialized defaultDocBatchSize to : {}" , queryConfig .defaultDocBatchSize );
73- } else {
74- queryConfig .defaultDocBatchSize = -1 ;
75- }
76- JsonNode maxUriBatchSize = result .get ("maxUriBatchSize" );
77- if (maxUriBatchSize != null && maxUriBatchSize .isInt ()) {
78- queryConfig .maxUriBatchSize = maxUriBatchSize .asInt ();
79- logger .debug ("initialized maxUriBatchSize to : {}" , queryConfig .maxUriBatchSize );
80- } else {
81- queryConfig .maxUriBatchSize = -1 ;
82- }
83-
84- } catch (JsonProcessingException e ) {
85- logger .error ("failed to initialize query" , e );
86- }
87-
88- queryConfig .forestConfig = makeForestConfig (result .has ("forests" ) ? result .get ("forests" ) : result );
89-
90- return queryConfig ;
91- }
39+ QueryConfig initConfig (String method , SearchQueryDefinition qdef ) {
40+ logger .debug ("initializing forest configuration with query" );
41+ if (qdef == null ) throw new IllegalArgumentException ("null query definition" );
42+
43+ JsonNode result = ((DatabaseClientImpl ) this .client ).getServices ()
44+ .forestInfo (null , method , new RequestParameters (), qdef , new JacksonHandle ())
45+ .get ();
46+
47+ JsonNode queryResult = result .get ("query" );
48+
49+ String serializedCtsQuery = null ;
50+ if (queryResult != null && queryResult .isObject () && queryResult .has ("ctsquery" )) {
51+ try {
52+ serializedCtsQuery = new ObjectMapper ().writeValueAsString (queryResult );
53+ logger .debug ("initialized query to: {}" , serializedCtsQuery );
54+ } catch (JsonProcessingException e ) {
55+ logger .warn ("Unable to serialize query result while initializing QueryBatcher; cause: {}" , e .getMessage ());
56+ }
57+ }
58+
59+ JsonNode filteredResult = result .get ("filtered" );
60+ Boolean filtered = null ;
61+ if (filteredResult != null && filteredResult .isBoolean ()) {
62+ filtered = filteredResult .asBoolean ();
63+ logger .debug ("initialized filtering to: {}" , filtered );
64+ }
65+
66+ JsonNode maxDocToUriBatchRatioNode = result .get ("maxDocToUriBatchRatio" );
67+ int maxDocToUriBatchRatio = -1 ;
68+ if (maxDocToUriBatchRatioNode != null && maxDocToUriBatchRatioNode .isInt ()) {
69+ maxDocToUriBatchRatio = maxDocToUriBatchRatioNode .asInt ();
70+ logger .debug ("initialized maxDocToUriBatchRatio to : {}" , maxDocToUriBatchRatio );
71+ }
72+
73+ JsonNode defaultDocBatchSizeNode = result .get ("defaultDocBatchSize" );
74+ int defaultDocBatchSize = -1 ;
75+ if (defaultDocBatchSizeNode != null && defaultDocBatchSizeNode .isInt ()) {
76+ defaultDocBatchSize = defaultDocBatchSizeNode .asInt ();
77+ logger .debug ("initialized defaultDocBatchSize to : {}" , defaultDocBatchSize );
78+ }
79+
80+ JsonNode maxUriBatchSizeNode = result .get ("maxUriBatchSize" );
81+ int maxUriBatchSize = -1 ;
82+ if (maxUriBatchSizeNode != null && maxUriBatchSizeNode .isInt ()) {
83+ maxUriBatchSize = maxUriBatchSizeNode .asInt ();
84+ logger .debug ("initialized maxUriBatchSize to : {}" , maxUriBatchSize );
85+ }
86+
87+ ForestConfiguration forestConfig = makeForestConfig (result .has ("forests" ) ? result .get ("forests" ) : result );
88+ return new QueryConfig (serializedCtsQuery , forestConfig , filtered ,
89+ maxDocToUriBatchRatio , defaultDocBatchSize , maxUriBatchSize );
90+ }
9291
9392 ForestConfigurationImpl readForestConfig () {
9493 logger .debug ("initializing forest configuration" );
@@ -183,12 +182,4 @@ private String generateJobId() {
183182 return UUID .randomUUID ().toString ();
184183 }
185184
186- static class QueryConfig {
187- String serializedCtsQuery ;
188- ForestConfiguration forestConfig ;
189- Boolean filtered ;
190- int maxDocToUriBatchRatio ;
191- int defaultDocBatchSize ;
192- int maxUriBatchSize ;
193- }
194185}
0 commit comments