You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by Zen 98052 <z9...@outlook.com> on 2016/06/15 22:18:11 UTC
Re:
I don't think I can use UpdateFactory.create, because it expects a String arg (while my case is I want to pass an InputStream)
________________________________
From: Zen 98052
Sent: Wednesday, June 15, 2016 6:01:02 PM
To: users@jena.apache.org
Subject: Re: proper way to pass app context
Below is the Jena code that I can copy (I am doing this because UpdateAction API doesn't return the UpdateProcessor, or in this case UpdateProcessorStreaming, which what I need).
Unfortunately, UpdateFactory.setupParser is 'protected' instead of 'public'. Does it mean I have to subclass the UpdateFactory class?
Or can I simply call UpdateFactory.create? I am not sure if I need UpdateSink in my case (which is using input stream)
Thanks,
Z
public static void parseExecute(UsingList usingList, DatasetGraph dataset, InputStream input, Binding inputBinding, String baseURI, Syntax syntax)
{
GraphStore graphStore = GraphStoreFactory.create(dataset);
UpdateProcessorStreaming uProc = UpdateExecutionFactory.createStreaming(graphStore, inputBinding) ;
if (uProc == null)
throw new ARQException("No suitable update procesors are registered/able to execute your updates");
uProc.startRequest();
try
{
UpdateSink sink = new UsingUpdateSink(uProc.getUpdateSink(), usingList) ;
try
{
UpdateParser parser = UpdateFactory.setupParser(sink.getPrologue(), baseURI, syntax) ;
parser.parse(sink, input) ;
}
finally
{
sink.close() ;
}
}
finally
{
uProc.finishRequest();
}
}
________________________________
From: Andy Seaborne <an...@apache.org>
Sent: Wednesday, June 15, 2016 4:22:45 PM
To: users@jena.apache.org
Subject: Re: proper way to pass app context
On 15/06/16 13:35, Zen 98052 wrote:
> Hi Andy,
>
> I see the code parseExecute in UpdateAction, which I can copy and pass the context object.
>
> Before that, how do I get that per-request context at first place?
>
>
> For SELECT request, I am able to call QueryExecutionFactory.create to get the QueryExecution object, which has the per-request context object.
>
> I don't see there is UpdateExecution or something like that.
pass it when
UpdateExecutionFactory.
create(UpdateRequest updateRequest, Dataset dataset, Context context)
or manipulate the returned UpdateProcessor
Andy
>
>
> Once I got the per-request context object, I want to pass it to StageBuilder.setGenerator(context, ...), and QC.setFactory(context, ...)
>
>
>
> Thanks,
>
> Z
>
> ________________________________
> From: Andy Seaborne <an...@apache.org>
> Sent: Tuesday, June 14, 2016 4:44:48 AM
> To: users@jena.apache.org
> Subject: Re: proper way to pass app context
>
> On 14/06/16 01:06, Zen 98052 wrote:
>> Hi Andy,
>>
>> How to set the custom op executor for UPDATE?
>> My code for update is:
>>
>>
>> InputStream stream = new ByteArrayInputStream(postData.getBytes("UTF-8"));
>> UpdateAction.parseExecute(null, graphDataset, stream, Syntax.syntaxARQ);
>>
>>
>>
>> Thanks,
>>
>> Z
>
> The class UpdateAction is a collection of convenience operations. The
> full API is via UpdateExecutionFactory which includes
> passing in a context.
>
> Andy
>
>