Changeset 1279 for fmts


Ignore:
Timestamp:
Nov 6, 2011, 1:29:56 AM (13 years ago)
Author:
George Lilly
Message:

version with BULKLOAD

File:
1 edited

Legend:

Unmodified
Added
Removed
  • fmts/trunk/p/C0XF2N.m

    r1277 r1279  
    3737 S @ZFARY@("C0XTN")=$NA(^C0X(101)) ; TRIPLES GLOBAL NAME
    3838 S @ZFARY@("C0XSN")=$NA(^C0X(201)) ; STRING FILE GLOBAL NAME
    39  S @ZFARY@("C0XDIR")="/home/glilly/rdf/"
     39 S @ZFARY@("C0XDIR")="/home/glilly/fmts/trunk/samples/qds/"
     40 S @ZFARY@("BLKLOAD")=1 ; this file supports block load
     41 S @ZFARY@("FMTSSTYLE")="F2N" ; fileman style
    4042 D USEFARY(ZFARY)
    4143 Q
     
    407409 . W !," APPROXIMATELY ",$P(C0XCNT/C0XDIFF,".")," TRIPLES PER SECOND"
    408410 W !,"INSERTING ",C0XCNT," TRIPLES"
    409  I $D(C0XFDA) D UPDIE(.C0XFDA) ; commit the updates to the file
     411 I $D(C0XFDA) D  ;
     412 . I $G(BLKLOAD) D  ;
     413 . . D BULKLOAD(.C0XFDA)
     414 . E  D  ;
     415 . . D UPDIE(.C0XFDA) ; commit the updates to the file
    410416 ; next, mark the graph as finished
    411417 S C0XINS=$$NOW^XLFDT ; PARSE COMPLETE
     
    486492 S BATCNT=BATCNT+1
    487493 S C0XCNT=C0XCNT+1
    488  S C0XFDA(C0XTFN,"?+"_BATCNT_",",.01)=ZNODE
    489  S C0XFDA(C0XTFN,"?+"_BATCNT_",",.02)=$O(ZIENS("IEN","ZG",""))
    490  S C0XFDA(C0XTFN,"?+"_BATCNT_",",.03)=$O(ZIENS("IEN","ZS",""))
    491  S C0XFDA(C0XTFN,"?+"_BATCNT_",",.04)=$O(ZIENS("IEN","ZP",""))
    492  S C0XFDA(C0XTFN,"?+"_BATCNT_",",.05)=$O(ZIENS("IEN","ZO",""))
     494 I $G(BLKLOAD)=1 D  ; we are using bulk load
     495 . S C0XFDA(C0XTFN,BATCNT,.01)=ZNODE
     496 . S C0XFDA(C0XTFN,BATCNT,.02)=$O(ZIENS("IEN","ZG",""))
     497 . S C0XFDA(C0XTFN,BATCNT,.03)=$O(ZIENS("IEN","ZS",""))
     498 . S C0XFDA(C0XTFN,BATCNT,.04)=$O(ZIENS("IEN","ZP",""))
     499 . S C0XFDA(C0XTFN,BATCNT,.05)=$O(ZIENS("IEN","ZO",""))
     500 E  D  ;
     501 . S C0XFDA(C0XTFN,"?+"_BATCNT_",",.01)=ZNODE
     502 . S C0XFDA(C0XTFN,"?+"_BATCNT_",",.02)=$O(ZIENS("IEN","ZG",""))
     503 . S C0XFDA(C0XTFN,"?+"_BATCNT_",",.03)=$O(ZIENS("IEN","ZS",""))
     504 . S C0XFDA(C0XTFN,"?+"_BATCNT_",",.04)=$O(ZIENS("IEN","ZP",""))
     505 . S C0XFDA(C0XTFN,"?+"_BATCNT_",",.05)=$O(ZIENS("IEN","ZO",""))
    493506 I BATCNT=BATMAX D  ; BATCH IS DONE
    494  . D UPDIE(.C0XFDA)
     507 . I $G(BLKLOAD) D  ; bulk load
     508 . . D BULKLOAD(.C0XFDA) ; bulk load the batch
     509 . E  D  ; no bulk load
     510 . . D UPDIE(.C0XFDA)
    495511 . K C0XFDA
    496512 . S BATCNT=0 ; RESET COUNTER
     
    557573 Q
    558574 ;
     575BULKLOAD(ZBFDA) ; BULK LOADER FOR LOADING TRIPLES INTO FILE 172.101
     576 ; USING GLOBAL SETS INSTEAD OF UPDATE^DIE
     577 ; QUITS IF FILE IS NOT 172.101
     578 ; EXPECTS AN FDA WITHOUT STRINGS FOR THE IENS, STARTING AT 1
     579 ; QUITS IF FIRST ENTRY IS NOT IENS 1
     580 ; ASSUMES THAT THE LAST IENS IS THE COUNT OF ENTRIES
     581 ; ZBFDA IS PASSED BY REFERENCE
     582 ;
     583 ; -- reserves a block of iens from file 172.101 by locking the zero node
     584 ; -- ^C0X(101,0) and adding the count of entries to piece 2 and 3
     585 ; -- then unlocking to minimize the duration of the lock
     586 ;
     587 W !,"USING BULKLOAD"
     588 I '$D(ZBFDA) Q  ; EMPTY FDA
     589 I $O(ZBFDA(""))'=172.101 Q  ; WRONG FILE
     590 N ZCNT,ZP3,ZP4
     591 ; -- find the number of nodes to insert
     592 S ZCNT=$O(ZBFDA(172.101,""),-1)
     593 I ZCNT="" D  Q  ;
     594 . W !,"ERROR IN BULK LOAD - INVALID NODE COUNT"
     595 . B
     596 ; -- lock the zero node and reserve a block of iens to insert
     597 W !,"LOCKING ZERO NODE"
     598 LOCK +^C0X(101,0)
     599 S ZP3=$P(^C0X(101,0),U,3)
     600 S ZP4=$P(^C0X(101,0),U,4)
     601 S $P(^C0X(101,0),U,3)=ZP3+ZCNT+1
     602 S $P(^C0X(101,0),U,4)=ZP4+ZCNT+1
     603 LOCK -^C0X(101,0)
     604 N ZI,ZN,ZG,ZS,ZP,ZO,ZIEN,ZBASE
     605 S ZBASE=ZP3 ; the last ien in the file
     606 W !,"ZERO NODE UNLOCKED, IENS RESERVED=",ZCNT
     607 W !,$$NOW^XLFDT
     608 S ZI=""
     609 F  S ZI=$O(ZBFDA(172.101,ZI)) Q:ZI=""  D  ;
     610 . S ZN=$G(ZBFDA(172.101,ZI,.01)) ; node name
     611 . I ZN="" D BLKERR Q  ;
     612 . S ZG=$G(ZBFDA(172.101,ZI,.02)) ; graph pointer
     613 . I ZG="" D BLKERR Q  ;
     614 . S ZS=$G(ZBFDA(172.101,ZI,.03)) ; subject pointer
     615 . I ZS="" D BLKERR Q  ;
     616 . S ZP=$G(ZBFDA(172.101,ZI,.04)) ; predicate pointer
     617 . I ZP="" D BLKERR Q  ;
     618 . S ZO=$G(ZBFDA(172.101,ZI,.05)) ; object pointer
     619 . I ZO="" D BLKERR Q  ;
     620 . S ZIEN=ZI+ZBASE ; the new ien
     621 . S ^C0X(101,ZIEN,0)=ZN_U_ZG_U_ZS_U_ZP_U_ZO ; set the zero node
     622 . S ^C0X(101,"B",ZN,ZIEN)="" ; the B index
     623 . S ^C0X(101,"G",ZG,ZIEN)="" ; the G for Graph index
     624 . S ^C0X(101,"SPO",ZS,ZP,ZO)=""
     625 . S ^C0X(101,"SOP",ZS,ZO,ZP)=""
     626 . S ^C0X(101,"OPS",ZO,ZP,ZS)=""
     627 . S ^C0X(101,"OSP",ZO,ZS,ZP)=""
     628 . S ^C0X(101,"GOPS",ZG,ZO,ZP,ZS)=""
     629 . S ^C0X(101,"GOSP",ZG,ZO,ZS,ZP)=""
     630 . S ^C0X(101,"GPSO",ZG,ZP,ZS,ZO)=""
     631 . S ^C0X(101,"GSPO",ZG,ZS,ZP,ZO)=""
     632 Q
     633 ;
     634BLKERR ;
     635 W !,"ERROR IN BULK LOAD",! ZWR ZBFDA(ZI)
     636 B
     637 Q
     638 ;
    559639UPDIE(ZFDA) ; INTERNAL ROUTINE TO CALL UPDATE^DIE AND CHECK FOR ERRORS
    560640 ; ZFDA IS PASSED BY REFERENCE
Note: See TracChangeset for help on using the changeset viewer.