Graph

Struct Graph 

Source
pub struct Graph<'gl> { /* private fields */ }
Expand description

A standalone graph opened by Galaxy.

See the Galaxy::open_graph for more details.

§Lifetime

The 'gl lifetime of Graph is the lifetime of galaxy that is borrowed when open it.

Implementations§

Source§

impl<'gl> Graph<'gl>

Source

pub unsafe fn from_ptr(ptr: *mut lgraph_api_graph_db_t) -> Graph<'gl>

Create a graph from c binding ptr

§Safety

It should only be used when writing rust procedure plugin to convert raw c binding ptr to rust Graph

Source

pub fn create_ro_txn(&self) -> Result<RoTxn<'_>>

Create a read-only transaction.

There can be multiple simultaneously active read-only transactions but only one that can write. Once a single read-write transaction is opened, all further attempts to begin one will block until the first one is committed or aborted. This has no effect on read-only transactions, however, and they may continue to be opened at any time.

§Errors

TODO(eadrenking@outlook.com):

§Examples
use tugraph::{db::OpenOptions, Error};
use std::{str::FromStr, path::PathBuf};

let galaxy = OpenOptions::new()
    .create(true)
    .open("/tmp/rust_tugraph/doc/create_ro_txn", "admin", "73@TuGraph")?;
let graph = galaxy.open_graph("default", true)?;
let ro_txn = graph.create_ro_txn()?;
Source

pub fn create_rw_txn(&self, optimistic: bool) -> Result<RwTxn<'_>>

Create a read-write transaction.

A read-write transaction can be optimistic. Optimistic transactions can run in parallel and any conflict will be detected during commit. If read-write transaction is not optimistic, only one read-write transaction can be active, all further attempts to begin one will block utils the frist one is committed or aborted.

§Errors

TODO(eadrenking@outlook.com)

§Examples
use tugraph::{db::OpenOptions, Error};
use std::{str::FromStr, path::PathBuf};

let galaxy = OpenOptions::new()
    .create(true)
    .open("/tmp/rust_tugraph/doc/create_rw_txn", "admin", "73@TuGraph")?;
let graph = galaxy.open_graph("default", false)?;
let rw_txn = graph.create_rw_txn(true)?;
Source

pub fn fork_ro_txn(&self, txn: &RoTxn<'_>) -> Result<RoTxn<'_>>

👎Deprecated: transaction is not Send and cannot be used in Arc

Fork a read-only transaction

The resulting read-only transaction will share the same view as the forked one, meaning that when reads are performed on the same vertex/edge, the results will always be identical, whether they are performed in the original transaction or the forked one.

Note: Since one thread can only have one active read-only transaction, fork_ro_txn should be called in another thread.

§Errors

TODO(eadrenking@outlook.com)

§Examples
use tugraph::{db::OpenOptions, Error};
use std::{str::FromStr, path::PathBuf, thread};

let galaxy = OpenOptions::new()
    .create(true)
    .open("/tmp/rust_tugraph/doc/fork_ro_txn", "admin", "73@TuGraph")?;
let graph = galaxy.open_graph("default", true)?;
let ro_txn = graph.create_ro_txn()?;
thread::scope(|s| {
    s.spawn(|| {
        let forked_ro_txn = graph
            .fork_ro_txn(&ro_txn)
            .expect("fork ro-txn should be ok");
    });
});
Source

pub fn flush(&self) -> Result<()>

Flush buffered data to disk.

Read-write transaction write data into filesystem when commit returns sucessfully. Call flush to call filesystem to write data buffered in kernel into disk.

§Errors

TODO(eadrenking@outlook.com)

§Examples
use tugraph::{db::OpenOptions, Error};
use std::{str::FromStr, path::PathBuf};

let galaxy = OpenOptions::new()
    .create(true)
    .open("/tmp/rust_tugraph/doc/flush", "admin", "73@TuGraph")?;
let graph = galaxy.open_graph("default", false)?;
let rw_txn = graph.create_rw_txn(false)?;
// do some update work in rw_txn
// ...
graph.flush()?;
Source

pub fn drop_all_data(&self) -> Result<()>

Drop all the data in the graph, including labels, indexes and vertexes/edges.

§Errors

TODO(eadrenking@outlook.com)

§Examples
use tugraph::{db::OpenOptions, Error};
use std::{str::FromStr, path::PathBuf};

let galaxy = OpenOptions::new()
    .create(true)
    .open("/tmp/rust_tugraph/doc/drop_all_data", "admin", "73@TuGraph")?;
let graph = galaxy.open_graph("default", false)?;
// do some update work in rw_txn
// ...
graph.drop_all_data()?;
Source

pub fn drop_all_vertex(&self) -> Result<()>

Drop all vertex and edges but keep the labels and indexes.

§Errors

TODO(eadrenking@outlook.com)

§Examples
use tugraph::{db::OpenOptions, Error};
use std::{str::FromStr, path::PathBuf};

let galaxy = OpenOptions::new()
    .create(true)
    .open("/tmp/rust_tugraph/doc/drop_all_vertex", "admin", "73@TuGraph")?;
let graph = galaxy.open_graph("default", false)?;
let rw_txn = graph.create_rw_txn(false)?;
// do some update work in rw_txn
// ...
graph.drop_all_vertex()?;
Source

pub fn estimate_num_vertices(&self) -> Result<usize>

Estimate number of vertices.

We don’t maintain the exact number of vertices, but only the next vid. This method actually returns the next vid to be used. So if you have deleted a lot of vertices, the result can be quite different from actual number of vertices.

§Errors

TODO(eadrenking@outlook.com)

§Examples
use tugraph::{db::OpenOptions, Error};
use std::{str::FromStr, path::PathBuf};

let galaxy = OpenOptions::new()
    .create(true)
    .open("/tmp/rust_tugraph/doc/estimate_num_vertices", "admin", "73@TuGraph")?;
let graph = galaxy.open_graph("default", true)?;
let num = graph.estimate_num_vertices()?;
Source

pub fn add_vertex_label<'a, T>( &self, label: &str, field_specs: T, primary_field: &str, ) -> Result<bool>
where T: IntoIterator<Item = &'a FieldSpec>,

Add a vertex label.

§Errors

TODO(eadrenking@outlook.com)

§Examples
use tugraph::{db::OpenOptions, field::{FieldSpec, FieldType}, Error};
use std::{str::FromStr, path::PathBuf};

let galaxy = OpenOptions::new()
    .create(true)
    .open("/tmp/rust_tugraph/doc/add_vertex_label", "admin", "73@TuGraph")?;
let graph = galaxy.open_graph("default", false)?;
graph.add_vertex_label(
    "Person",
     &[
         FieldSpec {
             name: "name".into(),
              ty: FieldType::String,
              optional: false,
          },
          FieldSpec {
              name: "age".into(),
              ty: FieldType::Int8,
              optional: false,
          },
         FieldSpec {
             name: "is_male".into(),
            ty: FieldType::Bool,
             optional: false,
         },
    ],
    "name",)?;
Source

pub fn delete_vertex_label(&self, label: &str) -> Result<(bool, usize)>

Delete a vertex label and all the vertices with this label.

§Errors

TODO(eadrenking@outlook.com)

§Examples
use tugraph::{db::OpenOptions, field::FieldSpec, Error};
use std::{str::FromStr, path::PathBuf};

let galaxy = OpenOptions::new()
    .create(true)
    .open("/tmp/rust_tugraph/doc/delete_vertex_label", "admin", "73@TuGraph")?;
let graph = galaxy.open_graph("default", false)?;
graph.delete_vertex_label("Person")?;
Source

pub fn alter_vertex_label_del_fields<'a, T>( &self, label: &str, del_fields: T, ) -> Result<(bool, usize)>
where T: IntoIterator<Item = &'a str>,

Delete fields in a vertex label.

This method also updates the vertex data and indices accordingly to make sure the database remains in consistent state.

§Errors

TODO(eadrenking@outlook.com)

§Examples
use tugraph::{db::OpenOptions, field::FieldSpec, Error};
use std::{str::FromStr, path::PathBuf};

let galaxy = OpenOptions::new()
    .create(true)
    .open("/tmp/rust_tugraph/doc/alter_vertex_label_del_fields", "admin", "73@TuGraph")?;
let graph = galaxy.open_graph("default", false)?;
graph.alter_vertex_label_del_fields("Person", ["age", "is_male"])?;
Source

pub fn alter_vertex_label_add_fields<'a, 'b, T, D>( &self, label: &str, add_fields: T, default_values: D, ) -> Result<(bool, usize)>
where T: IntoIterator<Item = &'a FieldSpec>, D: IntoIterator<Item = &'b FieldData>,

Add fields to a vertex label.

The new fields in existing vertices will be filled with default values.

§Errors

TODO(eadrenking@outlook.com)

§Examples
use tugraph::{db::OpenOptions, field::{FieldSpec, FieldType, FieldData}, Error};
use std::{str::FromStr, path::PathBuf};

let galaxy = OpenOptions::new()
    .create(true)
    .open("/tmp/rust_tugraph/doc/alter_vertex_label_add_fields", "admin", "73@TuGraph")?;
let graph = galaxy.open_graph("default", false)?;
graph.add_vertex_label(
    "Person",
     &[
        FieldSpec {
              name: "name".into(),
              ty: FieldType::String,
              optional: false,
        },
    ],
    "name",
)?;
graph.alter_vertex_label_add_fields(
    "Person",
     &[
        FieldSpec {
            name: "age".into(),
            ty: FieldType::Int8,
            optional: false,
        },
    ],
    &[FieldData::Bool(false)],
)?;
Source

pub fn alter_vertex_label_mod_fields<'a, T>( &self, label: &str, mod_fields: T, ) -> Result<(bool, usize)>
where T: IntoIterator<Item = &'a FieldSpec>,

Modify fields in a vertex label, either chage the data type or optional, or both.

§Errors

TODO(eadrenking@outlook.com)

§Examples
use tugraph::{db::OpenOptions, field::{FieldSpec, FieldType}, Error};
use std::{str::FromStr, path::PathBuf};

let galaxy = OpenOptions::new()
    .create(true)
    .open("/tmp/rust_graph/doc/alter_vertex_label_mod_fields", "admin", "73@TuGraph")?;
let graph = galaxy.open_graph("default", false)?;
graph.add_vertex_label(
    "Person",
     &[
        FieldSpec {
              name: "name".into(),
              ty: FieldType::String,
              optional: false,
        },
        FieldSpec {
              name: "age".into(),
              ty: FieldType::Int64,
              optional: false,
        },
    ],
    "name",
)?;
graph.alter_vertex_label_mod_fields(
    "Person",
      &[
          FieldSpec {
              name: "age".into(),
              ty: FieldType::Int8,
              optional: false,
          },
    ],
)?;
Source

pub fn add_edge_label<'a, 'b, 'c, U, C>( &self, label: &str, field_specs: U, temporal_field: &str, edge_constraints: C, ) -> Result<bool>
where U: IntoIterator<Item = &'a FieldSpec>, C: IntoIterator<Item = (&'b str, &'c str)>,

Add a edge label, specifying its schema.

It is allowed to specify edge constrains, too. An edge can be bound to several (source_label, destination_label) pairs, which makes sure this type of edges will only be added between these types of vertices. By default, the constraint is empty, meaning that the edge is not restricted.

§Errors

TODO(eadrenking@outlook.com)

§Examples
use tugraph::{db::OpenOptions, field::{FieldSpec, FieldType}, Error};
use std::{str::FromStr, path::PathBuf};

let galaxy = OpenOptions::new()
    .create(true)
    .open("/tmp/rust_tugraph/doc/add_edge_label", "admin", "73@TuGraph")?;
let graph = galaxy.open_graph("default", false)?;
graph.add_vertex_label("Person",
   &[
       FieldSpec {
           name: "name".into(),
           ty: FieldType::String,
           optional: false,
       },
   ],
   "name",
)?;
graph.add_vertex_label("Comment",
   &[
       FieldSpec {
           name: "content".into(),
           ty: FieldType::String,
           optional: false,
       },
   ],
   "content",
)?;
graph.add_edge_label(
    "Post",
    &[
        FieldSpec {
            name: "datetime".into(),
            ty: FieldType::DateTime,
            optional: false,
        }
    ],
    "",
    [("Person", "Comment")],
)?;
Source

pub fn delete_edge_label(&self, label: &str) -> Result<(bool, usize)>

Deletes an edge label and all the edges of this type.

§Errors

TODO(eadrenking@outlook.com)

§Examples
use tugraph::{db::OpenOptions, Error};
use std::{str::FromStr, path::PathBuf};

let galaxy = OpenOptions::new()
    .create(true)
    .open("/tmp/rust_tugraph/doc/delete_edge_label", "admin", "73@TuGraph")?;
let graph = galaxy.open_graph("default", false)?;
graph.delete_edge_label("Post")?;
Source

pub fn alter_label_mod_edge_constraints<'a, 'b, 'c, U>( &self, label: &str, constraints: U, ) -> Result<bool>
where U: IntoIterator<Item = (&'b str, &'c str)>,

Modify edge constraint.

Existing edges that violate the new constrain will be removed.

§Errors

TODO(eadrenking@outlook.com)

§Examples
use tugraph::{db::OpenOptions, field::FieldSpec, Error};
use std::{str::FromStr, path::PathBuf};

let galaxy = OpenOptions::new()
    .create(true)
    .open("/tmp/rust_tugraph/doc/alter_label_mod_edge_constraints", "admin", "73@TuGraph")?;
let graph = galaxy.open_graph("default", false)?;
graph.alter_label_mod_edge_constraints("Post", [("Person", "Comment")])?;
Source

pub fn alter_edge_label_del_fields<'a, T>( &self, label: &str, del_fields: T, ) -> Result<(bool, usize)>
where T: IntoIterator<Item = &'a str>,

Delete fields in an edge label.

Existing edges that violate the new constrain will be removed.

§Errors

TODO(eadrenking@outlook.com)

§Examples
use tugraph::{db::OpenOptions, Error};
use std::{str::FromStr, path::PathBuf};

let galaxy = OpenOptions::new()
    .create(true)
    .open("/tmp/rust_tugraph/doc/alter_edge_label_del_fields", "admin", "73@TuGraph")?;
let graph = galaxy.open_graph("default", false)?;
graph.alter_edge_label_del_fields("Post", ["datetime"])?;
Source

pub fn alter_edge_label_add_fields<'a, 'b, U, D>( &self, label: &str, add_fields: U, default_values: D, ) -> Result<(bool, usize)>
where U: IntoIterator<Item = &'a FieldSpec>, D: IntoIterator<Item = &'b FieldData>,

Add fields to an edge label.

The new fields in existing edges will be set to default values.

§Errors

TODO(eadrenking@outlook.com)

§Examples
use tugraph::{db::OpenOptions, field::{FieldSpec, FieldData, FieldType}, Error};
use std::{str::FromStr, path::PathBuf};

let galaxy = OpenOptions::new()
    .create(true)
    .open("/tmp/rust_tugraph/doc/alter_edge_label_add_fields", "admin", "73@TuGraph")?;
let graph = galaxy.open_graph("default", false)?;
graph.alter_edge_label_add_fields(
    "Post",
    &[
        FieldSpec {
            name: "title".into(),
            ty: FieldType::String,
            optional: true,
        },
    ],
    &[FieldData::String(String::new())],
)?;
Source

pub fn alter_edge_label_mod_fields<'a, T>( &self, label: &str, mod_fields: T, ) -> Result<(bool, usize)>
where T: IntoIterator<Item = &'a FieldSpec>,

Modify fields in an edge label.

Data type and OPTIONAL can be modified.

§Errors

TODO(eadrenking@outlook.com)

§Examples
use tugraph::{db::OpenOptions, field::{FieldSpec, FieldType}, Error};
use std::{str::FromStr, path::PathBuf};

let galaxy = OpenOptions::new()
    .create(true)
    .open("/tmp/rust_tugraph/doc/alter_edge_label_mod_fields", "admin", "73@TuGraph")?;
let graph = galaxy.open_graph("default", false)?;
graph.alter_edge_label_mod_fields(
    "Post",
    &[
        FieldSpec {
            name: "title".into(),
            ty: FieldType::String,
            optional: true,
        },
    ],
)?;
Source

pub fn add_vertex_index( &self, label: &str, field: &str, is_unique: bool, ) -> Result<bool>

Adds an index to ‘label:field’.

This method blocks until the index is fully created.

§Errors

TODO(eadrenking@outlook.com)

§Examples
use tugraph::{db::OpenOptions, field::{FieldType, FieldSpec}, Error};
use std::{str::FromStr, path::PathBuf};

let galaxy = OpenOptions::new()
    .create(true)
    .open("/tmp/rust_graph/doc/add_vertex_index", "admin", "73@TuGraph")?;
let graph = galaxy.open_graph("default", false)?;
graph.add_vertex_label("Person",
   &[
       FieldSpec {
           name: "name".into(),
           ty: FieldType::String,
           optional: false,
       },
       FieldSpec {
           name: "age".into(),
           ty: FieldType::Int8,
           optional: false,
       },
   ],
   "name",
)?;
graph.add_vertex_index("Person", "age", false)?;
Source

pub fn add_edge_index( &self, label: &str, field: &str, is_unique: bool, ) -> Result<bool>

Adds an index to ‘label:field’.

This method blocks until the index is fully created.

§Errors

TODO(eadrenking@outlook.com)

§Examples
use tugraph::{db::OpenOptions, field::{FieldType, FieldSpec}, Error};
use std::{str::FromStr, path::PathBuf};

let galaxy = OpenOptions::new()
    .create(true)
    .open("/tmp/rust_tugraph/doc/add_edge_index", "admin", "73@TuGraph")?;
let graph = galaxy.open_graph("default", false)?;
graph.add_vertex_label("Person",
   &[
       FieldSpec {
           name: "name".into(),
           ty: FieldType::String,
           optional: false,
       },
   ],
   "name",
)?;
graph.add_vertex_label("Comment",
   &[
       FieldSpec {
           name: "content".into(),
           ty: FieldType::String,
           optional: false,
       },
   ],
   "content",
)?;
graph.add_edge_label(
    "Post",
    &[
        FieldSpec {
            name: "datetime".into(),
            ty: FieldType::DateTime,
            optional: false,
        }
    ],
    "",
    [("Person", "Comment")],
)?;
graph.add_edge_index("Post", "datetime", false)?;
Source

pub fn is_vertex_indexed(&self, label: &str, field: &str) -> Result<bool>

Check if this vertex_label:field is indexed.

§Errors

TODO(eadrenking@outlook.com)

§Examples
use tugraph::{db::OpenOptions, field::{FieldType, FieldSpec}, Error};
use std::{str::FromStr, path::PathBuf};

let galaxy = OpenOptions::new()
    .create(true)
    .open("/tmp/rust_graph/doc/is_vertex_indexed", "admin", "73@TuGraph")?;
let graph = galaxy.open_graph("default", false)?;
graph.add_vertex_label("Person",
   &[
       FieldSpec {
           name: "name".into(),
           ty: FieldType::String,
           optional: false,
       },
       FieldSpec {
           name: "age".into(),
           ty: FieldType::Int8,
           optional: false,
       },
   ],
   "name",
)?;
graph.add_vertex_index("Person", "age", false)?;
let indexed = graph.is_vertex_indexed("Person", "age")?;
assert!(indexed);
Source

pub fn is_edge_indexed(&self, label: &str, field: &str) -> Result<bool>

Check if this edge_label:field is indexed.

§Errors

TODO(eadrenking@outlook.com)

§Examples
use tugraph::{db::OpenOptions, field::{FieldType, FieldSpec}, Error};
use std::{str::FromStr, path::PathBuf};

let galaxy = OpenOptions::new()
    .create(true)
    .open("/tmp/rust_tugraph/doc/is_edge_indexed", "admin", "73@TuGraph")?;
let graph = galaxy.open_graph("default", false)?;
graph.add_vertex_label("Person",
   &[
       FieldSpec {
           name: "name".into(),
           ty: FieldType::String,
           optional: false,
       },
   ],
   "name",
)?;
graph.add_vertex_label("Comment",
   &[
       FieldSpec {
           name: "content".into(),
           ty: FieldType::String,
           optional: false,
       },
   ],
   "content",
)?;
graph.add_edge_label(
    "Post",
    &[
        FieldSpec {
            name: "datetime".into(),
            ty: FieldType::DateTime,
            optional: false,
        }
    ],
    "",
    [("Person", "Comment")],
)?;
graph.add_edge_index("Post", "datetime", false)?;
let indexed = graph.is_edge_indexed("Post", "datetime")?;
assert!(indexed);
Source

pub fn delete_vertex_index(&self, label: &str, field: &str) -> Result<bool>

Deletes the index to ‘vertex_label:field’

§Errors

TODO(eadrenking@outlook.com)

§Examples
use tugraph::{db::OpenOptions, field::{FieldType, FieldSpec}, Error};
use std::{str::FromStr, path::PathBuf};

let galaxy = OpenOptions::new()
    .create(true)
    .open("/tmp/rust_tugraph/doc/delete_vertex_index", "admin", "73@TuGraph")?;
let graph = galaxy.open_graph("default", false)?;
graph.add_vertex_label("Person",
   &[
       FieldSpec {
           name: "name".into(),
           ty: FieldType::String,
           optional: false,
       },
       FieldSpec {
           name: "age".into(),
           ty: FieldType::Int8,
           optional: false,
       },
   ],
   "name",
)?;
graph.add_vertex_index("Person", "age", false)?;
let deleted = graph.delete_vertex_index("Person", "age")?;
assert!(deleted);
Source

pub fn delete_edge_index(&self, label: &str, field: &str) -> Result<bool>

Deletes the index to ‘edge_label:field’

§Errors

TODO(eadrenking@outlook.com)

§Examples
use tugraph::{db::OpenOptions, field::{FieldType, FieldSpec}, Error};
use std::{str::FromStr, path::PathBuf};

let galaxy = OpenOptions::new()
    .create(true)
    .open("/tmp/rust_tugraph/doc/delete_edge_index", "admin", "73@TuGraph")?;
let graph = galaxy.open_graph("default", false)?;
graph.add_vertex_label("Person",
   &[
       FieldSpec {
           name: "name".into(),
           ty: FieldType::String,
           optional: false,
       },
   ],
   "name",
)?;
graph.add_vertex_label("Comment",
   &[
       FieldSpec {
           name: "content".into(),
           ty: FieldType::String,
           optional: false,
       },
   ],
   "content",
)?;
graph.add_edge_label(
    "Post",
    &[
        FieldSpec {
            name: "datetime".into(),
            ty: FieldType::DateTime,
            optional: false,
        }
    ],
    "",
    [("Person", "Comment")],
)?;
graph.add_edge_index("Post", "datetime", false)?;
graph.delete_edge_index("Post", "datetime")?;
Source

pub fn get_description(&self) -> Result<String>

Get graph description

§Errors

TODO(eadrenking@outlook.com)

§Examples
use tugraph::{db::OpenOptions, field::FieldSpec, Error};
use std::{str::FromStr, path::PathBuf};

let galaxy = OpenOptions::new()
    .create(true)
    .open("/tmp/rust_tugraph/doc/get_description", "admin", "73@TuGraph")?;
let graph = galaxy.open_graph("default", true)?;
let desc = graph.get_description()?;
Source

pub fn get_max_size(&self) -> Result<usize>

Get maximum graph size in bytes

§Errors

TODO(eadrenking@outlook.com)

§Examples
use tugraph::{db::OpenOptions, field::FieldSpec, Error};
use std::{str::FromStr, path::PathBuf};

let galaxy = OpenOptions::new()
    .create(true)
    .open("/tmp/rust_tugraph/doc/get_max_size", "admin", "73@TuGraph")?;
let graph = galaxy.open_graph("default", true)?;
let max_size = graph.get_max_size()?;
Source

pub fn add_vertex_full_text_index( &self, label: &str, field: &str, ) -> Result<bool>

Add fulltext index to ‘vertex_label:field’

§Errors

TODO(eadrenking@outlook.com)

§Know issues

There is no public api of tugraph to enable fulltext index enabled. Calling this api always return Error with message “Fulltext index is not enabled”.

§Examples
use tugraph::{db::OpenOptions, field::FieldSpec, Error};
use std::{str::FromStr, path::PathBuf};

let galaxy = OpenOptions::new()
    .create(true)
    .open("/tmp/rust_tugraph/doc/add_vertex_full_text_index", "admin", "73@TuGraph")?;
let graph = galaxy.open_graph("default", false)?;
graph.add_vertex_full_text_index("Comment", "content")?;
Source

pub fn add_edge_full_text_index(&self, label: &str, field: &str) -> Result<bool>

Add fulltext index to ‘edge_label:field’

§Errors

TODO(eadrenking@outlook.com)

§Know issues

There is no public api of tugraph to enable fulltext index enabled. Calling this api always return Error with message “Fulltext index is not enabled”.

§Examples
use tugraph::{db::OpenOptions, field::FieldSpec, Error};
use std::{str::FromStr, path::PathBuf};

let galaxy = OpenOptions::new()
    .create(true)
    .open("/tmp/rust_tugraph/doc/add_edge_full_text_index", "admin", "73@TuGraph")?;
let graph = galaxy.open_graph("default", false)?;
graph.add_edge_full_text_index("Post", "title")?;
Source

pub fn delete_vertex_full_text_index( &self, label: &str, field: &str, ) -> Result<bool>

Delete the fulltext index of ‘vertex_label:field’

§Errors

TODO(eadrenking@outlook.com)

§Examples
use tugraph::{db::OpenOptions, field::FieldSpec, Error};
use std::{str::FromStr, path::PathBuf};

let galaxy = OpenOptions::new()
    .create(true)
    .open("/tmp/rust_tugraph/doc/delete_vertex_full_text_index", "admin", "73@TuGraph")?;
let graph = galaxy.open_graph("default", false)?;
graph.delete_vertex_full_text_index("Comment", "content")?;
Source

pub fn delete_edge_full_text_index( &self, label: &str, field: &str, ) -> Result<bool>

Delete the fulltext index of ‘edge_label:field’

§Errors

TODO(eadrenking@outlook.com)

§Examples
use tugraph::{db::OpenOptions, field::FieldSpec, Error};
use std::{str::FromStr, path::PathBuf};

let galaxy = OpenOptions::new()
    .create(true)
    .open("/tmp/rust_tugraph/doc/delete_edge_full_text_index", "admin", "73@TuGraph")?;
let graph = galaxy.open_graph("default", false)?;
graph.delete_vertex_full_text_index("Post", "title")?;
Source

pub fn rebuild_full_text_index<'a, 'b, V, E>( &self, vertex_labels: V, edge_labels: E, ) -> Result<()>
where V: IntoIterator<Item = &'a str>, E: IntoIterator<Item = &'b str>,

Rebuild the fulltext index of vertex_labels and edge_labels.

§Errors

TODO(eadrenking@outlook.com)

§Know issues

There is no public api of tugraph to enable fulltext index enabled. Calling this api always return Error with message “Fulltext index is not enabled”.

§Examples
use tugraph::{db::OpenOptions, field::FieldSpec, Error};
use std::{str::FromStr, path::PathBuf};

let galaxy = OpenOptions::new()
    .create(true)
    .open("/tmp/rust_tugraph/doc/rebuild_full_text_index", "admin", "73@TuGraph")?;
let graph = galaxy.open_graph("default", false)?;
graph.rebuild_full_text_index(["Comment"], ["Post"])?;
Source

pub fn list_full_text_indexes(&self) -> Result<Vec<ListIndex>>

List fulltext indexes of vertex and edge.

§Errors

TODO(eadrenking@outlook.com)

§Examples
use tugraph::{db::OpenOptions, field::FieldSpec, Error};
use std::{str::FromStr, path::PathBuf};

let galaxy = OpenOptions::new()
    .create(true)
    .open("/tmp/rust_tugraph/doc/list_full_text_indexes", "admin", "73@TuGraph")?;
let graph = galaxy.open_graph("default", true)?;
let full_indexes = graph.list_full_text_indexes()?;
Source

pub fn query_vertex_by_full_text_index( &self, label: &str, query: &str, topn: i32, ) -> Result<Vec<QueryVertexFTIndex>>

Query vertex by fulltext index by using Lucene query syntax and return top n data.

See the Lucene Query Syntax for details

§Errors

TODO(eadrenking@outlook.com)

§Examples
use tugraph::{db::OpenOptions, field::FieldSpec, Error};
use std::{str::FromStr, path::PathBuf};

let galaxy = OpenOptions::new()
    .create(true)
    .open("/tmp/rust_tugraph/doc/query_vertex_by_full_text_index", "admin", "73@TuGraph")?;
let graph = galaxy.open_graph("default", true)?;
let data = graph.query_vertex_by_full_text_index("Comment", "content:nice", 3)?;
Source

pub fn query_edge_by_full_text_index( &self, label: &str, query: &str, topn: i32, ) -> Result<Vec<QueryEdgeFTIndex>>

Query edge by fulltext index by using Lucene query syntax and return top n data.

See the Lucene Query Syntax for details

§Errors

TODO(eadrenking@outlook.com)

§Examples
use tugraph::{db::OpenOptions, field::FieldSpec, Error};
use std::{str::FromStr, path::PathBuf};

let galaxy = OpenOptions::new()
    .create(true)
    .open("/tmp/rust_tugraph/doc/query_edge_by_full_text_index", "admin", "73@TuGraph")?;
let graph = galaxy.open_graph("default", true)?;
let data = graph.query_edge_by_full_text_index("Post", "date:[20020101 TO 20030101]", 3)?;

Trait Implementations§

Source§

impl Sync for Graph<'_>

Auto Trait Implementations§

§

impl<'gl> Freeze for Graph<'gl>

§

impl<'gl> RefUnwindSafe for Graph<'gl>

§

impl<'gl> !Send for Graph<'gl>

§

impl<'gl> Unpin for Graph<'gl>

§

impl<'gl> UnwindSafe for Graph<'gl>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.