📜 ⬆️ ⬇️

Globals are Cossack swords for data storage. Trees Part 2

Start - see part 1.

3. Variants of structures when using globals


Such a structure as an ordered tree has different special cases. Consider those that have practical value when working with globals.

3.1 Special case 1. One node without branches



Globals can be used not only like an array, but also as ordinary variables. For example, as a counter:
')
Set ^counter = 0  ;  
Set id=$Increment(^counter) ;   

, , . .

3.2 2.


— key-value . , .



, . :

  1. -.
    Set ^t(id1) = "col11/col21/col31"
    Set ^t(id2) = "col12/col22/col32"
  2. , . .
  3. $LB ( Cache), .

    Set ^t(id1) = $LB("col11", "col21", "col31")
    Set ^t(id2) = $LB("col12", "col22", "col32")

, . . — , . .

.

Set ^i("col11", id1) = 1
Set ^i("col12", id2) = 1

^i (id) .

. .

TSTART
Set ^t(id1) = $LB("col11", "col21", "col31")
Set ^i("col11", id1) = 1
TCOMMIT

c M , .

( ), // COS/M .
INSERT SELECT , TSTART TCOMMIT ().

.

778 361 /.
300 — 422 141 /.

— 572 082 / 50 . M-.
, SSD. RAID5 Write-back. Phenom II 1100T.

SQL- , . MySQL 5.5 ( InnoDB) , 11 .

, , . SQL- .

, , , SQL, .
, . , . , key-value, , , , - .
- , .

3.3 3. ,


, , : . .
vs. .
  1. , .
  2. . ( ) .

  1. , . 11,5% 2- .

: . — , , .

3.4 .


, , .

3.4.1




. , , , . . , 99% .

SQL : «» ~ 100 000 , «» — 100 000 , «» — 100 000 , «» — 100 000 .. .. , ( !), , , .

, , , , , , .

, . , , ,
.
, SQL (EAV, 1,2,3,4,5,6,7,8,9,10), . . () (SQL). .

, (ALTER TABLE) . MySQL, , ALTER TABLE ADD|DROP COLUMN ( MyISAM, InnoDB). , .

, , . , . .

, , — .

, , — , B-tree.

, , - , . - .
, , MongoDB. :

  1. . JSON ( BSON) 16. , JSON- , JSON-, . . . 16 , , . . , .
  2. // . ( !), BSON, // , , BSON, . .
  3. . , B-tree. BSON , .

3.3.2


( ) . PHP 3.3.1.

$a = array(
  "name" => "Vince Medvedev",
  "city" => "Moscow",
  "threatments" => array(
    "surgeries" => array("apedicectomy", "biopsy"),
    "radiation" => array("gamma", "x-rays"),
    "physiotherapy" => array("knee", "shoulder")
  )
);


3.3.3 : XML, JSON


. .

XML
XML , . , .

<note id=5>
<to></to>
<from></from>
<heading></heading>
<body>  !</body>
</note>

COS :

Set ^xml("note")="id=5"
Set ^xml("note","to")=""
Set ^xml("note","from")=""
Set ^xml("note","heading")=""
Set ^xml("note","body")="  !"

: XML, JSON, . note. ^xml . , , :


JSON.
3.3.1 JSON-:

var document = {
  "name": "Vince Medvedev",
  "city": "Moscow",
  "threatments": {
    "surgeries": ["apedicectomy", "biopsy"],
    "radiation": ["gamma", "x-rays"],
    "physiotherapy": ["knee", "shoulder"]
  },
};


3.3.4 ,


: , -, .

. . , . .



, . . , . , .



4.


, , .
/
  1. [ ], [ ]
  2. ,
  3. ,
  1. / [/ ] /
  2. (schema-less). .
  3. .
  4. . .


« — - . . 3».

Disclaimer: InterSystems.

Source: https://habr.com/ru/post/264173/


All Articles