Kódování layoutu ticketovacího systému
Zobrazují se odpovědi 1 až 1 z 1

Ako aplikovat podmienky na KV databazu?

  1. Ahojte,
    robim vrstvu pre strukturovane data nad KV databazou.
    Nizsie je uvedeny popis architektury. Aktualne riesim ako aplikovat podmienky. Cize nieco ako
    Kód:
    WHERE foo.bar = 1 AND baz.bar >= 10
    Rozmyslam ci mam skusit najprv prejst indexy a robit prakticky postupne nejaku map reduce alebo ci si mam vygenerovat zoznam prefixov na kluce a proste si ich prejst jeden po druhom. Ale v konencom dosledku mam stale pocit ze mam len nejaku funkciu ktorou prebehnem vsetky zaznamy a z toho dostanem kopec Row IDciek a vlastne takto to robim v slucke az kym neprejdem cez vsetky podmienky, potom musim zase na N zaznamov aplikovat sort a range a az potom vratit vysledok.

    Nejak som si proste neni isty ako na to :) ... a zase nechcem mat nejake spaghetti riesenie kde nacitam plno dat do pamete zbytocne.

    Architektura:
    Kód:
    /**
    The data objects are mapped onto the key-value store in the following manner:
    primary key:
    	pattern: /table/primaryKeyValue
    	example: /node/25
    	value: nil
    	meaning: if key exists, the table exists, this is present only for prefix matching,
                 otherwise primary key can be used to determine if record exists
    single value:
    	pattern: /table/primaryKeyValue/field
    	example: /node/25/title
    	value: value of the title field
    	meaning: if key exists, it holds the requested field's value,
    			 if does not exist but /tableID/primaryKeyID exists, the value is null
    multiple values:
    	pattern: /table/primaryKeyValue/field/delta
    	example: /node/25/tag/0, /node/25/tag/1, /node/25/tag/2
    	value: value of the tag field
    	meaning: multi-valued fields are split into multiple records by suffixing them
    			 with the delta of the slice value they represent
    primary index:
    	pattern: /table/indexName/indexedValue
    	example: /node/id/10
    	value: nil
    	meaning: id is primary index's (field) name, 10 is unique value
                 and record points to the table id/primary key,
                 this is for prefix filtering that does nto require to walk through all records
                 within the table when filtering on primary key
    unique index:
    	pattern: /table/indexName/indexedValue
    	example: /node/coupon/as4sdf4s54f
    	value: row id / primary key value
    	meaning: coupon is unique index's (field) name, as4sdf4s54f is unique value
                 and record points to the table id/primary key
    simple index:
    	pattern: /table/indexName/indexedValue/primaryKeyValue
    	example: /node/author/12/123
    	value: nil
    	meaning: author is index name, 12 is indexed value, 123 is rows id / primary key value
    
    Example:
    	Node {
    		ID: 123 (primary: primary key)
    		Title: "A lovely day"
    		UID: 12 (author: index)
    		Created: 10.04.2018 10:05:00
    		Changed: 28.08.2018 12:09:25
    		Body: "Lorem Ipsum dolor sit amet ..."
            Categories: []int{4, 5, 9}, (category: index)
            Tags: []int{12, 15, 66, 8}
            Price: 12.5
            Coupon: "x5d6g6s4" (coupon: unique index)
            Summary: nil
    	}
    
    	 primary -> /node/123 = nil
         primary -> /node/id/123 = nil
          author -> /node/coupon/x5d6g6s4 = 123
    	category -> /node/category/4/123 = nil
    	category -> /node/category/5/123 = nil
    	category -> /node/category/9/123 = nil
    
    	   value -> /node/123/id = 123
           value -> /node/123/title = "A lovely day"
           value -> /node/123/uid = 12
           value -> /node/123/created = 10.04.2018 10:05:00
           value -> /node/123/changed = 28.08.2018 12:09:25
           value -> /node/123/body = "Lorem Ipsum dolor sit amet ..."
           value -> /node/123/categories/0 = 4
           value -> /node/123/categories/1 = 5
           value -> /node/123/categories/2 = 9
           value -> /node/123/tags/0 = 12
           value -> /node/123/tags/1 = 15
           value -> /node/123/tags/2 = 66
           value -> /node/123/tags/3 = 8
           value -> /node/123/price = 12.5
           value -> /node/123/coupon = "x5d6g6s4
           * note the absence of the summary field, empty fields do not have placeholder records
    
    The schema is mapped like so:
    	/_schema/tableName/_primary = columnName
    	/_schema/tableName/_unique/indexName = columnName // index name will always match the column name
    	/_schema/tableName/_index/indexName = columnName // index name will always match the column name
    	/_schema/tableName/columnName/type = data type
    	/_schema/tableName/columnName/default = default value ... no entry means no default value
    	/_schema/tableName/columnName/multi = 1/0 is/not multivalued ... no entry means FALSE
    	/_schema/tableName/columnName/req = 1/0 is/not required ... no entry means FALSE
    	/_schema/tableName/columnName/ai = int64 auto-increment counter for integer-typed indexes ... no entry means no AI
    
    Notes:
    	- only fields of integer data type can be primary keys
    	- primary key has to be required or have auto-increment enabled
    	- primary and unique indexes can be only single valued fields
    	- index and unique index can be only string, integer, decimal, boolean
    	- auto-increment setting will be used only on integer values
    	- default values will be ignored for unique and primary indexes fields
    	- boolean values are stored as 1/0, hence will be used as such when used as indexes
    	- when row with filled index is being inserted and AI is enabled, the value cannot be smaller than the
          value of the /_schema/tableName/columnName/ai. If the value is larger than the stored AI counter,
          the AI counter will be increased to match this new value and all new records will be assigned larger
          values from the inserted row from now on.
    
    */

    ---
    Tak na koniec to asi vyriesim tak ze vsetky stlpce budu automaticky indexy. Pri KV databaze to dava dost zmysel. Takto mozem iterovat len kluce ktore su v ramke a nemusim vobec pristupovat k ulozenym datam(az na par datovych typov ktore nemozno indexovat).
    Naposledy upravil node : 09.08.2018 v 23:36

  2. Co se právě děje na Webtrhu?
    Eliaš - IT Solutions poptává: Hľadám VUE js - Praha
    CocoBryce poptává: Dropshop na Prestashopu
    Matěj Plšek poptává: Návrh plošných spojů
Hostujeme u Server powered by TELE3