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>
impl<'gl> Graph<'gl>
Sourcepub unsafe fn from_ptr(ptr: *mut lgraph_api_graph_db_t) -> Graph<'gl>
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
Sourcepub fn create_ro_txn(&self) -> Result<RoTxn<'_>>
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()?;Sourcepub fn create_rw_txn(&self, optimistic: bool) -> Result<RwTxn<'_>>
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)?;Sourcepub fn fork_ro_txn(&self, txn: &RoTxn<'_>) -> Result<RoTxn<'_>>
👎Deprecated: transaction is not Send and cannot be used in Arc
pub fn fork_ro_txn(&self, txn: &RoTxn<'_>) -> Result<RoTxn<'_>>
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");
});
});
Sourcepub fn flush(&self) -> Result<()>
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()?;Sourcepub fn drop_all_data(&self) -> Result<()>
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()?;Sourcepub fn drop_all_vertex(&self) -> Result<()>
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()?;Sourcepub fn estimate_num_vertices(&self) -> Result<usize>
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()?;Sourcepub fn add_vertex_label<'a, T>(
&self,
label: &str,
field_specs: T,
primary_field: &str,
) -> Result<bool>where
T: IntoIterator<Item = &'a FieldSpec>,
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",)?;Sourcepub fn delete_vertex_label(&self, label: &str) -> Result<(bool, usize)>
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")?;Sourcepub fn alter_vertex_label_del_fields<'a, T>(
&self,
label: &str,
del_fields: T,
) -> Result<(bool, usize)>where
T: IntoIterator<Item = &'a str>,
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"])?;Sourcepub fn alter_vertex_label_add_fields<'a, 'b, T, D>(
&self,
label: &str,
add_fields: T,
default_values: D,
) -> Result<(bool, usize)>
pub fn alter_vertex_label_add_fields<'a, 'b, T, D>( &self, label: &str, add_fields: T, default_values: D, ) -> Result<(bool, usize)>
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)],
)?;Sourcepub fn alter_vertex_label_mod_fields<'a, T>(
&self,
label: &str,
mod_fields: T,
) -> Result<(bool, usize)>where
T: IntoIterator<Item = &'a FieldSpec>,
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,
},
],
)?;Sourcepub fn add_edge_label<'a, 'b, 'c, U, C>(
&self,
label: &str,
field_specs: U,
temporal_field: &str,
edge_constraints: C,
) -> Result<bool>
pub fn add_edge_label<'a, 'b, 'c, U, C>( &self, label: &str, field_specs: U, temporal_field: &str, edge_constraints: C, ) -> Result<bool>
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")],
)?;Sourcepub fn delete_edge_label(&self, label: &str) -> Result<(bool, usize)>
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")?;Sourcepub fn alter_label_mod_edge_constraints<'a, 'b, 'c, U>(
&self,
label: &str,
constraints: U,
) -> Result<bool>
pub fn alter_label_mod_edge_constraints<'a, 'b, 'c, U>( &self, label: &str, constraints: U, ) -> Result<bool>
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")])?;Sourcepub fn alter_edge_label_del_fields<'a, T>(
&self,
label: &str,
del_fields: T,
) -> Result<(bool, usize)>where
T: IntoIterator<Item = &'a str>,
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"])?;Sourcepub fn alter_edge_label_add_fields<'a, 'b, U, D>(
&self,
label: &str,
add_fields: U,
default_values: D,
) -> Result<(bool, usize)>
pub fn alter_edge_label_add_fields<'a, 'b, U, D>( &self, label: &str, add_fields: U, default_values: D, ) -> Result<(bool, usize)>
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())],
)?;Sourcepub fn alter_edge_label_mod_fields<'a, T>(
&self,
label: &str,
mod_fields: T,
) -> Result<(bool, usize)>where
T: IntoIterator<Item = &'a FieldSpec>,
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,
},
],
)?;Sourcepub fn add_vertex_index(
&self,
label: &str,
field: &str,
is_unique: bool,
) -> Result<bool>
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)?;Sourcepub fn add_edge_index(
&self,
label: &str,
field: &str,
is_unique: bool,
) -> Result<bool>
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)?;Sourcepub fn is_vertex_indexed(&self, label: &str, field: &str) -> Result<bool>
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);Sourcepub fn is_edge_indexed(&self, label: &str, field: &str) -> Result<bool>
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);Sourcepub fn delete_vertex_index(&self, label: &str, field: &str) -> Result<bool>
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);Sourcepub fn delete_edge_index(&self, label: &str, field: &str) -> Result<bool>
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")?;Sourcepub fn get_description(&self) -> Result<String>
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()?;Sourcepub fn get_max_size(&self) -> Result<usize>
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()?;Sourcepub fn add_vertex_full_text_index(
&self,
label: &str,
field: &str,
) -> Result<bool>
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")?;Sourcepub fn add_edge_full_text_index(&self, label: &str, field: &str) -> Result<bool>
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")?;Sourcepub fn delete_vertex_full_text_index(
&self,
label: &str,
field: &str,
) -> Result<bool>
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")?;Sourcepub fn delete_edge_full_text_index(
&self,
label: &str,
field: &str,
) -> Result<bool>
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")?;Sourcepub fn rebuild_full_text_index<'a, 'b, V, E>(
&self,
vertex_labels: V,
edge_labels: E,
) -> Result<()>
pub fn rebuild_full_text_index<'a, 'b, V, E>( &self, vertex_labels: V, edge_labels: E, ) -> Result<()>
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"])?;Sourcepub fn list_full_text_indexes(&self) -> Result<Vec<ListIndex>>
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()?;Sourcepub fn query_vertex_by_full_text_index(
&self,
label: &str,
query: &str,
topn: i32,
) -> Result<Vec<QueryVertexFTIndex>>
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)?;Sourcepub fn query_edge_by_full_text_index(
&self,
label: &str,
query: &str,
topn: i32,
) -> Result<Vec<QueryEdgeFTIndex>>
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)?;