Menu

[r12]: / trunk / libtop_engine / rule_term.h  Maximize  Restore  History

Download this file

1098 lines (950 with data), 52.1 kB

   1
   2
   3
   4
   5
   6
   7
   8
   9
  10
  11
  12
  13
  14
  15
  16
  17
  18
  19
  20
  21
  22
  23
  24
  25
  26
  27
  28
  29
  30
  31
  32
  33
  34
  35
  36
  37
  38
  39
  40
  41
  42
  43
  44
  45
  46
  47
  48
  49
  50
  51
  52
  53
  54
  55
  56
  57
  58
  59
  60
  61
  62
  63
  64
  65
  66
  67
  68
  69
  70
  71
  72
  73
  74
  75
  76
  77
  78
  79
  80
  81
  82
  83
  84
  85
  86
  87
  88
  89
  90
  91
  92
  93
  94
  95
  96
  97
  98
  99
 100
 101
 102
 103
 104
 105
 106
 107
 108
 109
 110
 111
 112
 113
 114
 115
 116
 117
 118
 119
 120
 121
 122
 123
 124
 125
 126
 127
 128
 129
 130
 131
 132
 133
 134
 135
 136
 137
 138
 139
 140
 141
 142
 143
 144
 145
 146
 147
 148
 149
 150
 151
 152
 153
 154
 155
 156
 157
 158
 159
 160
 161
 162
 163
 164
 165
 166
 167
 168
 169
 170
 171
 172
 173
 174
 175
 176
 177
 178
 179
 180
 181
 182
 183
 184
 185
 186
 187
 188
 189
 190
 191
 192
 193
 194
 195
 196
 197
 198
 199
 200
 201
 202
 203
 204
 205
 206
 207
 208
 209
 210
 211
 212
 213
 214
 215
 216
 217
 218
 219
 220
 221
 222
 223
 224
 225
 226
 227
 228
 229
 230
 231
 232
 233
 234
 235
 236
 237
 238
 239
 240
 241
 242
 243
 244
 245
 246
 247
 248
 249
 250
 251
 252
 253
 254
 255
 256
 257
 258
 259
 260
 261
 262
 263
 264
 265
 266
 267
 268
 269
 270
 271
 272
 273
 274
 275
 276
 277
 278
 279
 280
 281
 282
 283
 284
 285
 286
 287
 288
 289
 290
 291
 292
 293
 294
 295
 296
 297
 298
 299
 300
 301
 302
 303
 304
 305
 306
 307
 308
 309
 310
 311
 312
 313
 314
 315
 316
 317
 318
 319
 320
 321
 322
 323
 324
 325
 326
 327
 328
 329
 330
 331
 332
 333
 334
 335
 336
 337
 338
 339
 340
 341
 342
 343
 344
 345
 346
 347
 348
 349
 350
 351
 352
 353
 354
 355
 356
 357
 358
 359
 360
 361
 362
 363
 364
 365
 366
 367
 368
 369
 370
 371
 372
 373
 374
 375
 376
 377
 378
 379
 380
 381
 382
 383
 384
 385
 386
 387
 388
 389
 390
 391
 392
 393
 394
 395
 396
 397
 398
 399
 400
 401
 402
 403
 404
 405
 406
 407
 408
 409
 410
 411
 412
 413
 414
 415
 416
 417
 418
 419
 420
 421
 422
 423
 424
 425
 426
 427
 428
 429
 430
 431
 432
 433
 434
 435
 436
 437
 438
 439
 440
 441
 442
 443
 444
 445
 446
 447
 448
 449
 450
 451
 452
 453
 454
 455
 456
 457
 458
 459
 460
 461
 462
 463
 464
 465
 466
 467
 468
 469
 470
 471
 472
 473
 474
 475
 476
 477
 478
 479
 480
 481
 482
 483
 484
 485
 486
 487
 488
 489
 490
 491
 492
 493
 494
 495
 496
 497
 498
 499
 500
 501
 502
 503
 504
 505
 506
 507
 508
 509
 510
 511
 512
 513
 514
 515
 516
 517
 518
 519
 520
 521
 522
 523
 524
 525
 526
 527
 528
 529
 530
 531
 532
 533
 534
 535
 536
 537
 538
 539
 540
 541
 542
 543
 544
 545
 546
 547
 548
 549
 550
 551
 552
 553
 554
 555
 556
 557
 558
 559
 560
 561
 562
 563
 564
 565
 566
 567
 568
 569
 570
 571
 572
 573
 574
 575
 576
 577
 578
 579
 580
 581
 582
 583
 584
 585
 586
 587
 588
 589
 590
 591
 592
 593
 594
 595
 596
 597
 598
 599
 600
 601
 602
 603
 604
 605
 606
 607
 608
 609
 610
 611
 612
 613
 614
 615
 616
 617
 618
 619
 620
 621
 622
 623
 624
 625
 626
 627
 628
 629
 630
 631
 632
 633
 634
 635
 636
 637
 638
 639
 640
 641
 642
 643
 644
 645
 646
 647
 648
 649
 650
 651
 652
 653
 654
 655
 656
 657
 658
 659
 660
 661
 662
 663
 664
 665
 666
 667
 668
 669
 670
 671
 672
 673
 674
 675
 676
 677
 678
 679
 680
 681
 682
 683
 684
 685
 686
 687
 688
 689
 690
 691
 692
 693
 694
 695
 696
 697
 698
 699
 700
 701
 702
 703
 704
 705
 706
 707
 708
 709
 710
 711
 712
 713
 714
 715
 716
 717
 718
 719
 720
 721
 722
 723
 724
 725
 726
 727
 728
 729
 730
 731
 732
 733
 734
 735
 736
 737
 738
 739
 740
 741
 742
 743
 744
 745
 746
 747
 748
 749
 750
 751
 752
 753
 754
 755
 756
 757
 758
 759
 760
 761
 762
 763
 764
 765
 766
 767
 768
 769
 770
 771
 772
 773
 774
 775
 776
 777
 778
 779
 780
 781
 782
 783
 784
 785
 786
 787
 788
 789
 790
 791
 792
 793
 794
 795
 796
 797
 798
 799
 800
 801
 802
 803
 804
 805
 806
 807
 808
 809
 810
 811
 812
 813
 814
 815
 816
 817
 818
 819
 820
 821
 822
 823
 824
 825
 826
 827
 828
 829
 830
 831
 832
 833
 834
 835
 836
 837
 838
 839
 840
 841
 842
 843
 844
 845
 846
 847
 848
 849
 850
 851
 852
 853
 854
 855
 856
 857
 858
 859
 860
 861
 862
 863
 864
 865
 866
 867
 868
 869
 870
 871
 872
 873
 874
 875
 876
 877
 878
 879
 880
 881
 882
 883
 884
 885
 886
 887
 888
 889
 890
 891
 892
 893
 894
 895
 896
 897
 898
 899
 900
 901
 902
 903
 904
 905
 906
 907
 908
 909
 910
 911
 912
 913
 914
 915
 916
 917
 918
 919
 920
 921
 922
 923
 924
 925
 926
 927
 928
 929
 930
 931
 932
 933
 934
 935
 936
 937
 938
 939
 940
 941
 942
 943
 944
 945
 946
 947
 948
 949
 950
 951
 952
 953
 954
 955
 956
 957
 958
 959
 960
 961
 962
 963
 964
 965
 966
 967
 968
 969
 970
 971
 972
 973
 974
 975
 976
 977
 978
 979
 980
 981
 982
 983
 984
 985
 986
 987
 988
 989
 990
 991
 992
 993
 994
 995
 996
 997
 998
 999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
#ifndef RULE_TERM_H_
#define RULE_TERM_H_
#include "rdf_rule_core.h"
#include "rdf_session.h"
#include "backward_reasoner.h"
#include "rule_internal.h"
#include "rule_term_base.h"
#include "rule_expression.h"
#include "rule_session.h"
namespace rule {
namespace internal {
struct assertion_tag {};
struct negation_tag {};
//*
template<class U, class V, class W>
inline void print_triple_debug(U const& u, V const& v, W const& w, rdf::index_type const* t3, bool b)
{
std::cout << "is_match_row_internal\n";
};
inline void print_triple_debug(index_type const& u, index_type const& v, index_type const& w, rdf::index_type const* t3, bool b)
{
std::cout << "is_match_row_internal: " << rdf::triple(u, v, w) << " == " << rdf::to_string(t3) << " ? " << (b? "true":"false") << std::endl;
};
/////////////////////////////////////////////////////////////////////////////////////////
// class rule_term
//
/////////////////////////////////////////////////////////////////////////////////////////
template<class U, class V, class W, class Fu, class Fv, class Fw, class Operation=assertion_tag>
class rule_term : public rule_term_base {
public:
rule_term(Fu const& fu_, Fv const& fv_, Fw const& fw_):
rule_term_base(),
fu(fu_),
fv(fv_),
fw(fw_),
m_oper(),
m_pkg_rule_vertices_p()
{};
virtual ~rule_term(){};
unsigned int compute_rows(rule_session * rule_session_p, beta_relation::const_iterator& left_relation, beta_relation& relation)const;
unsigned int retract_rows(rule_session * rule_session_p, beta_relation::const_iterator& left_relation, beta_relation& relation)const;
unsigned int op(rule_session * rule_session_p, relation_row_map const& relation_row, U u, V v, W w, beta_relation& relation, assertion_tag)const;
unsigned int op(rule_session * rule_session_p, relation_row_map const& relation_row, rdf::index_type u, rdf::index_type v, rdf::index_type w, beta_relation& relation, negation_tag)const;
unsigned int retract_op(rule_session * rule_session_p, relation_row_map const& relation_row, U u, V v, W w, beta_relation& relation, assertion_tag)const;
unsigned int retract_op(rule_session * rule_session_p, relation_row_map const& relation_row, rdf::index_type u, rdf::index_type v, rdf::index_type w, beta_relation& relation, negation_tag)const;
inline bool is_match_row (rule_session * rule_session_p, relation_row_map const& relation_row, rdf::index_type const* triple)const{return is_match_row_internal(rule_session_p, relation_row, triple);};
inline bool can_triple_match(rdf::index_type const* t3)const{return fu.is_match_possible(t3[0]) and fv.is_match_possible(t3[1]) and fw.is_match_possible(t3[2]);};
unsigned int merge_rows(rule_session * rule_session_p, beta_relation const& left_relation, rdf::index_type const*triple, beta_relation& relation)const;
unsigned int remove_rows(rule_session * rule_session_p, beta_relation const& left_relation, rdf::index_type const*triple, beta_relation& relation)const;
rdf::index_type * get_inferred_triples(rule_session *, rdf::index_type *t3, relation_row_map const& relation_row)const;
unsigned int compute_inferred_triples(rule_session * rule_session_p, relation_row_map const& relation_row)const;
unsigned int retract_inferred_triples(rule_session * rule_session_p, relation_row_map const& relation_row)const;
inline bool is_assertion_term()const{return is_assertion_term_op(m_oper);};
inline bool is_assertion_term_op(assertion_tag)const{return true;};
inline bool is_assertion_term_op(negation_tag)const{return false;};
void register_cback(rdf::rdf_cback_mgr& manager, rdf::index_triple_cback_ptr_type const& cback)const;
void register_backward_chaining_rules(back_reasoner_mgr & mgr);
// this is called on consequent terms only by knowledge_rule, rt_p is a body term
inline bool check_for_match(rule_term_ptr_type const& rt_p)const
{
return rt_p->check_for_match(fu_name, fu.get_match_item()) and
rt_p->check_for_match(fv_name, fv.get_match_item()) and
rt_p->check_for_match(fw_name, fw.get_match_item());
};
/* Used by knowledge_rule to merge identical rule_term with existing ones in the rule_graph */
inline bool is_same_as(rule_term_ptr_type const& rt_p)const
{
bool is_same = rt_p->is_same_as(fu_name, fu) and
rt_p->is_same_as(fv_name, fv) and
rt_p->is_same_as(fw_name, fw);
if(!is_same) return false;
if(get_filter()) {
if(!rt_p->get_filter()) return false;
return get_filter()->is_same_as(rt_p->get_filter());
}
if(rt_p->get_filter()) return false;
return true;
};
// =========================================================================================
// MEMBER FUNCTIONS TO DETERMINE IF TWO TERMS ARE EQUIVALENT
// Used by bool is_same_as(rule_term_ptr_type const& rt_p)const above
// =========================================================================================
inline bool check_for_match(functor_name const f, rdf::index_type const index)const
{
if(f == fu_name) return fu.check_for_match(index);
if(f == fv_name) return fv.check_for_match(index);
if(f == fw_name) return fw.check_for_match(index);
return false;
};
inline bool check_for_match(functor_name const f, std::string const& s)const
{
if(f == fu_name) return fu.check_for_match(s);
if(f == fv_name) return fv.check_for_match(s);
if(f == fw_name) return fw.check_for_match(s);
return false;
};
inline bool check_for_match(functor_name const f, F_expression const& x)const
{
if(f == fu_name) return fu.check_for_match(x);
if(f == fv_name) return fv.check_for_match(x);
if(f == fw_name) return fw.check_for_match(x);
return false;
};
inline bool is_same_as(functor_name const f, F_cst const& x)const
{
if(f == fu_name) return fu.is_same_as(x);
if(f == fv_name) return fv.is_same_as(x);
if(f == fw_name) return fw.is_same_as(x);
return false;
};
inline bool is_same_as(functor_name const f, F_join const& x)const
{
if(f == fu_name) return fu.is_same_as(x);
if(f == fv_name) return fv.is_same_as(x);
if(f == fw_name) return fw.is_same_as(x);
return false;
};
inline bool is_same_as(functor_name const f, F_var const& x)const
{
if(f == fu_name) return fu.is_same_as(x);
if(f == fv_name) return fv.is_same_as(x);
if(f == fw_name) return fw.is_same_as(x);
return false;
};
inline bool is_same_as(functor_name const f, F_expression const& x)const
{
if(f == fu_name) return fu.is_same_as(x);
if(f == fv_name) return fv.is_same_as(x);
if(f == fw_name) return fw.is_same_as(x);
return false;
};
// ----------------------------------------------------------------------------------------
inline unsigned int
get_preferred_lookup_index()
{
if(fu.get_lookup_index() != beta_relation::NO_LOOKUP_INDEX) return fu.get_lookup_index();
if(fv.get_lookup_index() != beta_relation::NO_LOOKUP_INDEX) return fv.get_lookup_index();
if(fw.get_lookup_index() != beta_relation::NO_LOOKUP_INDEX) return fw.get_lookup_index();
return beta_relation::NO_LOOKUP_INDEX;
};
protected:
unsigned int get_triple_index(std::string const& label)const
{
if(fu.has_label(label)) return 0;
if(fv.has_label(label)) return 1;
if(fw.has_label(label)) return 2;
std::cout << "rule_term::get_triple_index: invalid label: " << label << std::endl;
throw rdf::rdf_exception(rdf::invalid_index, "rule_term::get_triple_index: invalid label");
};
virtual std::string get_triple_label(unsigned int index)const
{
if(0 == index) return fu.get_label();
if(1 == index) return fv.get_label();
if(2 == index) return fw.get_label();
std::cout << "rule_term::get_triple_label: invalid index: " << index << std::endl;
throw rdf::rdf_exception(rdf::invalid_index, "rule_term::get_triple_label: invalid index (must be 0, 1, or 2)");
};
inline
std::string get_assertion_tag(assertion_tag)const
{
return "";
};
inline
std::string get_assertion_tag(negation_tag)const
{
return "not";
};
inline
std::string to_string()const
{
std::ostringstream sout;
sout << get_assertion_tag(m_oper) << "("
<< rule::internal::to_string(fu) << " "
<< rule::internal::to_string(fv) << " "
<< rule::internal::to_string(fw) << ")";
return sout.str();
};
private:
// =========================================================================================
// MEMBER FUNCTIONS TO INVOKE BACKWARD CHAINING RULES
// =========================================================================================
inline void register_backward_chaining_rules(back_reasoner_mgr & mgr, var, var){};
inline void register_backward_chaining_rules(back_reasoner_mgr & mgr, var, index_type){};
// this rule term is of the form (_ resource ?o) - where resource is in the argument of this function
inline void register_backward_chaining_rules(back_reasoner_mgr & mgr, index_type const resource, var)
{
m_pkg_rule_vertices_p = mgr.get_root_vertices_for_p(resource);
if(!m_pkg_rule_vertices_p) {
// get all backward_chaining rules that for resource
back_reasoner_mgr::p_iterator itor;
back_reasoner_mgr::p_iterator end;
boost::tie(itor, end) = mgr.get_all_backw_for_predicate(resource);
if(itor == end) return;
pkg_rule_vertices_t temp;
temp.reserve(100);
for(; itor!=end; ++itor) temp.push_back(itor->second);
m_pkg_rule_vertices_p.reset(new pkg_rule_vertices_t());
m_pkg_rule_vertices_p->reserve(temp.size());
m_pkg_rule_vertices_p->swap(temp);
mgr.insert_rule_vertices_for_p(resource, m_pkg_rule_vertices_p);
// //*
// std::cout << "rule_term::register_backward_chaining_rules: rule_term "
// << to_string() << " creating pkg reasoner: "
// << &*m_pkg_rule_vertices_p << std::endl;
} else {
// //*
// std::cout << "rule_term::register_backward_chaining_rules: rule_term "
// << to_string() << " registering to pkg reasoner: "
// << &*m_pkg_rule_vertices_p << std::endl;
}
};
// this rule term is of the form (_ resource object) - where resource and object are in the argument of this function
inline void register_backward_chaining_rules(back_reasoner_mgr & mgr, index_type const resource, index_type const object)
{
m_pkg_rule_vertices_p = mgr.get_root_vertices_for_p(resource, object);
if(!m_pkg_rule_vertices_p) {
// get backward_chaining rules that match (_ p ?o)
back_reasoner_mgr::p_iterator p_itor;
back_reasoner_mgr::p_iterator p_end;
boost::tie(p_itor, p_end) = mgr.get_backw_for_predicate_any_object(resource);
// get backward_chaining rules that match (_ p o)
back_reasoner_mgr::po_iterator po_itor;
back_reasoner_mgr::po_iterator po_end;
boost::tie(po_itor, po_end) = mgr.get_backw_for_predicate_object(resource, object);
if(p_itor==p_end and po_itor==po_end) return;
pkg_rule_vertices_t temp;
temp.reserve(100);
for(; p_itor !=p_end; ++p_itor) temp.push_back(p_itor->second);
for(; po_itor!=po_end; ++po_itor) temp.push_back(po_itor->second);
m_pkg_rule_vertices_p.reset(new pkg_rule_vertices_t());
m_pkg_rule_vertices_p->reserve(temp.size());
m_pkg_rule_vertices_p->swap(temp);
mgr.insert_rule_vertices_for_p(resource, object, m_pkg_rule_vertices_p);
// //*
// std::cout << "rule_term::register_backward_chaining_rules: rule_term "
// << to_string() << " creating pkg reasoner: "
// << &*m_pkg_rule_vertices_p << std::endl;
} else {
// //*
// std::cout << "rule_term::register_backward_chaining_rules: rule_term "
// << to_string() << " registering to pkg reasoner: "
// << &*m_pkg_rule_vertices_p << std::endl;
}
};
inline void notify_backward_reasoner(rule_session * session_p)const
{
if(m_pkg_rule_vertices_p) session_p->schedule_reasoners(m_pkg_rule_vertices_p);
};
// ----------------------------------------------------------------------------------------
inline bool is_match_row_internal(rule_session * s, relation_row_map const& row, rdf::index_type const* t3)const
{
bool b = fu(s, row, t3[0]) and fv(s, row, t3[1]) and fw(s, row, t3[2]);
// //*
// print_triple_debug(fu(s, row), fv(s, row), fw(s, row), t3, b);
return b;
};
Fu fu;
Fv fv;
Fw fw;
Operation m_oper;
pkg_rule_vertices_ptr_t m_pkg_rule_vertices_p;
};
// see specialization cases below
template<class U, class V, class W, class Fu, class Fv, class Fw, class Operation>
unsigned int rule_term<U, V, W, Fu, Fv, Fw, Operation>::compute_rows(
rule_session * rule_session_p,
beta_relation::const_iterator& left_relation_itor,
beta_relation& relation )const
{
unsigned int count = 0;
while(!left_relation_itor.is_end())
{
relation_row_map const& relation_row = left_relation_itor.get_relation_row();
U u = fu(relation_row);
V v = fv(relation_row);
W w = fw(relation_row);
count += op(rule_session_p, relation_row, u, v, w, relation, m_oper);
left_relation_itor.next();
};
notify_backward_reasoner(rule_session_p);
return count;
};
// see specialization cases below
template<class U, class V, class W, class Fu, class Fv, class Fw, class Operation>
unsigned int rule_term<U, V, W, Fu, Fv, Fw, Operation>::retract_rows(
rule_session * rule_session_p,
beta_relation::const_iterator& left_relation_itor,
beta_relation& relation )const
{
unsigned int count = 0;
while(!left_relation_itor.is_end())
{
relation_row_map const& relation_row = left_relation_itor.get_relation_row();
U u = fu(relation_row);
V v = fv(relation_row);
W w = fw(relation_row);
count += retract_op(rule_session_p, relation_row, u, v, w, relation, m_oper);
left_relation_itor.next();
};
return count;
};
// case (u v w) where u, v, w may or may not be specified (i.e., can be var)
template<class U, class V, class W, class Fu, class Fv, class Fw, class Operation>
inline unsigned int rule_term<U, V, W, Fu, Fv, Fw, Operation>::op(
rule_session * rule_session_p,
relation_row_map const& relation_row,
U u, V v, W w,
beta_relation& relation,
assertion_tag)const
{
unsigned int count = 0;
rdf::rdf_session::index_iterator index_iter = rule_session_p->get_rdf_session().find_index(u, v, w);
while(!index_iter.is_end()) {
rdf::index_type triple[3];
index_iter.get_triple_as_array(&triple[0]);
// add a row in relation, if not duplicate and duplicates are checked
count += add_row(rule_session_p, relation_row, &triple[0], relation);
index_iter.next();
};
return count;
};
// case not(u v w) where u, v, w are specified
template<class U, class V, class W, class Fu, class Fv, class Fw, class Operation>
inline unsigned int rule_term<U, V, W, Fu, Fv, Fw, Operation>::op(
rule_session * rule_session_p,
relation_row_map const& relation_row,
rdf::index_type u, rdf::index_type v, rdf::index_type w,
beta_relation& relation,
negation_tag)const
{
unsigned int count = 0;
if(!rule_session_p->get_rdf_session().contains(u, v, w)) {
// add a row in relation
rdf::index_type triple[3] = {u, v, w};
count += add_row(rule_session_p, relation_row, &triple[0], relation);
}
return count;
};
template<class U, class V, class W, class Fu, class Fv, class Fw, class Operation>
inline unsigned int rule_term<U, V, W, Fu, Fv, Fw, Operation>::retract_op(
rule_session * rule_session_p,
relation_row_map const& relation_row,
U u, V v, W w,
beta_relation& relation,
assertion_tag)const
{
unsigned int count = 0;
rdf::rdf_session::index_iterator index_iter = rule_session_p->get_rdf_session().find_index(u, v, w);
rdf::index_type triple[3];
while(!index_iter.is_end()) {
index_iter.get_triple_as_array(&triple[0]);
count += remove_row(rule_session_p, relation_row, &triple[0], relation);
index_iter.next();
};
return count;
};
template<class U, class V, class W, class Fu, class Fv, class Fw, class Operation>
inline unsigned int rule_term<U, V, W, Fu, Fv, Fw, Operation>::retract_op(
rule_session * rule_session_p,
relation_row_map const& relation_row,
rdf::index_type u, rdf::index_type v, rdf::index_type w,
beta_relation& relation,
negation_tag)const
{
unsigned int count = 0;
if(!rule_session_p->get_rdf_session().contains(u, v, w)) {
// add a row in relation
rdf::index_type triple[3] = {u, v, w};
count += remove_row(rule_session_p, relation_row, &triple[0], relation);
};
return count;
};
template<class U, class V, class W, class Fu, class Fv, class Fw, class Operation>
inline unsigned int rule_term<U, V, W, Fu, Fv, Fw, Operation>::merge_rows(
rule_session * rule_session_p,
beta_relation const& left_relation,
rdf::index_type const* triple,
beta_relation& relation )const
{
unsigned int count = 0;
beta_relation::const_iterator left_relation_itor = left_relation.beta_relation_iterator(
fu.get_lookup_index(), fv.get_lookup_index(),
fw.get_lookup_index(), triple);
while(!left_relation_itor.is_end())
{
relation_row_map const& relation_row = left_relation_itor.get_relation_row();
if(rule_session_p->is_verbose()) {
std::cout << "...merge_rows <" << relation_row.to_string() << "|" << rdf::index_triple(triple) << "> ";
}
// add a row in relation if match
if(is_match_row_internal(rule_session_p, relation_row, triple)) {
if(rule_session_p->is_verbose()) std::cout << "yes\n";
count += add_row(rule_session_p, relation_row, triple, relation);
} else {
if(rule_session_p->is_verbose()) std::cout << "no\n";
}
left_relation_itor.next();
}
return count;
};
template<class U, class V, class W, class Fu, class Fv, class Fw, class Operation>
inline unsigned int rule_term<U, V, W, Fu, Fv, Fw, Operation>::remove_rows(
rule_session * rule_session_p,
beta_relation const& left_relation,
rdf::index_type const*triple,
beta_relation& relation )const
{
unsigned int count = 0;
beta_relation::const_iterator left_relation_itor = left_relation.beta_relation_iterator(
fu.get_lookup_index(), fv.get_lookup_index(),
fw.get_lookup_index(), triple);
while(!left_relation_itor.is_end())
{
relation_row_map const& relation_row = left_relation_itor.get_relation_row();
if(rule_session_p->is_verbose()) {
std::cout << "...remove_rows <" << relation_row.to_string() << "|" << rdf::index_triple(triple) << "> ";
}
// remove row reference in relation if match
if(is_match_row_internal(rule_session_p, relation_row, triple)) {
if(rule_session_p->is_verbose()) std::cout << "yes\n";
count += remove_row(rule_session_p, relation_row, triple, relation);
} else {
if(rule_session_p->is_verbose()) std::cout << "no\n";
}
left_relation_itor.next();
}
return count;
};
// see specialization cases below to ensure compilation
template<class U, class V, class W, class Fu, class Fv, class Fw, class Operation>
inline unsigned int rule_term<U, V, W, Fu, Fv, Fw, Operation>::compute_inferred_triples(
rule_session * rule_session_p,
relation_row_map const& relation_row)const
{
rdf::index_type u = fu(rule_session_p, relation_row);
rdf::index_type v = fv(rule_session_p, relation_row);
rdf::index_type w = fw(rule_session_p, relation_row);
if(rule_session_p->is_verbose() or rule_session_p->is_logging_rule_events()) {
if(rule_session_p->is_logging_rule_events()) {
rule_session_p->log_inferred_triple(u, v, w);
}
if(rule_session_p->is_verbose()) {
std::cout << "\n*** Inferred ";
if(rule_session_p->get_rdf_session().contains(u, v, w)) {
std::cout << "(duplicate) ";
}
std::cout << "triple from "
<< get_name()
<< ": "
<< rdf::index_triple(u, v, w)
<< ", from row "
<< relation_row.to_string(*this)
<< std::endl;
}
}
return rule_session_p->get_rdf_session().insert_inferred(u, v, w);
};
// see specialization cases below to ensure compilation
template<class U, class V, class W, class Fu, class Fv, class Fw, class Operation>
inline rdf::index_type * rule_term<U, V, W, Fu, Fv, Fw, Operation>::get_inferred_triples(
rule_session * rule_session_p,
rdf::index_type *t3,
relation_row_map const& relation_row)const
{
t3[0] = fu(rule_session_p, relation_row);
t3[1] = fv(rule_session_p, relation_row);
t3[2] = fw(rule_session_p, relation_row);
return t3;
};
// see specialization cases below to ensure compilation
template<class U, class V, class W, class Fu, class Fv, class Fw, class Operation>
inline unsigned int rule_term<U, V, W, Fu, Fv, Fw, Operation>::retract_inferred_triples(
rule_session * rule_session_p,
relation_row_map const& relation_row)const
{
rdf::index_type u = fu(rule_session_p, relation_row);
rdf::index_type v = fv(rule_session_p, relation_row);
rdf::index_type w = fw(rule_session_p, relation_row);
if(rule_session_p->is_verbose() or rule_session_p->is_logging_rule_events()) {
if(rule_session_p->is_logging_rule_events()) {
rule_session_p->log_inferred_triple(u, v, w);
}
unsigned int count = rule_session_p->get_rdf_session().get_ref_count(u, v, w);
if(rule_session_p->is_verbose()) {
std::cout << "\n*** Retract ";
if(count > 1) {
std::cout << "(reduce count to "
<< (count-1)
<< ") ";
}
std::cout << "triple from "
<< get_name()
<< ": "
<< rdf::index_triple(u, v, w)
<< ", from row "
<< relation_row.to_string(*this)
<< std::endl;
}
}
return rule_session_p->get_rdf_session().retract_inferred(u, v, w);
};
template<class U, class V, class W, class Fu, class Fv, class Fw, class Operation>
inline void rule_term<U, V, W, Fu, Fv, Fw, Operation>::register_cback(
rdf::rdf_cback_mgr& manager,
rdf::index_triple_cback_ptr_type const& cback)const
{
U u = fu.get_cback_index();
V v = fv.get_cback_index();
W w = fw.get_cback_index();
manager.register_call_back(u, v, w, cback);
};
template<class U, class V, class W, class Fu, class Fv, class Fw, class Operation>
inline void rule_term<U, V, W, Fu, Fv, Fw, Operation>::register_backward_chaining_rules(back_reasoner_mgr & mgr)
{
register_backward_chaining_rules(mgr, fv.get_cback_index(), fw.get_cback_index());
};
}; /* internal namespace */
typedef rdf::var V_;
typedef rdf::index_type I_;
typedef rdf::index_type A_;
typedef internal::F_var Fv;
typedef internal::F_join Fi;
typedef internal::F_cst Fa;
typedef internal::negation_tag Ne;
typedef internal::rule_term<V_, A_, A_, Fv, Fa, Fa> T_vaa; // A1
typedef internal::rule_term<I_, A_, A_, Fi, Fa, Fa> T_iaa; // A1
typedef internal::rule_term<A_, A_, V_, Fa, Fa, Fv> T_aav; // A2
typedef internal::rule_term<A_, A_, I_, Fa, Fa, Fi> T_aai; // A2
typedef internal::rule_term<A_, V_, A_, Fa, Fv, Fa> T_ava; // A3
typedef internal::rule_term<A_, I_, A_, Fa, Fi, Fa> T_aia; // A3
typedef internal::rule_term<V_, A_, V_, Fv, Fa, Fv> T_vav; // A4
typedef internal::rule_term<I_, A_, V_, Fi, Fa, Fv> T_iav; // A4
typedef internal::rule_term<V_, A_, I_, Fv, Fa, Fi> T_vai; // A4
typedef internal::rule_term<I_, A_, I_, Fi, Fa, Fi> T_iai; // A4
typedef internal::rule_term<A_, V_, V_, Fa, Fv, Fv> T_avv; // A5
typedef internal::rule_term<A_, I_, V_, Fa, Fi, Fv> T_aiv; // A5
typedef internal::rule_term<A_, V_, I_, Fa, Fv, Fi> T_avi; // A5
typedef internal::rule_term<A_, I_, I_, Fa, Fi, Fi> T_aii; // A5
typedef internal::rule_term<V_, V_, A_, Fv, Fv, Fa> T_vva; // A6
typedef internal::rule_term<I_, V_, A_, Fi, Fv, Fa> T_iva; // A6
typedef internal::rule_term<V_, I_, A_, Fv, Fi, Fa> T_via; // A6
typedef internal::rule_term<I_, I_, A_, Fi, Fi, Fa> T_iia; // A6
typedef internal::rule_term<V_, V_, V_, Fv, Fv, Fv> T_vvv; // A7
typedef internal::rule_term<I_, V_, V_, Fi, Fv, Fv> T_ivv; // A7
typedef internal::rule_term<V_, I_, V_, Fv, Fi, Fv> T_viv; // A7
typedef internal::rule_term<V_, V_, I_, Fv, Fv, Fi> T_vvi; // A7
typedef internal::rule_term<I_, I_, V_, Fi, Fi, Fv> T_iiv; // A7
typedef internal::rule_term<I_, V_, I_, Fi, Fv, Fi> T_ivi; // A7
typedef internal::rule_term<V_, I_, I_, Fv, Fi, Fi> T_vii; // A7
typedef internal::rule_term<I_, I_, I_, Fi, Fi, Fi> T_iii; // A7
typedef internal::rule_term<I_, A_, A_, Fi, Fa, Fa, Ne> Not_T_iaa; // A1
typedef internal::rule_term<A_, A_, I_, Fa, Fa, Fi, Ne> Not_T_aai; // A2
typedef internal::rule_term<A_, I_, A_, Fa, Fi, Fa, Ne> Not_T_aia; // A3
typedef internal::rule_term<I_, A_, I_, Fi, Fa, Fi, Ne> Not_T_iai; // A4
typedef internal::rule_term<A_, I_, I_, Fa, Fi, Fi, Ne> Not_T_aii; // A5
typedef internal::rule_term<I_, I_, A_, Fi, Fi, Fa, Ne> Not_T_iia; // A6
typedef internal::rule_term<I_, I_, I_, Fi, Fi, Fi, Ne> Not_T_iii; // A7
// ADDITIONAL RULE TERMS FOR CASE WHERE EXPRESSION IS USED FOR CALCULATING OBJECT IN CONSEQUENT TERMS
typedef rdf::index_type X_;
typedef internal::F_expression Fx;
typedef internal::rule_term<A_, A_, X_, Fa, Fa, Fx> T_aax; // A2
typedef internal::rule_term<A_, I_, X_, Fa, Fi, Fx> T_aix; // A3
typedef internal::rule_term<I_, A_, X_, Fi, Fa, Fx> T_iax; // A4
typedef internal::rule_term<I_, I_, X_, Fi, Fi, Fx> T_iix; // A7
namespace internal {
inline index_type
F_expression::operator()(rule_session * s, relation_row_map const& row)const
{
using boost::lexical_cast;
expression_data const l = (*m_expression_p)(s, row);
switch(l.get_type())
{
case unset: return s->get_rdf_session().create_literal_as_index("", rdf::internal::no_value()); //* should that be an exception?
case integer: return s->get_rdf_session().create_int_literal_as_index(l.get_int());
case unsigned_integer: return s->get_rdf_session().create_uint_literal_as_index(l.get_uint());
case real: return s->get_rdf_session().create_real_literal_as_index(l.get_real());
case date: return s->get_rdf_session().create_date_literal_as_index(l.get_date());
case time: return s->get_rdf_session().create_time_literal_as_index(l.get_time());
case duration: return s->get_rdf_session().create_duration_literal_as_index(l.get_duration());
case string: return s->get_rdf_session().create_string_literal_as_index(l.get_string());
default: return l.get_index();
};
};
// Specialization since these added expressions are used in consequent terms only and these methods are never called
template<>inline unsigned int T_aax::retract_op(rule_session *, relation_row_map const&, A_, A_, X_, beta_relation&, assertion_tag)const{return 0;};
template<>inline unsigned int T_aix::retract_op(rule_session *, relation_row_map const&, A_, I_, X_, beta_relation&, assertion_tag)const{return 0;};
template<>inline unsigned int T_iax::retract_op(rule_session *, relation_row_map const&, I_, A_, X_, beta_relation&, assertion_tag)const{return 0;};
template<>inline unsigned int T_iix::retract_op(rule_session *, relation_row_map const&, I_, I_, X_, beta_relation&, assertion_tag)const{return 0;};
template<>inline unsigned int T_aax::op(rule_session *, relation_row_map const&, A_, A_, X_, beta_relation&, assertion_tag)const{return 0;};
template<>inline unsigned int T_aix::op(rule_session *, relation_row_map const&, A_, I_, X_, beta_relation&, assertion_tag)const{return 0;};
template<>inline unsigned int T_iax::op(rule_session *, relation_row_map const&, I_, A_, X_, beta_relation&, assertion_tag)const{return 0;};
template<>inline unsigned int T_iix::op(rule_session *, relation_row_map const&, I_, I_, X_, beta_relation&, assertion_tag)const{return 0;};
template<>inline void T_aax::register_cback(rdf::rdf_cback_mgr&, rdf::index_triple_cback_ptr_type const&)const{};
template<>inline void T_aix::register_cback(rdf::rdf_cback_mgr&, rdf::index_triple_cback_ptr_type const&)const{};
template<>inline void T_iax::register_cback(rdf::rdf_cback_mgr&, rdf::index_triple_cback_ptr_type const&)const{};
template<>inline void T_iix::register_cback(rdf::rdf_cback_mgr&, rdf::index_triple_cback_ptr_type const&)const{};
// 7 specializations, cases where the find_index cannot be called since there is no variable, must use contains resource on rule_session_p->get_rdf_session()
template<>inline unsigned int T_iaa::op(rule_session * rule_session_p, relation_row_map const& relation_row, I_ u, A_ v, A_ w, beta_relation& relation, assertion_tag)const
{
unsigned int count = 0;
if(rule_session_p->get_rdf_session().contains(u, v, w)) {
rdf::index_type triple[3] = {u, v, w}; count += add_row(rule_session_p, relation_row, &triple[0], relation);
}
return count;
};
template<>inline unsigned int T_aai::op(rule_session * rule_session_p, relation_row_map const& relation_row, A_ u, A_ v, I_ w, beta_relation& relation, assertion_tag)const
{
unsigned int count = 0;
if(rule_session_p->get_rdf_session().contains(u, v, w)) {
rdf::index_type triple[3] = {u, v, w}; count += add_row(rule_session_p, relation_row, &triple[0], relation);
}
return count;
};
template<>inline unsigned int T_aia::op(rule_session * rule_session_p, relation_row_map const& relation_row, A_ u, I_ v, A_ w, beta_relation& relation, assertion_tag)const
{
unsigned int count = 0;
if(rule_session_p->get_rdf_session().contains(u, v, w)) {
rdf::index_type triple[3] = {u, v, w}; count += add_row(rule_session_p, relation_row, &triple[0], relation);
}
return count;
};
template<>inline unsigned int T_iai::op(rule_session * rule_session_p, relation_row_map const& relation_row, I_ u, A_ v, I_ w, beta_relation& relation, assertion_tag)const
{
unsigned int count = 0;
if(rule_session_p->get_rdf_session().contains(u, v, w)) {
rdf::index_type triple[3] = {u, v, w}; count += add_row(rule_session_p, relation_row, &triple[0], relation);
}
return count;
};
template<>inline unsigned int T_aii::op(rule_session * rule_session_p, relation_row_map const& relation_row, A_ u, I_ v, I_ w, beta_relation& relation, assertion_tag)const
{
unsigned int count = 0;
if(rule_session_p->get_rdf_session().contains(u, v, w)) {
rdf::index_type triple[3] = {u, v, w}; count += add_row(rule_session_p, relation_row, &triple[0], relation);
}
return count;
};
template<>inline unsigned int T_iia::op(rule_session * rule_session_p, relation_row_map const& relation_row, I_ u, I_ v, A_ w, beta_relation& relation, assertion_tag)const
{
unsigned int count = 0;
if(rule_session_p->get_rdf_session().contains(u, v, w)) {
rdf::index_type triple[3] = {u, v, w}; count += add_row(rule_session_p, relation_row, &triple[0], relation);
}
return count;
};
template<>inline unsigned int T_iii::op(rule_session * rule_session_p, relation_row_map const& relation_row, I_ u, I_ v, I_ w, beta_relation& relation, assertion_tag)const
{
unsigned int count = 0;
if(rule_session_p->get_rdf_session().contains(u, v, w)) {
rdf::index_type triple[3] = {u, v, w}; count += add_row(rule_session_p, relation_row, &triple[0], relation);
}
return count;
};
// 7 specializations, cases where the find_index cannot be called since there is no variable, must use contains resource on rule_session_p->get_rdf_session()
template<>inline unsigned int T_iaa::retract_op(rule_session * rule_session_p, relation_row_map const& relation_row, I_ u, A_ v, A_ w, beta_relation& relation, assertion_tag)const
{
unsigned int count = 0;
if(rule_session_p->get_rdf_session().contains(u, v, w)) {
rdf::index_type triple[3] = {u, v, w}; count += remove_row(rule_session_p, relation_row, &triple[0], relation);
};
return count;
};
template<>inline unsigned int T_aai::retract_op(rule_session * rule_session_p, relation_row_map const& relation_row, A_ u, A_ v, I_ w, beta_relation& relation, assertion_tag)const
{
unsigned int count = 0;
if(rule_session_p->get_rdf_session().contains(u, v, w)) {
rdf::index_type triple[3] = {u, v, w}; count += remove_row(rule_session_p, relation_row, &triple[0], relation);
};
return count;
};
template<>inline unsigned int T_aia::retract_op(rule_session * rule_session_p, relation_row_map const& relation_row, A_ u, I_ v, A_ w, beta_relation& relation, assertion_tag)const
{
unsigned int count = 0;
if(rule_session_p->get_rdf_session().contains(u, v, w)) {
rdf::index_type triple[3] = {u, v, w}; count += remove_row(rule_session_p, relation_row, &triple[0], relation);
};
return count;
};
template<>inline unsigned int T_iai::retract_op(rule_session * rule_session_p, relation_row_map const& relation_row, I_ u, A_ v, I_ w, beta_relation& relation, assertion_tag)const
{
unsigned int count = 0;
if(rule_session_p->get_rdf_session().contains(u, v, w)) {
rdf::index_type triple[3] = {u, v, w}; count += remove_row(rule_session_p, relation_row, &triple[0], relation);
};
return count;
};
template<>inline unsigned int T_aii::retract_op(rule_session * rule_session_p, relation_row_map const& relation_row, A_ u, I_ v, I_ w, beta_relation& relation, assertion_tag)const
{
unsigned int count = 0;
if(rule_session_p->get_rdf_session().contains(u, v, w)) {
rdf::index_type triple[3] = {u, v, w}; count += remove_row(rule_session_p, relation_row, &triple[0], relation);
};
return count;
};
template<>inline unsigned int T_iia::retract_op(rule_session * rule_session_p, relation_row_map const& relation_row, I_ u, I_ v, A_ w, beta_relation& relation, assertion_tag)const
{
unsigned int count = 0;
if(rule_session_p->get_rdf_session().contains(u, v, w)) {
rdf::index_type triple[3] = {u, v, w}; count += remove_row(rule_session_p, relation_row, &triple[0], relation);
};
return count;
};
template<>inline unsigned int T_iii::retract_op(rule_session * rule_session_p, relation_row_map const& relation_row, I_ u, I_ v, I_ w, beta_relation& relation, assertion_tag)const
{
unsigned int count = 0;
if(rule_session_p->get_rdf_session().contains(u, v, w)) {
rdf::index_type triple[3] = {u, v, w}; count += remove_row(rule_session_p, relation_row, &triple[0], relation);
};
return count;
};
// specialization cases -- rule term with variable (var) cannot be used in consequent
template<>inline unsigned int T_vaa::compute_inferred_triples(rule_session *, relation_row_map const&)const{return 0;};
template<>inline unsigned int T_aav::compute_inferred_triples(rule_session *, relation_row_map const&)const{return 0;};
template<>inline unsigned int T_ava::compute_inferred_triples(rule_session *, relation_row_map const&)const{return 0;};
template<>inline unsigned int T_vav::compute_inferred_triples(rule_session *, relation_row_map const&)const{return 0;};
template<>inline unsigned int T_iav::compute_inferred_triples(rule_session *, relation_row_map const&)const{return 0;};
template<>inline unsigned int T_vai::compute_inferred_triples(rule_session *, relation_row_map const&)const{return 0;};
template<>inline unsigned int T_avv::compute_inferred_triples(rule_session *, relation_row_map const&)const{return 0;};
template<>inline unsigned int T_aiv::compute_inferred_triples(rule_session *, relation_row_map const&)const{return 0;};
template<>inline unsigned int T_avi::compute_inferred_triples(rule_session *, relation_row_map const&)const{return 0;};
template<>inline unsigned int T_vva::compute_inferred_triples(rule_session *, relation_row_map const&)const{return 0;};
template<>inline unsigned int T_iva::compute_inferred_triples(rule_session *, relation_row_map const&)const{return 0;};
template<>inline unsigned int T_via::compute_inferred_triples(rule_session *, relation_row_map const&)const{return 0;};
template<>inline unsigned int T_vvv::compute_inferred_triples(rule_session *, relation_row_map const&)const{return 0;};
template<>inline unsigned int T_ivv::compute_inferred_triples(rule_session *, relation_row_map const&)const{return 0;};
template<>inline unsigned int T_viv::compute_inferred_triples(rule_session *, relation_row_map const&)const{return 0;};
template<>inline unsigned int T_vvi::compute_inferred_triples(rule_session *, relation_row_map const&)const{return 0;};
template<>inline unsigned int T_iiv::compute_inferred_triples(rule_session *, relation_row_map const&)const{return 0;};
template<>inline unsigned int T_ivi::compute_inferred_triples(rule_session *, relation_row_map const&)const{return 0;};
template<>inline unsigned int T_vii::compute_inferred_triples(rule_session *, relation_row_map const&)const{return 0;};
// specialization cases -- rule term with variable (var) cannot be used in consequent
template<>inline rdf::index_type * T_vaa::get_inferred_triples(rule_session *, rdf::index_type *t3, relation_row_map const&)const{t3[0]=0; t3[1]=0; t3[2]=0; return t3;};
template<>inline rdf::index_type * T_aav::get_inferred_triples(rule_session *, rdf::index_type *t3, relation_row_map const&)const{t3[0]=0; t3[1]=0; t3[2]=0; return t3;};
template<>inline rdf::index_type * T_ava::get_inferred_triples(rule_session *, rdf::index_type *t3, relation_row_map const&)const{t3[0]=0; t3[1]=0; t3[2]=0; return t3;};
template<>inline rdf::index_type * T_vav::get_inferred_triples(rule_session *, rdf::index_type *t3, relation_row_map const&)const{t3[0]=0; t3[1]=0; t3[2]=0; return t3;};
template<>inline rdf::index_type * T_iav::get_inferred_triples(rule_session *, rdf::index_type *t3, relation_row_map const&)const{t3[0]=0; t3[1]=0; t3[2]=0; return t3;};
template<>inline rdf::index_type * T_vai::get_inferred_triples(rule_session *, rdf::index_type *t3, relation_row_map const&)const{t3[0]=0; t3[1]=0; t3[2]=0; return t3;};
template<>inline rdf::index_type * T_avv::get_inferred_triples(rule_session *, rdf::index_type *t3, relation_row_map const&)const{t3[0]=0; t3[1]=0; t3[2]=0; return t3;};
template<>inline rdf::index_type * T_aiv::get_inferred_triples(rule_session *, rdf::index_type *t3, relation_row_map const&)const{t3[0]=0; t3[1]=0; t3[2]=0; return t3;};
template<>inline rdf::index_type * T_avi::get_inferred_triples(rule_session *, rdf::index_type *t3, relation_row_map const&)const{t3[0]=0; t3[1]=0; t3[2]=0; return t3;};
template<>inline rdf::index_type * T_vva::get_inferred_triples(rule_session *, rdf::index_type *t3, relation_row_map const&)const{t3[0]=0; t3[1]=0; t3[2]=0; return t3;};
template<>inline rdf::index_type * T_iva::get_inferred_triples(rule_session *, rdf::index_type *t3, relation_row_map const&)const{t3[0]=0; t3[1]=0; t3[2]=0; return t3;};
template<>inline rdf::index_type * T_via::get_inferred_triples(rule_session *, rdf::index_type *t3, relation_row_map const&)const{t3[0]=0; t3[1]=0; t3[2]=0; return t3;};
template<>inline rdf::index_type * T_vvv::get_inferred_triples(rule_session *, rdf::index_type *t3, relation_row_map const&)const{t3[0]=0; t3[1]=0; t3[2]=0; return t3;};
template<>inline rdf::index_type * T_ivv::get_inferred_triples(rule_session *, rdf::index_type *t3, relation_row_map const&)const{t3[0]=0; t3[1]=0; t3[2]=0; return t3;};
template<>inline rdf::index_type * T_viv::get_inferred_triples(rule_session *, rdf::index_type *t3, relation_row_map const&)const{t3[0]=0; t3[1]=0; t3[2]=0; return t3;};
template<>inline rdf::index_type * T_vvi::get_inferred_triples(rule_session *, rdf::index_type *t3, relation_row_map const&)const{t3[0]=0; t3[1]=0; t3[2]=0; return t3;};
template<>inline rdf::index_type * T_iiv::get_inferred_triples(rule_session *, rdf::index_type *t3, relation_row_map const&)const{t3[0]=0; t3[1]=0; t3[2]=0; return t3;};
template<>inline rdf::index_type * T_ivi::get_inferred_triples(rule_session *, rdf::index_type *t3, relation_row_map const&)const{t3[0]=0; t3[1]=0; t3[2]=0; return t3;};
template<>inline rdf::index_type * T_vii::get_inferred_triples(rule_session *, rdf::index_type *t3, relation_row_map const&)const{t3[0]=0; t3[1]=0; t3[2]=0; return t3;};
// specialization cases -- rule term with variable (var) cannot be used in consequent
template<>inline bool T_vaa::can_triple_match(rdf::index_type const*)const{return false;};
template<>inline bool T_aav::can_triple_match(rdf::index_type const*)const{return false;};
template<>inline bool T_ava::can_triple_match(rdf::index_type const*)const{return false;};
template<>inline bool T_vav::can_triple_match(rdf::index_type const*)const{return false;};
template<>inline bool T_iav::can_triple_match(rdf::index_type const*)const{return false;};
template<>inline bool T_vai::can_triple_match(rdf::index_type const*)const{return false;};
template<>inline bool T_avv::can_triple_match(rdf::index_type const*)const{return false;};
template<>inline bool T_aiv::can_triple_match(rdf::index_type const*)const{return false;};
template<>inline bool T_avi::can_triple_match(rdf::index_type const*)const{return false;};
template<>inline bool T_vva::can_triple_match(rdf::index_type const*)const{return false;};
template<>inline bool T_iva::can_triple_match(rdf::index_type const*)const{return false;};
template<>inline bool T_via::can_triple_match(rdf::index_type const*)const{return false;};
template<>inline bool T_vvv::can_triple_match(rdf::index_type const*)const{return false;};
template<>inline bool T_ivv::can_triple_match(rdf::index_type const*)const{return false;};
template<>inline bool T_viv::can_triple_match(rdf::index_type const*)const{return false;};
template<>inline bool T_vvi::can_triple_match(rdf::index_type const*)const{return false;};
template<>inline bool T_iiv::can_triple_match(rdf::index_type const*)const{return false;};
template<>inline bool T_ivi::can_triple_match(rdf::index_type const*)const{return false;};
template<>inline bool T_vii::can_triple_match(rdf::index_type const*)const{return false;};
// specialization cases -- rule term with variable (var) cannot be used in consequent
template<>inline unsigned int T_vaa::retract_inferred_triples(rule_session *, relation_row_map const&)const{return 0;};
template<>inline unsigned int T_aav::retract_inferred_triples(rule_session *, relation_row_map const&)const{return 0;};
template<>inline unsigned int T_ava::retract_inferred_triples(rule_session *, relation_row_map const&)const{return 0;};
template<>inline unsigned int T_vav::retract_inferred_triples(rule_session *, relation_row_map const&)const{return 0;};
template<>inline unsigned int T_iav::retract_inferred_triples(rule_session *, relation_row_map const&)const{return 0;};
template<>inline unsigned int T_vai::retract_inferred_triples(rule_session *, relation_row_map const&)const{return 0;};
template<>inline unsigned int T_avv::retract_inferred_triples(rule_session *, relation_row_map const&)const{return 0;};
template<>inline unsigned int T_aiv::retract_inferred_triples(rule_session *, relation_row_map const&)const{return 0;};
template<>inline unsigned int T_avi::retract_inferred_triples(rule_session *, relation_row_map const&)const{return 0;};
template<>inline unsigned int T_vva::retract_inferred_triples(rule_session *, relation_row_map const&)const{return 0;};
template<>inline unsigned int T_iva::retract_inferred_triples(rule_session *, relation_row_map const&)const{return 0;};
template<>inline unsigned int T_via::retract_inferred_triples(rule_session *, relation_row_map const&)const{return 0;};
template<>inline unsigned int T_vvv::retract_inferred_triples(rule_session *, relation_row_map const&)const{return 0;};
template<>inline unsigned int T_ivv::retract_inferred_triples(rule_session *, relation_row_map const&)const{return 0;};
template<>inline unsigned int T_viv::retract_inferred_triples(rule_session *, relation_row_map const&)const{return 0;};
template<>inline unsigned int T_vvi::retract_inferred_triples(rule_session *, relation_row_map const&)const{return 0;};
template<>inline unsigned int T_iiv::retract_inferred_triples(rule_session *, relation_row_map const&)const{return 0;};
template<>inline unsigned int T_ivi::retract_inferred_triples(rule_session *, relation_row_map const&)const{return 0;};
template<>inline unsigned int T_vii::retract_inferred_triples(rule_session *, relation_row_map const&)const{return 0;};
// specializations, cases where the I_ must be variable
template<>inline void T_iaa::register_cback(rdf::rdf_cback_mgr& manager, rdf::index_triple_cback_ptr_type const& cback)const{
V_ u = fu.get_cback_index();
A_ v = fv.get_cback_index();
A_ w = fw.get_cback_index();
manager.register_call_back(u, v, w, cback);
};
template<>inline void T_aai::register_cback(rdf::rdf_cback_mgr& manager, rdf::index_triple_cback_ptr_type const& cback)const{
A_ u = fu.get_cback_index();
A_ v = fv.get_cback_index();
V_ w = fw.get_cback_index();
manager.register_call_back(u, v, w, cback);
};
template<>inline void T_aia::register_cback(rdf::rdf_cback_mgr& manager, rdf::index_triple_cback_ptr_type const& cback)const{
A_ u = fu.get_cback_index();
V_ v = fv.get_cback_index();
A_ w = fw.get_cback_index();
manager.register_call_back(u, v, w, cback);
};
template<>inline void T_iav::register_cback(rdf::rdf_cback_mgr& manager, rdf::index_triple_cback_ptr_type const& cback)const{
V_ u = fu.get_cback_index();
A_ v = fv.get_cback_index();
V_ w = fw.get_cback_index();
manager.register_call_back(u, v, w, cback);
};
template<>inline void T_vai::register_cback(rdf::rdf_cback_mgr& manager, rdf::index_triple_cback_ptr_type const& cback)const{
V_ u = fu.get_cback_index();
A_ v = fv.get_cback_index();
V_ w = fw.get_cback_index();
manager.register_call_back(u, v, w, cback);
};
template<>inline void T_iai::register_cback(rdf::rdf_cback_mgr& manager, rdf::index_triple_cback_ptr_type const& cback)const{
V_ u = fu.get_cback_index();
A_ v = fv.get_cback_index();
V_ w = fw.get_cback_index();
manager.register_call_back(u, v, w, cback);
};
template<>inline void T_aiv::register_cback(rdf::rdf_cback_mgr& manager, rdf::index_triple_cback_ptr_type const& cback)const{
A_ u = fu.get_cback_index();
V_ v = fv.get_cback_index();
V_ w = fw.get_cback_index();
manager.register_call_back(u, v, w, cback);
};
template<>inline void T_avi::register_cback(rdf::rdf_cback_mgr& manager, rdf::index_triple_cback_ptr_type const& cback)const{
A_ u = fu.get_cback_index();
V_ v = fv.get_cback_index();
V_ w = fw.get_cback_index();
manager.register_call_back(u, v, w, cback);
};
template<>inline void T_aii::register_cback(rdf::rdf_cback_mgr& manager, rdf::index_triple_cback_ptr_type const& cback)const{
A_ u = fu.get_cback_index();
V_ v = fv.get_cback_index();
V_ w = fw.get_cback_index();
manager.register_call_back(u, v, w, cback);
};
template<>inline void T_iva::register_cback(rdf::rdf_cback_mgr& manager, rdf::index_triple_cback_ptr_type const& cback)const{
V_ u = fu.get_cback_index();
V_ v = fv.get_cback_index();
A_ w = fw.get_cback_index();
manager.register_call_back(u, v, w, cback);
};
template<>inline void T_via::register_cback(rdf::rdf_cback_mgr& manager, rdf::index_triple_cback_ptr_type const& cback)const{
V_ u = fu.get_cback_index();
V_ v = fv.get_cback_index();
A_ w = fw.get_cback_index();
manager.register_call_back(u, v, w, cback);
};
template<>inline void T_iia::register_cback(rdf::rdf_cback_mgr& manager, rdf::index_triple_cback_ptr_type const& cback)const{
V_ u = fu.get_cback_index();
V_ v = fv.get_cback_index();
A_ w = fw.get_cback_index();
manager.register_call_back(u, v, w, cback);
};
template<>inline void T_ivv::register_cback(rdf::rdf_cback_mgr& manager, rdf::index_triple_cback_ptr_type const& cback)const{
V_ u = fu.get_cback_index();
V_ v = fv.get_cback_index();
V_ w = fw.get_cback_index();
manager.register_call_back(u, v, w, cback);
};
template<>inline void T_viv::register_cback(rdf::rdf_cback_mgr& manager, rdf::index_triple_cback_ptr_type const& cback)const{
V_ u = fu.get_cback_index();
V_ v = fv.get_cback_index();
V_ w = fw.get_cback_index();
manager.register_call_back(u, v, w, cback);
};
template<>inline void T_vvi::register_cback(rdf::rdf_cback_mgr& manager, rdf::index_triple_cback_ptr_type const& cback)const{
V_ u = fu.get_cback_index();
V_ v = fv.get_cback_index();
V_ w = fw.get_cback_index();
manager.register_call_back(u, v, w, cback);
};
template<>inline void T_iiv::register_cback(rdf::rdf_cback_mgr& manager, rdf::index_triple_cback_ptr_type const& cback)const{
V_ u = fu.get_cback_index();
V_ v = fv.get_cback_index();
V_ w = fw.get_cback_index();
manager.register_call_back(u, v, w, cback);
};
template<>inline void T_ivi::register_cback(rdf::rdf_cback_mgr& manager, rdf::index_triple_cback_ptr_type const& cback)const{
V_ u = fu.get_cback_index();
V_ v = fv.get_cback_index();
V_ w = fw.get_cback_index();
manager.register_call_back(u, v, w, cback);
};
template<>inline void T_vii::register_cback(rdf::rdf_cback_mgr& manager, rdf::index_triple_cback_ptr_type const& cback)const{
V_ u = fu.get_cback_index();
V_ v = fv.get_cback_index();
V_ w = fw.get_cback_index();
manager.register_call_back(u, v, w, cback);
};
template<>inline void T_iii::register_cback(rdf::rdf_cback_mgr& manager, rdf::index_triple_cback_ptr_type const& cback)const{
V_ u = fu.get_cback_index();
V_ v = fv.get_cback_index();
V_ w = fw.get_cback_index();
manager.register_call_back(u, v, w, cback);
};
template<>inline void Not_T_iaa::register_cback(rdf::rdf_cback_mgr& manager, rdf::index_triple_cback_ptr_type const& cback)const{
V_ u = fu.get_cback_index();
A_ v = fv.get_cback_index();
A_ w = fw.get_cback_index();
manager.register_call_back(u, v, w, cback);
};
template<>inline void Not_T_aai::register_cback(rdf::rdf_cback_mgr& manager, rdf::index_triple_cback_ptr_type const& cback)const{
A_ u = fu.get_cback_index();
A_ v = fv.get_cback_index();
V_ w = fw.get_cback_index();
manager.register_call_back(u, v, w, cback);
};
template<>inline void Not_T_aia::register_cback(rdf::rdf_cback_mgr& manager, rdf::index_triple_cback_ptr_type const& cback)const{
A_ u = fu.get_cback_index();
V_ v = fv.get_cback_index();
A_ w = fw.get_cback_index();
manager.register_call_back(u, v, w, cback);
};
template<>inline void Not_T_iai::register_cback(rdf::rdf_cback_mgr& manager, rdf::index_triple_cback_ptr_type const& cback)const{
V_ u = fu.get_cback_index();
A_ v = fv.get_cback_index();
V_ w = fw.get_cback_index();
manager.register_call_back(u, v, w, cback);
};
template<>inline void Not_T_aii::register_cback(rdf::rdf_cback_mgr& manager, rdf::index_triple_cback_ptr_type const& cback)const{
A_ u = fu.get_cback_index();
V_ v = fv.get_cback_index();
V_ w = fw.get_cback_index();
manager.register_call_back(u, v, w, cback);
};
template<>inline void Not_T_iia::register_cback(rdf::rdf_cback_mgr& manager, rdf::index_triple_cback_ptr_type const& cback)const{
V_ u = fu.get_cback_index();
V_ v = fv.get_cback_index();
A_ w = fw.get_cback_index();
manager.register_call_back(u, v, w, cback);
};
template<>inline void Not_T_iii::register_cback(rdf::rdf_cback_mgr& manager, rdf::index_triple_cback_ptr_type const& cback)const{
V_ u = fu.get_cback_index();
V_ v = fv.get_cback_index();
V_ w = fw.get_cback_index();
manager.register_call_back(u, v, w, cback);
};
}; /* internal namespace */
}; /* rule namespace */
#endif /*RULE_TERM_H_*/
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.