11 Replies Latest reply on Dec 8, 2011 12:36 AM by 366556

    Incremental inferencing and vitual models

    366556
      Hello,

      I have 3 models where one of them in the data model were an application is adding assertions on a daily/hourly bases. I need to inference these 3 models and be able to continue query them while adding more assertions.
      I've tried creating an entailment wint INC=T and specified a delta model. And from that I created a virtual model that I use for query. However when I add assertions to the delta model it doesn't appear in the virtual model.
      Would you please provide me with a sample code how to generate a virtual inferenced model that is updated incrementally?

      Thanks.
        • 1. Re: Incremental inferencing and vitual models
          alwu-Oracle
          Hi,

          Could you please cut & paste the commands you used to run inference and create virtual model?

          Thanks,

          Zhe Wu
          • 2. Re: Incremental inferencing and vitual models
            366556
            EXECUTE sem_apis.create_entailment('owl_idx', sem_models('M1', 'M2','D1'), sem_rulebases('OWLPRIME'),sem_apis.REACH_CLOSURE, null,'INC=T DOP=4',sem_models('D2'))

            EXECUTE sem_apis.create_virtual_model('vm_owl', sem_models('M1', 'M2','D1'), sem_rulebases('OWLPRIME'));

            I could continue adding assertions to 'D2' and 'vm_owl' doesn't get corrupt but it doesn't get updated with the new assertions in 'D2'.

            Is there a way to setup the entailment or virtual model so I could add assertions into 'D2' and they'll be inference and available for query in 'vm_owl'?

            Thanks.
            • 3. Re: Incremental inferencing and vitual models
              alwu-Oracle
              Hi,

              After adding new assertions, did you run the inference command again?

              Thanks,

              Zhe Wu
              • 4. Re: Incremental inferencing and vitual models
                366556
                Hi Zhe,

                To re-run the inference command it takes about 6-7 seconds to complete. Meanwhile if another application is trying to query the virtual model (while it's re-inferencing) the following exception is thrown:

                SQLException:
                Message: ORA-20000: We do not have a valid rules index for this Model-Rulebase combination
                ORA-06512: at "MDSYS.RDF_MATCH_IMPL_T", line 816
                ORA-06512: at "MDSYS.RDF_MATCH_IMPL_T", line 235
                ORA-06512: at line 1

                SQLState: 72000

                Is there a way to "update" the entailment and once it's ready "re-point" the virtual model to it so there's no downtime for querying?

                Thanks for any suggestions.

                Edited by: arielah on Nov 30, 2011 11:55 AM
                • 5. Re: Incremental inferencing and vitual models
                  alwu-Oracle
                  Hi,

                  Does it make a difference if you set the status to be INCOMPLETE (or INVALID) according to Section 1.6.1 of the
                  following document?

                  http://docs.oracle.com/cd/E11882_01/appdev.112/e11828/sdo_rdf_concepts.htm#CIHHEDAC

                  Thanks,

                  Zhe Wu
                  • 6. Re: Incremental inferencing and vitual models
                    366556
                    Thank you that worked using the SEM_MATCH query.

                    Is there a way to pass this index_status when using the ARQ framework?

                    Thanks.
                    • 7. Re: Incremental inferencing and vitual models
                      alwu-Oracle
                      Hi,

                      Sorry for the delay. I am attending a conference.

                      If your queries are coming from a Joseki endpoint, then you don't have to do anything.

                      If you are programming using Jena APIs, you can set QueryOptions.ALLOW_QUERY_INVALID_AND_DUP when
                      creating the Attachment instance.

                      Thanks,

                      Zhe Wu
                      • 8. Re: Incremental inferencing and vitual models
                        366556
                        Hi Zhe,

                        Thank you for all this great information.

                        I was wondering if there's a way to pass this QueryOption while creating the Query in Jena. The inferecing was already generated via sem_apis package ... create entailment. Is there's a way to pass this flag at that point?

                        EXECUTE sem_apis.create_entailment('OWL_IDX',
                        sem_models('M1', 'M2','D1'), sem_rulebases('OWLPRIME'),
                        sem_apis.REACH_CLOSURE,
                        null,
                        'INC=T DOP=4 DYN_INC_INF=T RAW8=T',
                        sem_models('D2'))

                        Thanks.
                        • 9. Re: Incremental inferencing and vitual models
                          alwu-Oracle
                          Hi,

                          First, I would recommend rename the entailment to M1_RI, assuming M1 is the primary model. It is the
                          default naming convention adopted by Jena Adapter.

                          Please search for "rename_entailment" in the following document.
                          http://docs.oracle.com/cd/E18283_01/appdev.112/e11828/sem_apis_ref.htm

                          To set the query options, please see following code snippet.

                          Attachment attachment = Attachment.createInstance(
                          new String[] {"M2", "D1"}, new String[]{"OWLPRIME"},
                          InferenceMaintenanceMode.UPDATE_WHEN_COMMIT,
                          QueryOptions.ALLOW_QUERY_INVALID_AND_DUP);

                          GraphOracleSem graph = new GraphOracleSem(
                          oracle, "M1", attachment);
                          ModelOracleSem model = new ModelOracleSem(graph);

                          ...

                          Query query = QueryFactory.create("..... put your SPARQL query here ...." );
                          QueryExecution qe = QueryExecutionFactory.create(query, model);
                          com.hp.hpl.jena.query.ResultSet results = (com.hp.hpl.jena.query.ResultSet) qe.execSelect();

                          Thanks,

                          Zhe Wu
                          • 10. Re: Incremental inferencing and vitual models
                            366556
                            Thank you for all your help. This worked.
                            • 11. Re: Incremental inferencing and vitual models
                              366556
                              Using the helpful advice I was able to solve my problem.