dotnetrdf icon indicating copy to clipboard operation
dotnetrdf copied to clipboard

ISparqlResultsHandler Design Issue

Open jiatao99 opened this issue 2 years ago • 2 comments

In ISparqlResultsHandler.cs you guys defined a function of: bool HandleResult(ISparqlResult result);. However the parser always create a new instance of SparqlResult.

Is it possible add one more function inside ISparqlResultsHandler:

ISparqlResult CreateResult();

The parser will invoke this function to create the ISparqlResult object. In this case, if I want to create my own implementation of ISparqlResultsHandler, I can construct my own implementation of ISparqlResult object.

Thanks

Tao

jiatao99 avatar May 27 '22 18:05 jiatao99

I think it would maybe be better to allow a factory to be injected when you build the query processor rather than in the handler as generating the results is really the concern of the query processor.

I'm thinking we could add support for this by extending VDS.RDF.Query.LeviathanQueryOptions to allow a factory instance to be passed in, this would implement a simple interface with a MakeResult method on it that would be invoked with an IEnumerable<KeyValuePair<string, INode>> that provides the bindings for the result and returns a single ISparqlResult instance. Would that work for your use case?

kal avatar May 29 '22 13:05 kal

Either way is fine. Just thought extending the interface is a lot easier since the implementation class has to implement this interface anyway.

jiatao99 avatar Jun 13 '22 14:06 jiatao99