norian: (Default)
Гибридная Графовая База Данных (ака отвертка с моторчиком для моделирования моделей)

День 3. Узлы данных: типы, шаблоны, блюпринты.

Типы данных полей не сохраняются в базе данных, поэтому блюпринт содержит только имена полей узла или линка. Также в блюпринте содержится информация об индексах полей.

При редактировании типа требуются значительные изменения всей структуры базы данных, поэтому предполагается дата пампинг для подобных операций, то есть создание нового блюпринта, автоматизированная перекачка данных существующих узлов и апдейт индексов если они есть. Поэтому имена полей узла добавляются в виде транзакции, то есть старт - добавление всех полей - коммит и после коммита не могут быть изменены.

source egDataNodeBlueprint.h:

#pragma once

#include "../indexes/egCoreIndexTypes.h"
#include "../service/egByteArray.h"
#include "../service/egFileType.h"

const int egBlueprintInit   {1}; // int blueprintMode
const int egBlueprintActive {2};

class EgDataNodeBlueprintType
{
public:
    int blueprintMode {egBlueprintActive};   // blueprint can't be edited freely, data pumping on changes is required
    EgBlueprintIDType   blueprintID;                    // Data Nodes Blueprint (DNL) ID for graph DB
    std::string         blueprintName;                  // == dataNodesTypeName

    EgHamSlicerType     theHamSlicer;                   // memory allocator for data nodes (node has only blueprint out connect)
    EgFileType          blueprintFile;                  // local files load & store support (if local files used)    

    // EgNodeBlueprintSettingsType    blueprintSettings;   // add-ons for blueprint type
    EgFieldsCountType              fieldsCount {0};

    std::unordered_map < std::string, EgFieldsCountType >   dataFieldsNames;    // map  data node field names to fields indexes for dataFieldsPtrs
    std::unordered_map < std::string, EgIndexSettingsType > indexedFields;

    EgByteArrayAbstractType egNotFound;
    const char* egNotFoundStr {"<Data Not Found>"};

    EgDataNodeBlueprintType(std::string a_blueprintName): blueprintName(a_blueprintName), blueprintFile(a_blueprintName) 
        { egNotFound.dataSize = strlen(egNotFoundStr)+1; egNotFound.dataChunk = (unsigned char *) egNotFoundStr; }
    ~EgDataNodeBlueprintType() { /* std::cout << "EgDataNodeBlueprintType destructor " << std::endl; */ clear(); }

    void clear() { dataFieldsNames.clear(); indexedFields.clear(); }

    int  BlueprintInitStart();
    void AddDataFieldName(std::string fieldName);
    void AddIndex(std::string indexName, uint8_t indexSizeBytes = 4, uint8_t indexSubType = egIndexesSpace::egIntFT); // default int32
    void BlueprintInitCommit();

    bool isIndexedField(std::string& name);
    
    inline void writeDataFieldsNames();
    inline void readDataFieldsNames();
    inline void writeIndexedFields();
    inline void readIndexesFields();
    
    int  LocalStoreBlueprint();
    int  LocalLoadBlueprint();
};

// ======================== Debug ========================

void PrintDataNodeBlueprint(EgDataNodeBlueprintType& blueprint);



Для проверки функциональности блюпринта написана тестовая утилита (кое как левой задней, имко нет смысла серьёзно вкладываться в тесты на ранних этапах, но чем раньше они появятся, тем проще контролировать процесс).

Read more... )
norian: (Default)
Гибридная Графовая База Данных (отвертка с моторчиком для моделирования моделей)

День 2. Вспомогательная функциональность, системы сборки и тестирования.

Хедер алиасов основных типов (с++). Чтобы не было разных типов в разных местах кода.

source egCoreTypes.h:

#pragma once
#include <iostream>
#include <cstdint>
#include <map>
#include <unordered_map>

typedef unsigned char ByteType;
    // ID types
typedef uint32_t            EgDataNodeIDType;
typedef EgDataNodeIDType    EgDataLinkIDType;
typedef uint16_t            EgBlueprintIDType;     // data nodes and links blueprint/layout/type/class ID type
typedef uint16_t            EgLayerNumType;
    // count/size/length types
typedef uint16_t            EgFieldNameLengthType;
typedef uint8_t             EgFieldsCountType;
typedef uint16_t            EgStrSizeType;
typedef uint64_t            StaticLengthType;
    // map types
class EgDataNode;
class EgDataLinkType;
typedef std::unordered_map <EgDataNodeIDType, EgDataNode*>  EgDataNodesMapType;
typedef std::map <EgDataNodeIDType, EgDataNode*>            EgDataNodesOrdMapType;
typedef std::unordered_map <EgDataLinkIDType, EgDataNode*>  EgLinkIDsNodePtrsMapType;
typedef std::unordered_map <EgDataNode*, EgDataNode*>   EgLinkDataPtrsNodePtrsMapType;

const uint64_t egDefaultHamBrickSize = 1024;


Система аллокации памяти для небольших кусочков данных "Ham Slicer". При использовании системной аллокации для таких данных получается значительный оверхед и повышенные риски утечек. Ham Slicer аллоцирует относительно большие блоки памяти и выделяет кусочки из них под поля данных.
Read more... )

Profile

norian: (Default)
Norian

January 2026

S M T W T F S
    1 2 3
456 78 910
11121314 151617
18 19 20 21222324
25262728293031

Syndicate

RSS Atom

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Jan. 21st, 2026 07:57 pm
Powered by Dreamwidth Studios