OceanBase logo

OceanBase

A unified distributed database ready for your transactional, analytical, and AI workloads.

DEPLOY YOUR WAY

OceanBase Cloud

The best way to deploy and scale OceanBase

OceanBase Enterprise

Run and manage OceanBase on your infra

TRY OPEN SOURCE

OceanBase Community Edition

The free, open-source distributed database

OceanBase seekdb

Open source AI native search database

Customer Stories

Real-world success stories from enterprises across diverse industries.

View All
BY USE CASES

Mission-Critical Transactions

Global & Multicloud Application

Elastic Scaling for Peak Traffic

Real-time Analytics

Active Geo-redundancy

Database Consolidation

Resources

Comprehensive knowledge hub for OceanBase.

Blog

Live Demos

Training & Certification

Documentation

Official technical guides, tutorials, API references, and manuals for all OceanBase products.

View All
PRODUCTS

OceanBase Cloud

OceanBase Database

Tools

Connectors and Middleware

QUICK START

OceanBase Cloud

OceanBase Database

BEST PRACTICES

Practical guides for utilizing OceanBase more effectively and conveniently

Company

Learn more about OceanBase – our company, partnerships, and trust and security initiatives.

About OceanBase

Partner

Trust Center

Contact Us

International - English
中国站 - 简体中文
日本 - 日本語
Sign In
Start on Cloud

A unified distributed database ready for your transactional, analytical, and AI workloads.

DEPLOY YOUR WAY

OceanBase Cloud

The best way to deploy and scale OceanBase

OceanBase Enterprise

Run and manage OceanBase on your infra

TRY OPEN SOURCE

OceanBase Community Edition

The free, open-source distributed database

OceanBase seekdb

Open source AI native search database

Customer Stories

Real-world success stories from enterprises across diverse industries.

View All
BY USE CASES

Mission-Critical Transactions

Global & Multicloud Application

Elastic Scaling for Peak Traffic

Real-time Analytics

Active Geo-redundancy

Database Consolidation

Comprehensive knowledge hub for OceanBase.

Blog

Live Demos

Training & Certification

Documentation

Official technical guides, tutorials, API references, and manuals for all OceanBase products.

View All
PRODUCTS
OceanBase CloudOceanBase Database
ToolsConnectors and Middleware
QUICK START
OceanBase CloudOceanBase Database
BEST PRACTICES

Practical guides for utilizing OceanBase more effectively and conveniently

Learn more about OceanBase – our company, partnerships, and trust and security initiatives.

About OceanBase

Partner

Trust Center

Contact Us

Start on Cloud
编组
All Products
    • Databases
    • iconOceanBase Database
    • iconOceanBase Cloud
    • iconOceanBase Tugraph
    • iconInteractive Tutorials
    • iconOceanBase Best Practices
    • Tools
    • iconOceanBase Cloud Platform
    • iconOceanBase Migration Service
    • iconOceanBase Developer Center
    • iconOceanBase Migration Assessment
    • iconOceanBase Admin Tool
    • iconOceanBase Loader and Dumper
    • iconOceanBase Deployer
    • iconKubernetes operator for OceanBase
    • iconOceanBase Diagnostic Tool
    • iconOceanBase Binlog Service
    • Connectors and Middleware
    • iconOceanBase Database Proxy
    • iconEmbedded SQL in C for OceanBase
    • iconOceanBase Call Interface
    • iconOceanBase Connector/C
    • iconOceanBase Connector/J
    • iconOceanBase Connector/ODBC
    • iconOceanBase Connector/NET
icon

OceanBase Tugraph

V3.3.3Enterprise Edition

  • Guide
    • What is a graph
    • What is a graph database
    • TuGraph Quick Start
  • Operating
    • Introduction
    • Installation
    • Data Importing
    • Service configuration
    • Service operations
    • Tools
      • tugraph_cypher Instructions
      • TuGraph Browser
      • TuGraph DataX Instructions
      • TuGraph Explore Instructions
    • High Availability mode
    • Database Management
    • User rights Management
  • Developer Document
    • TuGraph RESTful API
    • TuGraph-Cypher
    • TuGraph Stored Procedure Guide
    • Graph Analytics Engine
      • Bootstrap program
      • OlapBase API
      • OlapOnDB API
      • OlapOnDisk API
      • TuGraph Built-in Algorithm Description
  • Client
    • TuGraph Java SDK
    • TuGraph Python SDK
    • TuGraph C++ SDK
  • Supplement
    • Update the content description
  • Community
    • TuGraph Contribution Guide
    • TuGraph community roles
    • TuGraph Open source planning
    • Ant_Group_Open_Source_Individual_CLA_English_Chinese_2021
    • Ant_Group_Open_Source_Corporate_CLA_English_Chinese_2021

Download PDF

What is a graph What is a graph database TuGraph Quick Start Introduction Installation Data Importing Service configuration Service operations tugraph_cypher Instructions TuGraph Browser TuGraph DataX Instructions TuGraph Explore Instructions High Availability mode Database Management User rights Management TuGraph RESTful API TuGraph-Cypher TuGraph Stored Procedure Guide Bootstrap program OlapBase API OlapOnDB API OlapOnDisk API TuGraph Built-in Algorithm Description TuGraph Java SDK TuGraph Python SDK TuGraph C++ SDK Update the content description TuGraph Contribution Guide TuGraph community roles TuGraph Open source planningAnt_Group_Open_Source_Individual_CLA_English_Chinese_2021Ant_Group_Open_Source_Corporate_CLA_English_Chinese_2021
OceanBase logo

The Unified Distributed Database for the AI Era.

Follow Us
Products
OceanBase CloudOceanBase EnterpriseOceanBase Community EditionOceanBase seekdb
Resources
DocsBlogLive DemosTraining & Certification
Company
About OceanBaseTrust CenterLegalPartnerContact Us
Follow Us

© OceanBase 2026. All rights reserved

Cloud Service AgreementPrivacy PolicySecurity
Contact Us
Document Feedback
  1. Documentation Center
  2. OceanBase Tugraph
  3. V3.3.3
iconOceanBase Tugraph
V 3.3.3Enterprise Edition

Bootstrap program

Last Updated:2023-06-25 03:23:24  Updated
share
What is on this page
1. Introduction to TuGraph-Graph Analysis Engine
2. Procedure compile and run
3. Embed compile and run
4. Standalone compile and run

folded

share

This document is a bootstrap program designed for TuGraph users. Before reading the detailed documents, users should read this document first to have a general understanding of TuGraph's graph computing operation process, and it will be more convenient to read the detailed documents later. The bootstrap program is a simple instance of a bfs (breadth-first search) program based on Tugraph, and we will focus on how it is used.

1. Introduction to TuGraph-Graph Analysis Engine

TuGraph's graph analysis engine, oriented to the scene is mainly full graph/full data analysis class tasks. With the help of TuGraph's C++ graph analysis engine API, users can quickly derive a complex subgraph from different data sources, and then run iterative graph algorithms such as PageRank, LPA, WCC on the subgraph, and finally make corresponding countermeasures according to the running results.

In TuGraph, the process of both export and computation can be accelerated by parallel processing in memory, so as to achieve near-real-time processing and analysis. Compared with traditional methods, the overhead of data export and disk drop can be avoided, and the ideal performance of computation can be obtained by using compact graph data structure.

TuGraph has 6 built-in algorithms in the community version and 25 built-in algorithms in the commercial version. Users hardly need to implement the specific graph calculation process themselves. For details, please refer to algorithms.md.

According to different data sources and implementations, it can be divided into Procedure, Embed and Standalone, which all inherit from OlapBase API. OlapBase API interface documentation can be found in OlAPBase-APi.md.

The data source of Procedure and Embed is the db data preloaded in the graph database, which can be compiled to generate the.so file used by TuGraph-Web loading and the embed file used by the background terminal respectively. The input graph data are loaded in the form of db. The interface document can refer to olapondb-api.md.

Standalone is used to compile and generate a standalone file. Different from the former, the input graph data of the file is loaded in the form of txt, binary, and ODPS files, and the interface document can refer to olapondisk-api.md.

2. Procedure compile and run

This mode is mainly used for visual loading and running on the TuGraph-web interface. The usage method is as follows:

Run bash make_so.sh bfs in the TuGraph/plugins directory to the BFs.so file in the TuGraph/plugins directory, upload the file as a plug-in to Tugraph-web, input parameters and then execute.

Example: Compile the.so algorithm file at TuGraph/plugins bash make_so.sh bfs

After loading the bfs.so file as a plug-in to TuGraph-web, enter the following json parameters:

{
  "root_id": "0",
  "label": "node",
  "field": "id"
}

The following result

result:"{"core_cost":0.013641119003295898, "found_vertices":3829, "num_edges":88234, "num_vertices":4039, "output_cost":8.821487426757813e-06, "prepare_cost":0.03479194641113281, "total_cost":0.04844188690185547}"

The output :

  • num_edges: the number of edges in the graph
  • num_vertices: the number of nodes in the graph
  • prepare_cost: Represents the time required for the preprocessing phase. The preprocessing phase works: loading parameters, graph data loading, index initialization.
  • core_cost: Represents the time required for the algorithm to run.
  • found_vertices: Number of vertices found.
  • output_cost: the time it takes for the algorithm result to be written back to db.。
  • total_cost: The overall running time of the algorithm is executed.

make_so.sh This file is used to compile the graph algorithm files involved in TuGraph-OLAP into a.so file available for TuGraph-web.

3. Embed compile and run

This way is mainly used for TuGraph in the background program on the preloaded db graph data algorithm analysis. Its use method is as follows:

To complete the embed_main.cpp file in TuGraph/plugins directory, add the data name, input parameters, data path and other information, as shown in the following example:

#include <iostream>
#include "lgraph/lgraph.h"
#include "lgraph/olap_base.h"
using namespace std;

extern "C" bool Process(lgraph_api::GraphDB &db, const std::string &request, std::string &response);

int main(int argc, char **argv) {
    // db_path Specifies the path for saving the preloaded graph data
    std::string db_path = "../fb_db/";
    if (argc > 1)
        db_path = argv[1];
    lgraph_api::Galaxy g(db_path);
    g.SetCurrentUser("admin", "73@TuGraph");
    // Specifies the name of the graph
    lgraph_api::GraphDB db = g.OpenGraph("fb_db");
    std::string resp;
    // Enter the algorithm parameters in json format
    bool r = Process(db, "{\"root_id\":\"0\", \"label\":\"node\",\"field\":\"id\"}", resp);
    cout << r << endl;
    cout << resp << endl;
    return 0;
}

Run bash make_so.sh bfs in TuGraph/plugins to bfs_procedure in TuGraph/plugins/cpp. bash make_embed.sh bfs

Do this in the TuGraph/plugins folder ./cpp/bfs_procedure The result is returned.

Input: {"root_id":"0", "label":"node","field":"id"} found_vertices = 3829 {"core_cost":0.025603055953979492, "found_vertices":3829, "num_edges":88234, "num_vertices":4039, "output_cost":9.059906005859375e-06, "prepare_cost":0.056738853454589844, "total_cost":0.0823509693145752}

Input indicates the input parameters.The other parameters are described as above.

4. Standalone compile and run

This file is mainly used to load the graph data directly at the terminal and run the printout results. Here's how to use it:

In TuGraph/build directory make bfs_standalone can get bfs_standalone file, the file is generated with TuGraph/build/output/algo folder.

Run: Go to the TuGraph/build directory and do./output/algo/bfs_standalone -- type [type] -- input_dir [input_dir] -- vertices [vertices] --root (root) - output_dir [output_dir]

Ready to run.

  • [type] : indicates the type source of the input graph file, including text file, BINARY_FILE binary file, and ODPS source.

  • [input_dir] : indicates the path of the input graph file folder, which may contain one or more input files. TuGraph will read all the files under [input_dir] when reading the input file. It is required that [input_dir] can only contain the input file and cannot contain other files. Parameters cannot be omitted.

  • [vertices] : represents the number of vertices in the graph. 0 indicates the number of vertices that the user wants the system to automatically recognize. When is non-zero, it indicates the number of vertices that the user wants to customize. The number of user-defined vertices must be greater than the maximum vertex ID. This parameter can be omitted. The default value is 0.

  • [root] : indicates the starting vertex id for bfs. The argument cannot be omitted.

  • [output_dir] : indicates the path of the folder where the output data is saved. The output content is saved to this file, and the parameter cannot be omitted.

Example Compile the standalone algorithm program at TuGraph/build

make bfs_standalone

Run the text source file in TuGraph/build/output

    ./output/algo/bfs_standalone --type text --input_dir ../test/integration/data/algo/fb_unweighted --root 0

Result:

prepare_cost = 0.10(s)
core_cost = 0.02(s)
found_vertices = 3829
output_cost = 0.00(s)
total_cost = 0.11(s)
DONE.

Result Parameter description is the same as above.

If you do not know the required parameters of a new algorithm, run the./output/algo/bfs_standalone --type odps/text/binary (select one) -h to view the parameters.

At this point, the process of bfs operation on the figure above by TuGraph is complete.

Previous topic

TuGraph Stored Procedure Guide
Last

Next topic

OlapBase API
Next
What is on this page
1. Introduction to TuGraph-Graph Analysis Engine
2. Procedure compile and run
3. Embed compile and run
4. Standalone compile and run