@@ -484,6 +484,16 @@ public static int sparqlIntegrate(CmdSparqlIntegrateMain cmd) throws Exception {
484
484
}
485
485
}
486
486
487
+ Long resultSetPageSize = cmd .paginationConfig .queryPageSize ;
488
+ if (resultSetPageSize != null && resultSetPageSize > 0 ) {
489
+ dataSourceTmp = RdfDataEngines .wrapWithDataSourceTransform (dataSourceTmp , ds -> RdfDataSources .withPagination (ds , resultSetPageSize ));
490
+ }
491
+
492
+ Long queryLimit = cmd .paginationConfig .queryLimit ;
493
+ if (queryLimit != null && queryLimit > 0 ) {
494
+ dataSourceTmp = RdfDataEngines .wrapWithDataSourceTransform (dataSourceTmp , ds -> RdfDataSources .withLimit (ds , queryLimit ));
495
+ }
496
+
487
497
dataSourceTmp = RdfDataEngines .wrapWithQueryTransform (dataSourceTmp , null , QueryExecs ::withDetailedHttpMessages );
488
498
489
499
if (cmd .cachePath != null ) {
@@ -582,16 +592,19 @@ public static int sparqlIntegrate(CmdSparqlIntegrateMain cmd) throws Exception {
582
592
583
593
// Load function macros (run sparql inferences first)
584
594
Map <String , UserDefinedFunctionDefinition > udfRegistry = new LinkedHashMap <>();
595
+
596
+ // XXX There should be a separate registry for default macros to load.
597
+ loadMacros (macroProfiles , udfRegistry , "macros/ollama.ttl" );
598
+
585
599
for (String macroSource : cmd .macroSources ) {
586
- Model model = RDFDataMgr .loadModel (macroSource );
587
- SparqlStmtMgr .execSparql (model , "udf-inferences.rq" );
588
- Map <String , UserDefinedFunctionDefinition > contrib = UserDefinedFunctions .load (model , macroProfiles );
589
- udfRegistry .putAll (contrib );
600
+ loadMacros (macroProfiles , udfRegistry , macroSource );
590
601
}
591
602
592
603
if (!cmd .macroSources .isEmpty ()) {
593
- logger .info ("Loaded functions: {}" , udfRegistry .keySet ());
594
- logger .info ("Loaded {} function definitions from {} macro sources." , udfRegistry .size (), cmd .macroSources .size ());
604
+ if (logger .isInfoEnabled ()) {
605
+ logger .info ("Loaded functions: {}" , udfRegistry .keySet ());
606
+ logger .info ("Loaded {} function definitions from {} macro sources." , udfRegistry .size (), cmd .macroSources .size ());
607
+ }
595
608
// ExprTransform eform = new ExprTransformExpand(udfRegistry);
596
609
ExprTransform eform = new ExprTransformCopy () {
597
610
@ Override
@@ -602,8 +615,6 @@ public Expr transform(ExprFunctionN func, ExprList args) {
602
615
};
603
616
SparqlStmtTransform stmtTransform = SparqlStmtTransforms .ofExprTransform (eform );
604
617
dataSourceTmp = RdfDataEngines .wrapWithStmtTransform (dataSourceTmp , stmtTransform );
605
- // QueryTransform qform = q -> QueryUtils.rewrite(q, op -> Transformer.transform(null, eform, op));
606
- // dataSourceTmp = RdfDataEngines.wrapWithQueryTransform(dataSourceTmp, qform, null);
607
618
}
608
619
609
620
RdfDataEngine datasetAndDelete = dataSourceTmp ;
@@ -848,10 +859,14 @@ public void afterExec() {
848
859
849
860
server .start ();
850
861
862
+ // Try to get the host address from a network device (e.g. within a docker container)
851
863
String hostAddress ;
852
864
try (final DatagramSocket socket = new DatagramSocket ()){
853
865
socket .connect (InetAddress .getByName ("1.1.1.1" ), 53 );
854
866
hostAddress = socket .getLocalAddress ().getHostAddress ();
867
+ } catch (Exception e ) {
868
+ // Fall back to localhost
869
+ hostAddress = "localhost" ;
855
870
}
856
871
URI browseUri = new URI ("http://" +hostAddress +":" + port + "/" );
857
872
if (Desktop .isDesktopSupported ()) {
@@ -928,6 +943,14 @@ public void afterExec() {
928
943
return exitCode ;
929
944
}
930
945
946
+ private static void loadMacros (Set <String > macroProfiles , Map <String , UserDefinedFunctionDefinition > udfRegistry ,
947
+ String macroSource ) {
948
+ Model model = RDFDataMgr .loadModel (macroSource );
949
+ SparqlStmtMgr .execSparql (model , "udf-inferences.rq" );
950
+ Map <String , UserDefinedFunctionDefinition > contrib = UserDefinedFunctions .load (model , macroProfiles );
951
+ udfRegistry .putAll (contrib );
952
+ }
953
+
931
954
/** Be careful not to call within a read transaction! */
932
955
public static void updateSpatialIndex (Dataset dataset ) {
933
956
Context cxt = dataset .getContext ();
0 commit comments