~juan457/+junk/zorba

« back to all changes in this revision

Viewing changes to src/store/naive/simple_index_general.cpp

  • Committer: Markos Zaharioudakis
  • Date: 2012-07-11 15:38:39 UTC
  • mfrom: (10924 zorba)
  • mto: This revision was merged to the branch mainline in revision 10932.
  • Revision ID: markos_za@yahoo.com-20120711153839-0mkh15cg2ubknchd
work in progress

Show diffs side-by-side

added added

removed removed

Lines of Context:
212
212
  IndexImpl(qname, spec),
213
213
  theKeyTypeCode(store::XS_LAST),
214
214
  theCompFunction(spec.theTimezone, spec.theCollations[0]),
215
 
  theUntypedFlag(false),
 
215
  theNumUntypedEntries(0),
216
216
  theNumMultiKeyNodes(0)
217
217
{
218
218
  store::Item* typeName = spec.theKeyTypes[0].getp();
385
385
    if (lossy)
386
386
    {
387
387
      node2 = node;
388
 
      found = found || insertInMap(castItem, node2, store::XS_DECIMAL, false);
 
388
      if (insertInMap(castItem, node2, store::XS_DECIMAL, false))
 
389
        found = true;
389
390
    }
390
391
 
391
392
    return found;
421
422
        node2 = node;
422
423
        found = insertInMap(key, node2, store::XS_LONG, false);
423
424
 
424
 
        found = found || insertInMap(castItem, node, store::XS_DOUBLE, false);
 
425
        if (insertInMap(castItem, node, store::XS_DOUBLE, false))
 
426
          found = true;
425
427
      }
426
428
      else
427
429
      {
469
471
      xs_long longValue = longItem->getLongValue();
470
472
 
471
473
      node2 = node;
472
 
      found = found || insertInMap(castItem, node2, store::XS_LONG, true);
 
474
      if (insertInMap(castItem, node2, store::XS_LONG, true))
 
475
        found = true;
473
476
 
474
477
      if (longValue > theMaxLong || longValue < theMinLong)
475
478
      {
487
490
        if (lossy)
488
491
        {
489
492
          node2 = node;
490
 
          found = found || insertInMap(castItem, node2, store::XS_DOUBLE, true);
 
493
          if (insertInMap(castItem, node2, store::XS_DOUBLE, true))
 
494
            found = true;
491
495
        }
492
496
      }
493
497
 
497
501
        if (untypedItem->castToGYear(castItem))
498
502
        {
499
503
          node2 = node;
500
 
          found = found || insertInMap(castItem, node2, store::XS_GYEAR, true);
 
504
          if (insertInMap(castItem, node2, store::XS_GYEAR, true))
 
505
            found = true;
501
506
        }
502
507
 
503
508
        if (untypedItem->castToHexBinary(castItem))
504
509
        {
505
510
          node2 = node;
506
 
          found = found || insertInMap(castItem, node2, store::XS_HEXBINARY, true);
 
511
          if (insertInMap(castItem, node2, store::XS_HEXBINARY, true))
 
512
            found = true;
507
513
        }
508
514
 
509
515
        if (untypedItem->castToBase64Binary(castItem))
510
516
        {
511
517
          node2 = node;
512
 
          found = found || insertInMap(castItem, node2, store::XS_BASE64BINARY, true);
 
518
          if (insertInMap(castItem, node2, store::XS_BASE64BINARY, true))
 
519
            found = true;
513
520
        }
514
521
      }
515
522
    }
523
530
      decimalItem->coerceToDouble(castItem, true, lossy);
524
531
 
525
532
      node2 = node;
526
 
      found = found || insertInMap(castItem, node2, store::XS_DOUBLE, true);
 
533
      if (insertInMap(castItem, node2, store::XS_DOUBLE, true))
 
534
        found = true;
527
535
 
528
536
      if (lossy)
529
537
      {
530
538
        castItem.transfer(decimalItem);
531
539
        node2 = node;
532
 
        found = found || insertInMap(castItem, node2, store::XS_DECIMAL, true);
 
540
        if (insertInMap(castItem, node2, store::XS_DECIMAL, true))
 
541
          found = true;
533
542
      }
534
543
 
535
544
      // may also be hexBinary or base64Binary
538
547
        if (untypedItem->castToHexBinary(castItem))
539
548
        {
540
549
          node2 = node;
541
 
          found = found || insertInMap(castItem, node2, store::XS_HEXBINARY, true);
 
550
          if (insertInMap(castItem, node2, store::XS_HEXBINARY, true))
 
551
            found = true;
542
552
        }
543
553
 
544
554
        if (untypedItem->castToBase64Binary(castItem))
545
555
        {
546
556
          node2 = node;
547
 
          found = found || insertInMap(castItem, node2, store::XS_BASE64BINARY, true);
 
557
          if (insertInMap(castItem, node2, store::XS_BASE64BINARY, true))
 
558
            found = true;
548
559
        }
549
560
      }
550
561
    }
553
564
    else if (untypedItem->castToDouble(castItem))
554
565
    {
555
566
      node2 = node;
556
 
      found = found || insertInMap(castItem, node2, store::XS_DOUBLE, true);
 
567
      if (insertInMap(castItem, node2, store::XS_DOUBLE, true))
 
568
        found = true;
557
569
    }
558
570
 
559
571
    // try casting to xs:datetime
560
572
    else if (untypedItem->castToDateTime(castItem))
561
573
    {
562
574
      node2 = node;
563
 
      found = found || insertInMap(castItem, node2, store::XS_DATETIME, true);
 
575
      if (insertInMap(castItem, node2, store::XS_DATETIME, true))
 
576
        found = true;
564
577
    }
565
578
 
566
579
    // try casting to xs:date
567
580
    else if (untypedItem->castToDate(castItem))
568
581
    {
569
582
      node2 = node;
570
 
      found = found || insertInMap(castItem, node2, store::XS_DATE, true);
 
583
      if (insertInMap(castItem, node2, store::XS_DATE, true))
 
584
        found = true;
571
585
    }
572
586
 
573
587
    // try casting to xs:time
574
588
    else if (untypedItem->castToTime(castItem))
575
589
    {
576
590
      node2 = node;
577
 
      found = found || insertInMap(castItem, node2, store::XS_TIME, true);
 
591
      if (insertInMap(castItem, node2, store::XS_TIME, true))
 
592
        found = true;
578
593
    }
579
594
 
580
595
    // try casting to xs:gYearMonth
581
596
    if (!sorted && untypedItem->castToGYearMonth(castItem))
582
597
    {
583
598
      node2 = node;
584
 
      found = found || insertInMap(castItem, node2, store::XS_GYEAR_MONTH, true);
 
599
      if (insertInMap(castItem, node2, store::XS_GYEAR_MONTH, true))
 
600
        found = true;
585
601
    }
586
602
 
587
603
    // try casting to xs:gMonthDay
588
604
    else if (!sorted && untypedItem->castToGMonthDay(castItem))
589
605
    {
590
606
      node2 = node;
591
 
      found = found || insertInMap(castItem, node2, store::XS_GMONTH_DAY, true);
 
607
      if (insertInMap(castItem, node2, store::XS_GMONTH_DAY, true))
 
608
        found = true;
592
609
    }
593
610
 
594
611
    // try casting to xs:gDay
595
612
    else if (!sorted && untypedItem->castToGDay(castItem))
596
613
    {
597
614
      node2 = node;
598
 
      found = found || insertInMap(castItem, node2, store::XS_GDAY, true);
 
615
      if (insertInMap(castItem, node2, store::XS_GDAY, true))
 
616
        found = true;
599
617
    }
600
618
 
601
619
    // try casting to xs:gMonth
602
620
    else if (!sorted && untypedItem->castToGMonth(castItem))
603
621
    {
604
622
      node2 = node;
605
 
      found = found || insertInMap(castItem, node2, store::XS_GMONTH, true);
 
623
      if (insertInMap(castItem, node2, store::XS_GMONTH, true))
 
624
        found = true;
606
625
    }
607
626
 
608
627
    // try casting to xs:duration
609
628
    else if (untypedItem->castToDuration(castItem))
610
629
    {
611
630
      node2 = node;
612
 
      found = found || insertInMap(castItem, node2, store::XS_DURATION, true);
 
631
      if (insertInMap(castItem, node2, store::XS_DURATION, true))
 
632
        found = true;
613
633
    }
614
634
 
615
635
    // try casting to xs:hexBinary
616
636
    else if (!sorted && untypedItem->castToHexBinary(castItem))
617
637
    {
618
638
      node2 = node;
619
 
      found = found || insertInMap(castItem, node2, store::XS_HEXBINARY, true);
 
639
      if (insertInMap(castItem, node2, store::XS_HEXBINARY, true))
 
640
        found = true;
620
641
    }
621
642
 
622
643
    // try casting to xs:base64Binary
623
644
    else if (!sorted && untypedItem->castToBase64Binary(castItem))
624
645
    {
625
646
      node2 = node;
626
 
      found = found || insertInMap(castItem, node2, store::XS_BASE64BINARY, true);
 
647
      if (insertInMap(castItem, node2, store::XS_BASE64BINARY, true))
 
648
        found = true;
627
649
    }
628
650
 
629
651
    return found;
649
671
    bool untyped)
650
672
{
651
673
  if (untyped)
652
 
    theUntypedFlag = true;
 
674
    ++theNumUntypedEntries;
653
675
 
654
676
  if (isSorted())
655
677
  {
780
802
 
781
803
    if (lossy)
782
804
    {
783
 
      found = found || removeFromMap(castItem, node, store::XS_DECIMAL, false);
 
805
      if (removeFromMap(castItem, node, store::XS_DECIMAL, false))
 
806
        found = true;
784
807
    }
785
808
 
786
809
    return found;
817
840
        */
818
841
        found = removeFromMap(keyItem, node, store::XS_LONG, false);
819
842
 
820
 
        found = found || removeFromMap(castItem, node, store::XS_DOUBLE, false);
 
843
        if (removeFromMap(castItem, node, store::XS_DOUBLE, false))
 
844
          found = true;
821
845
      }
822
846
      else
823
847
      {
859
883
 
860
884
      xs_long longValue = longItem->getLongValue();
861
885
 
862
 
      found = found || removeFromMap(castItem, node, store::XS_LONG, true);
 
886
      if (removeFromMap(castItem, node, store::XS_LONG, true))
 
887
        found = true;
863
888
 
864
889
      if (longValue > theMaxLong || longValue < theMinLong)
865
890
      {
876
901
 
877
902
        if (lossy)
878
903
        {
879
 
          found = found || removeFromMap(castItem, node2, store::XS_DOUBLE, true);
 
904
          if (removeFromMap(castItem, node, store::XS_DOUBLE, true))
 
905
            found = true;
880
906
        }
881
907
      }
882
908
 
885
911
      {
886
912
        if (untypedItem->castToGYear(castItem))
887
913
        {
888
 
          found = found || removeFromMap(castItem, node, store::XS_GYEAR, true);
 
914
          if (removeFromMap(castItem, node, store::XS_GYEAR, true))
 
915
            found = true;
889
916
        }
890
917
 
891
918
        if (untypedItem->castToHexBinary(castItem))
892
919
        {
893
 
          found = found || removeFromMap(castItem, node, store::XS_HEXBINARY, true);
 
920
          if (removeFromMap(castItem, node, store::XS_HEXBINARY, true))
 
921
            found = true;
894
922
        }
895
923
 
896
924
        if (untypedItem->castToBase64Binary(castItem))
897
925
        {
898
 
          found = found || removeFromMap(castItem, node, store::XS_BASE64BINARY, true);
 
926
          if (removeFromMap(castItem, node, store::XS_BASE64BINARY, true))
 
927
            found = true;
899
928
        }
900
929
      }
901
930
    }
908
937
 
909
938
      decimalItem->coerceToDouble(castItem, true, lossy);
910
939
 
911
 
      found = found || removeFromMap(castItem, node, store::XS_DOUBLE, true);
 
940
      if (removeFromMap(castItem, node, store::XS_DOUBLE, true))
 
941
        found = true;
912
942
 
913
943
      if (lossy)
914
944
      {
915
945
        castItem.transfer(decimalItem);
916
 
        found = found || removeFromMap(castItem, node, store::XS_DECIMAL, true);
 
946
        if (removeFromMap(castItem, node, store::XS_DECIMAL, true))
 
947
          found = true;
917
948
      }
918
949
 
919
950
      // may also be hexBinary or base64Binary
921
952
      {
922
953
        if (untypedItem->castToHexBinary(castItem))
923
954
        {
924
 
          found = found || removeFromMap(castItem, node, store::XS_HEXBINARY, true);
 
955
          if (removeFromMap(castItem, node, store::XS_HEXBINARY, true))
 
956
            found = true;
925
957
        }
926
958
 
927
959
        if (untypedItem->castToBase64Binary(castItem))
928
960
        {
929
 
          found = found || removeFromMap(castItem, node, store::XS_BASE64BINARY, true);
 
961
          if (removeFromMap(castItem, node, store::XS_BASE64BINARY, true))
 
962
            found = true;
930
963
        }
931
964
      }
932
965
    }
934
967
    // try casting to xs:double
935
968
    else if (untypedItem->castToDouble(castItem))
936
969
    {
937
 
      found = found || removeFromMap(castItem, node, store::XS_DOUBLE, true);
 
970
      if (removeFromMap(castItem, node, store::XS_DOUBLE, true))
 
971
        found = true;
938
972
    }
939
973
 
940
974
    // try casting to xs:datetime
941
975
    else if (untypedItem->castToDateTime(castItem))
942
976
    {
943
 
      found = found || removeFromMap(castItem, node, store::XS_DATETIME, true);
 
977
      if (removeFromMap(castItem, node, store::XS_DATETIME, true))
 
978
        found = true;
944
979
    }
945
980
 
946
981
    // try casting to xs:date
947
982
    else if (untypedItem->castToDate(castItem))
948
983
    {
949
 
      found = found || removeFromMap(castItem, node, store::XS_DATE, true);
 
984
      if (removeFromMap(castItem, node, store::XS_DATE, true))
 
985
        found = true;
950
986
    }
951
987
 
952
988
    // try casting to xs:time
953
989
    else if (untypedItem->castToTime(castItem))
954
990
    {
955
 
      found = found || removeFromMap(castItem, node, store::XS_TIME, true);
 
991
      if (removeFromMap(castItem, node, store::XS_TIME, true))
 
992
        found = true;
956
993
    }
957
994
 
958
995
    // try casting to xs:gYearMonth
959
996
    if (!sorted && untypedItem->castToGYearMonth(castItem))
960
997
    {
961
 
      found = found || removeFromMap(castItem, node, store::XS_GYEAR_MONTH, true);
 
998
      if (removeFromMap(castItem, node, store::XS_GYEAR_MONTH, true))
 
999
        found = true;
962
1000
    }
963
1001
 
964
1002
    // try casting to xs:gMonthDay
965
1003
    else if (!sorted && untypedItem->castToGMonthDay(castItem))
966
1004
    {
967
 
      found = found || removeFromMap(castItem, node, store::XS_GMONTH_DAY, true);
 
1005
      if (removeFromMap(castItem, node, store::XS_GMONTH_DAY, true))
 
1006
        found = true;
968
1007
    }
969
1008
 
970
1009
    // try casting to xs:gDay
971
1010
    else if (!sorted && untypedItem->castToGDay(castItem))
972
1011
    {
973
 
      found = found || removeFromMap(castItem, node, store::XS_GDAY, true);
 
1012
      if (removeFromMap(castItem, node, store::XS_GDAY, true))
 
1013
        found = true;
974
1014
    }
975
1015
 
976
1016
    // try casting to xs:gMonth
977
1017
    else if (!sorted && untypedItem->castToGMonth(castItem))
978
1018
    {
979
 
      found = found || removeFromMap(castItem, node, store::XS_GMONTH, true);
 
1019
      if (removeFromMap(castItem, node, store::XS_GMONTH, true))
 
1020
        found = true;
980
1021
    }
981
1022
 
982
1023
    // try casting to xs:duration
983
1024
    else if (untypedItem->castToDuration(castItem))
984
1025
    {
985
 
      found = found || removeFromMap(castItem, node, store::XS_DURATION, true);
 
1026
      if (removeFromMap(castItem, node, store::XS_DURATION, true))
 
1027
        found = true;
986
1028
    }
987
1029
 
988
1030
    // try casting to xs:hexBinary
989
1031
    else if (!sorted && untypedItem->castToHexBinary(castItem))
990
1032
    {
991
 
      found = found || removeFromMap(castItem, node, store::XS_HEXBINARY, true);
 
1033
      if (removeFromMap(castItem, node, store::XS_HEXBINARY, true))
 
1034
        found = true;
992
1035
    }
993
1036
 
994
1037
    // try casting to xs:base64Binary
995
1038
    else if (!sorted && untypedItem->castToBase64Binary(castItem))
996
1039
    {
997
 
      found = found || removeFromMap(castItem, node, store::XS_BASE64BINARY, true);
 
1040
      if (removeFromMap(castItem, node, store::XS_BASE64BINARY, true))
 
1041
        found = true;
998
1042
    }
999
1043
 
1000
1044
    return found;
1029
1073
    store::SchemaTypeCode targetMap,
1030
1074
    bool untyped)
1031
1075
{
 
1076
  if (untyped)
 
1077
    --theNumUntypedEntries;
 
1078
 
1032
1079
  if (isSorted())
1033
1080
  {
1034
1081
    GeneralTreeIndex* idx = static_cast<GeneralTreeIndex*>(this);
1577
1624
      ERROR_PARAMS(ZED(NoMultiKeyNodeValues_2), theIndex->getName()->getStringValue()));
1578
1625
    }
1579
1626
 
1580
 
    if (theIndex->theUntypedFlag)
 
1627
    if (theIndex->theNumUntypedEntries > 0)
1581
1628
    {
1582
1629
      checkStringKeyType(theCondition->theKey.getp());
1583
1630
      checkStringKeyType(theCondition->theLowerBound.getp());