2023-09-12 20:26:03 +00:00
|
|
|
mod helpers;
|
|
|
|
mod parse;
|
2024-06-06 15:40:38 +00:00
|
|
|
use crate::helpers::{new_ds, skip_ok, Test};
|
2023-09-12 20:26:03 +00:00
|
|
|
use parse::Parse;
|
|
|
|
use surrealdb::dbs::Session;
|
|
|
|
use surrealdb::err::Error;
|
|
|
|
use surrealdb::sql::Value;
|
|
|
|
|
|
|
|
#[tokio::test]
|
|
|
|
async fn select_where_mtree_knn() -> Result<(), Error> {
|
|
|
|
let sql = r"
|
|
|
|
CREATE pts:1 SET point = [1,2,3,4];
|
|
|
|
CREATE pts:2 SET point = [4,5,6,7];
|
|
|
|
CREATE pts:3 SET point = [8,9,10,11];
|
2024-04-30 18:09:54 +00:00
|
|
|
DEFINE INDEX mt_pts ON pts FIELDS point MTREE DIMENSION 4 TYPE F32;
|
2023-09-12 20:26:03 +00:00
|
|
|
LET $pt = [2,3,4,5];
|
2024-05-24 13:45:21 +00:00
|
|
|
SELECT id, vector::distance::knn() AS dist FROM pts WHERE point <|2|> $pt;
|
2024-03-05 16:01:17 +00:00
|
|
|
SELECT id FROM pts WHERE point <|2|> $pt EXPLAIN;
|
2023-09-12 20:26:03 +00:00
|
|
|
";
|
|
|
|
let dbs = new_ds().await?;
|
|
|
|
let ses = Session::owner().with_ns("test").with_db("test");
|
|
|
|
let res = &mut dbs.execute(sql, &ses, None).await?;
|
|
|
|
assert_eq!(res.len(), 7);
|
|
|
|
//
|
|
|
|
for _ in 0..5 {
|
|
|
|
let _ = res.remove(0).result?;
|
|
|
|
}
|
|
|
|
let tmp = res.remove(0).result?;
|
|
|
|
let val = Value::parse(
|
|
|
|
"[
|
|
|
|
{
|
|
|
|
id: pts:1,
|
|
|
|
dist: 2f
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: pts:2,
|
|
|
|
dist: 4f
|
|
|
|
}
|
|
|
|
]",
|
|
|
|
);
|
|
|
|
assert_eq!(format!("{:#}", tmp), format!("{:#}", val));
|
|
|
|
let tmp = res.remove(0).result?;
|
|
|
|
let val = Value::parse(
|
|
|
|
"[
|
|
|
|
{
|
|
|
|
detail: {
|
|
|
|
plan: {
|
|
|
|
index: 'mt_pts',
|
2024-05-24 13:45:21 +00:00
|
|
|
operator: '<|2|>',
|
2023-09-12 20:26:03 +00:00
|
|
|
value: [2,3,4,5]
|
|
|
|
},
|
|
|
|
table: 'pts',
|
|
|
|
},
|
|
|
|
operation: 'Iterate Index'
|
2024-03-12 10:48:53 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
detail: {
|
2024-03-28 16:29:55 +00:00
|
|
|
type: 'Memory'
|
2024-03-12 10:48:53 +00:00
|
|
|
},
|
|
|
|
operation: 'Collector'
|
|
|
|
},
|
2023-09-12 20:26:03 +00:00
|
|
|
]",
|
|
|
|
);
|
|
|
|
assert_eq!(format!("{:#}", tmp), format!("{:#}", val));
|
|
|
|
Ok(())
|
|
|
|
}
|
2023-10-26 21:33:06 +00:00
|
|
|
|
|
|
|
#[tokio::test]
|
|
|
|
async fn delete_update_mtree_index() -> Result<(), Error> {
|
|
|
|
let sql = r"
|
|
|
|
CREATE pts:1 SET point = [1,2,3,4];
|
|
|
|
CREATE pts:2 SET point = [4,5,6,7];
|
|
|
|
CREATE pts:3 SET point = [2,3,4,5];
|
2024-04-30 18:09:54 +00:00
|
|
|
DEFINE INDEX mt_pts ON pts FIELDS point MTREE DIMENSION 4 TYPE I32;
|
2023-10-26 21:33:06 +00:00
|
|
|
CREATE pts:4 SET point = [8,9,10,11];
|
|
|
|
DELETE pts:2;
|
|
|
|
UPDATE pts:3 SET point = [12,13,14,15];
|
|
|
|
LET $pt = [2,3,4,5];
|
2024-05-24 13:45:21 +00:00
|
|
|
SELECT id, vector::distance::knn() AS dist FROM pts WHERE point <|5|> $pt ORDER BY dist;
|
2023-10-26 21:33:06 +00:00
|
|
|
";
|
|
|
|
let dbs = new_ds().await?;
|
|
|
|
let ses = Session::owner().with_ns("test").with_db("test");
|
|
|
|
let res = &mut dbs.execute(sql, &ses, None).await?;
|
|
|
|
assert_eq!(res.len(), 9);
|
|
|
|
//
|
|
|
|
for _ in 0..8 {
|
|
|
|
let _ = res.remove(0).result?;
|
|
|
|
}
|
|
|
|
let tmp = res.remove(0).result?;
|
|
|
|
let val = Value::parse(
|
|
|
|
"[
|
|
|
|
{
|
|
|
|
dist: 2f,
|
|
|
|
id: pts:1
|
|
|
|
},
|
|
|
|
{
|
|
|
|
dist: 12f,
|
|
|
|
id: pts:4
|
|
|
|
},
|
|
|
|
{
|
|
|
|
dist: 20f,
|
|
|
|
id: pts:3
|
|
|
|
}
|
|
|
|
]",
|
|
|
|
);
|
|
|
|
assert_eq!(format!("{:#}", tmp), format!("{:#}", val));
|
|
|
|
Ok(())
|
|
|
|
}
|
2023-11-13 16:11:38 +00:00
|
|
|
|
|
|
|
#[tokio::test]
|
|
|
|
async fn index_embedding() -> Result<(), Error> {
|
|
|
|
let sql = r#"
|
2024-03-06 09:29:19 +00:00
|
|
|
DEFINE INDEX idx_mtree_embedding_manhattan ON Document FIELDS items.embedding MTREE DIMENSION 4 DIST MANHATTAN;
|
|
|
|
DEFINE INDEX idx_mtree_embedding_cosine ON Document FIELDS items.embedding MTREE DIMENSION 4 DIST COSINE;
|
2023-11-13 16:11:38 +00:00
|
|
|
CREATE ONLY Document:1 CONTENT {
|
|
|
|
"items": [
|
|
|
|
{
|
|
|
|
"content": "apple",
|
|
|
|
"embedding": [
|
|
|
|
0.009953570552170277, -0.02680361643433571, -0.018817437812685966,
|
|
|
|
-0.08697346597909927
|
|
|
|
]
|
|
|
|
}
|
|
|
|
]
|
|
|
|
};
|
|
|
|
"#;
|
|
|
|
|
|
|
|
let dbs = new_ds().await?;
|
|
|
|
let ses = Session::owner().with_ns("test").with_db("test");
|
|
|
|
let res = &mut dbs.execute(sql, &ses, None).await?;
|
2024-03-06 09:29:19 +00:00
|
|
|
assert_eq!(res.len(), 3);
|
2023-11-13 16:11:38 +00:00
|
|
|
//
|
|
|
|
let _ = res.remove(0).result?;
|
2024-03-06 09:29:19 +00:00
|
|
|
let _ = res.remove(0).result?;
|
2023-11-13 16:11:38 +00:00
|
|
|
//
|
|
|
|
let tmp = res.remove(0).result?;
|
|
|
|
let val = Value::parse(
|
|
|
|
"{
|
|
|
|
id: Document:1,
|
|
|
|
items: [
|
|
|
|
{
|
|
|
|
content: 'apple',
|
|
|
|
embedding: [
|
|
|
|
0.009953570552170277f,
|
|
|
|
-0.02680361643433571f,
|
|
|
|
-0.018817437812685966f,
|
|
|
|
-0.08697346597909927f
|
|
|
|
]
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}",
|
|
|
|
);
|
|
|
|
assert_eq!(format!("{:#}", tmp), format!("{:#}", val));
|
|
|
|
Ok(())
|
|
|
|
}
|
2024-01-09 16:57:52 +00:00
|
|
|
|
|
|
|
#[tokio::test]
|
2024-05-08 14:26:41 +00:00
|
|
|
async fn select_where_brute_force_knn() -> Result<(), Error> {
|
2024-01-09 16:57:52 +00:00
|
|
|
let sql = r"
|
|
|
|
CREATE pts:1 SET point = [1,2,3,4];
|
|
|
|
CREATE pts:2 SET point = [4,5,6,7];
|
|
|
|
CREATE pts:3 SET point = [8,9,10,11];
|
|
|
|
LET $pt = [2,3,4,5];
|
2024-05-08 14:26:41 +00:00
|
|
|
SELECT id FROM pts WHERE point <|2,EUCLIDEAN|> $pt EXPLAIN;
|
2024-05-24 13:45:21 +00:00
|
|
|
SELECT id, vector::distance::knn() AS dist FROM pts WHERE point <|2,EUCLIDEAN|> $pt;
|
|
|
|
SELECT id, vector::distance::knn() AS dist FROM pts WHERE point <|2,EUCLIDEAN|> $pt PARALLEL;
|
2024-01-09 16:57:52 +00:00
|
|
|
";
|
|
|
|
let dbs = new_ds().await?;
|
|
|
|
let ses = Session::owner().with_ns("test").with_db("test");
|
|
|
|
let res = &mut dbs.execute(sql, &ses, None).await?;
|
|
|
|
assert_eq!(res.len(), 7);
|
|
|
|
//
|
2024-06-05 15:21:49 +00:00
|
|
|
skip_ok(res, 4);
|
2024-05-08 14:26:41 +00:00
|
|
|
//
|
2024-01-09 16:57:52 +00:00
|
|
|
let tmp = res.remove(0).result?;
|
|
|
|
let val = Value::parse(
|
|
|
|
"[
|
|
|
|
{
|
|
|
|
detail: {
|
|
|
|
table: 'pts',
|
|
|
|
},
|
|
|
|
operation: 'Iterate Table'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
detail: {
|
|
|
|
reason: 'NO INDEX FOUND'
|
|
|
|
},
|
|
|
|
operation: 'Fallback'
|
2024-03-12 10:48:53 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
detail: {
|
2024-03-28 16:29:55 +00:00
|
|
|
type: 'Memory'
|
2024-03-12 10:48:53 +00:00
|
|
|
},
|
|
|
|
operation: 'Collector'
|
|
|
|
},
|
2024-01-09 16:57:52 +00:00
|
|
|
]",
|
|
|
|
);
|
|
|
|
assert_eq!(format!("{:#}", tmp), format!("{:#}", val));
|
2024-05-08 14:26:41 +00:00
|
|
|
//
|
|
|
|
for i in 0..2 {
|
|
|
|
let tmp = res.remove(0).result?;
|
|
|
|
let val = Value::parse(
|
|
|
|
"[
|
|
|
|
{
|
|
|
|
id: pts:1,
|
|
|
|
dist: 2f
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: pts:2,
|
|
|
|
dist: 4f
|
|
|
|
}
|
|
|
|
]",
|
|
|
|
);
|
|
|
|
assert_eq!(format!("{:#}", tmp), format!("{:#}", val), "{i}");
|
|
|
|
}
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
|
|
|
#[tokio::test]
|
|
|
|
async fn select_where_hnsw_knn() -> Result<(), Error> {
|
|
|
|
let sql = r"
|
|
|
|
CREATE pts:1 SET point = [1,2,3,4];
|
|
|
|
CREATE pts:2 SET point = [4,5,6,7];
|
|
|
|
CREATE pts:3 SET point = [8,9,10,11];
|
|
|
|
DEFINE INDEX hnsw_pts ON pts FIELDS point HNSW DIMENSION 4 DIST EUCLIDEAN TYPE F32 EFC 500 M 12;
|
|
|
|
LET $pt = [2,3,4,5];
|
2024-05-24 13:45:21 +00:00
|
|
|
SELECT id, vector::distance::knn() AS dist FROM pts WHERE point <|2,100|> $pt;
|
2024-06-06 15:40:38 +00:00
|
|
|
SELECT id, vector::distance::knn() AS dist FROM pts WHERE point <|2,100|> $pt EXPLAIN;
|
|
|
|
SELECT id, vector::distance::knn() AS dist FROM pts WHERE point <|2,EUCLIDEAN|> $pt;
|
|
|
|
SELECT id, vector::distance::knn() AS dist FROM pts WHERE point <|2,EUCLIDEAN|> $pt EXPLAIN;
|
2024-05-08 14:26:41 +00:00
|
|
|
";
|
2024-06-06 15:40:38 +00:00
|
|
|
let mut t = Test::try_new(sql).await?;
|
|
|
|
t.skip_ok(5);
|
|
|
|
// KNN result with HNSW index
|
|
|
|
t.expect_val(
|
2024-05-08 14:26:41 +00:00
|
|
|
"[
|
|
|
|
{
|
|
|
|
id: pts:1,
|
|
|
|
dist: 2f
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: pts:2,
|
|
|
|
dist: 4f
|
|
|
|
}
|
|
|
|
]",
|
|
|
|
);
|
2024-06-06 15:40:38 +00:00
|
|
|
// Explains KNN with HNSW index
|
|
|
|
t.expect_val(
|
2024-05-08 14:26:41 +00:00
|
|
|
"[
|
|
|
|
{
|
|
|
|
detail: {
|
|
|
|
plan: {
|
|
|
|
index: 'hnsw_pts',
|
2024-05-24 13:45:21 +00:00
|
|
|
operator: '<|2,100|>',
|
2024-05-08 14:26:41 +00:00
|
|
|
value: [2,3,4,5]
|
|
|
|
},
|
|
|
|
table: 'pts',
|
|
|
|
},
|
|
|
|
operation: 'Iterate Index'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
detail: {
|
|
|
|
type: 'Memory'
|
|
|
|
},
|
|
|
|
operation: 'Collector'
|
|
|
|
}
|
|
|
|
]",
|
|
|
|
);
|
2024-06-06 15:40:38 +00:00
|
|
|
// KNN result with brute force
|
|
|
|
t.expect_val(
|
|
|
|
"[
|
|
|
|
{
|
|
|
|
id: pts:1,
|
|
|
|
dist: 2f
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: pts:2,
|
|
|
|
dist: 4f
|
|
|
|
}
|
|
|
|
]",
|
|
|
|
);
|
|
|
|
// Explain KNN with brute force
|
|
|
|
t.expect_val(
|
|
|
|
"[
|
|
|
|
{
|
|
|
|
detail: {
|
|
|
|
table: 'pts'
|
|
|
|
},
|
|
|
|
operation: 'Iterate Table'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
detail: {
|
|
|
|
reason: 'NO INDEX FOUND'
|
|
|
|
},
|
|
|
|
operation: 'Fallback'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
detail: {
|
|
|
|
type: 'Memory'
|
|
|
|
},
|
|
|
|
operation: 'Collector'
|
|
|
|
}
|
|
|
|
]",
|
|
|
|
);
|
2024-01-09 16:57:52 +00:00
|
|
|
Ok(())
|
|
|
|
}
|
2024-05-24 13:45:21 +00:00
|
|
|
|
|
|
|
#[tokio::test]
|
|
|
|
async fn select_mtree_knn_with_condition() -> Result<(), Error> {
|
|
|
|
let sql = r"
|
|
|
|
DEFINE INDEX mt_pt1 ON pts FIELDS point MTREE DIMENSION 1;
|
|
|
|
INSERT INTO pts [
|
|
|
|
{ id: pts:1, point: [ 10f ], flag: true },
|
|
|
|
{ id: pts:2, point: [ 20f ], flag: false },
|
|
|
|
{ id: pts:3, point: [ 30f ], flag: true },
|
|
|
|
{ id: pts:4, point: [ 40f ], flag: false },
|
|
|
|
{ id: pts:5, point: [ 50f ], flag: true },
|
|
|
|
{ id: pts:6, point: [ 60f ], flag: false },
|
|
|
|
{ id: pts:7, point: [ 70f ], flag: true }
|
|
|
|
];
|
|
|
|
LET $pt = [44f];
|
|
|
|
SELECT id, flag, vector::distance::knn() AS distance FROM pts
|
|
|
|
WHERE flag = true && point <|2|> $pt
|
|
|
|
ORDER BY distance EXPLAIN;
|
|
|
|
SELECT id, flag, vector::distance::knn() AS distance FROM pts
|
|
|
|
WHERE flag = true && point <|2|> $pt
|
|
|
|
ORDER BY distance;
|
|
|
|
";
|
|
|
|
let dbs = new_ds().await?;
|
|
|
|
let ses = Session::owner().with_ns("test").with_db("test");
|
|
|
|
let mut res = &mut dbs.execute(sql, &ses, None).await?;
|
|
|
|
assert_eq!(res.len(), 5);
|
|
|
|
//
|
2024-06-05 15:21:49 +00:00
|
|
|
skip_ok(&mut res, 3);
|
2024-05-24 13:45:21 +00:00
|
|
|
//
|
|
|
|
let tmp = res.remove(0).result?;
|
|
|
|
let val = Value::parse(
|
|
|
|
"[
|
|
|
|
{
|
|
|
|
detail: {
|
|
|
|
plan: {
|
|
|
|
index: 'mt_pt1',
|
|
|
|
operator: '<|2|>',
|
|
|
|
value: [44f]
|
|
|
|
},
|
|
|
|
table: 'pts',
|
|
|
|
},
|
|
|
|
operation: 'Iterate Index'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
detail: {
|
|
|
|
type: 'Memory'
|
|
|
|
},
|
|
|
|
operation: 'Collector'
|
|
|
|
}
|
|
|
|
]",
|
|
|
|
);
|
|
|
|
assert_eq!(format!("{:#}", tmp), format!("{:#}", val));
|
|
|
|
//
|
|
|
|
let tmp = res.remove(0).result?;
|
|
|
|
let val = Value::parse(
|
|
|
|
"[
|
|
|
|
{
|
|
|
|
id: pts:5,
|
|
|
|
flag: true,
|
|
|
|
distance: 6f
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: pts:3,
|
|
|
|
flag: true,
|
|
|
|
distance: 14f
|
|
|
|
}
|
|
|
|
]",
|
|
|
|
);
|
|
|
|
assert_eq!(format!("{:#}", tmp), format!("{:#}", val));
|
|
|
|
//
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test_log::test(tokio::test)]
|
|
|
|
async fn select_hnsw_knn_with_condition() -> Result<(), Error> {
|
|
|
|
let sql = r"
|
|
|
|
DEFINE INDEX hn_pt1 ON pts FIELDS point HNSW DIMENSION 1;
|
|
|
|
INSERT INTO pts [
|
|
|
|
{ id: pts:1, point: [ 10f ], flag: true },
|
|
|
|
{ id: pts:2, point: [ 20f ], flag: false },
|
|
|
|
{ id: pts:3, point: [ 30f ], flag: true },
|
|
|
|
{ id: pts:4, point: [ 40f ], flag: false },
|
|
|
|
{ id: pts:5, point: [ 50f ], flag: true },
|
|
|
|
{ id: pts:6, point: [ 60f ], flag: false },
|
|
|
|
{ id: pts:7, point: [ 70f ], flag: true }
|
|
|
|
];
|
|
|
|
LET $pt = [44f];
|
|
|
|
SELECT id, flag, vector::distance::knn() AS distance FROM pts
|
|
|
|
WHERE flag = true AND point <|2,40|> $pt
|
|
|
|
ORDER BY distance EXPLAIN;
|
|
|
|
SELECT id, flag, vector::distance::knn() AS distance FROM pts
|
|
|
|
WHERE flag = true AND point <|2,40|> $pt
|
|
|
|
ORDER BY distance;
|
|
|
|
";
|
|
|
|
let dbs = new_ds().await?;
|
|
|
|
let ses = Session::owner().with_ns("test").with_db("test");
|
|
|
|
let mut res = &mut dbs.execute(sql, &ses, None).await?;
|
|
|
|
assert_eq!(res.len(), 5);
|
|
|
|
//
|
2024-06-05 15:21:49 +00:00
|
|
|
skip_ok(&mut res, 3);
|
2024-05-24 13:45:21 +00:00
|
|
|
//
|
|
|
|
let tmp = res.remove(0).result?;
|
|
|
|
let val = Value::parse(
|
|
|
|
"[
|
|
|
|
{
|
|
|
|
detail: {
|
|
|
|
plan: {
|
|
|
|
index: 'hn_pt1',
|
|
|
|
operator: '<|2,40|>',
|
|
|
|
value: [44f]
|
|
|
|
},
|
|
|
|
table: 'pts',
|
|
|
|
},
|
|
|
|
operation: 'Iterate Index'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
detail: {
|
|
|
|
type: 'Memory'
|
|
|
|
},
|
|
|
|
operation: 'Collector'
|
|
|
|
}
|
|
|
|
]",
|
|
|
|
);
|
|
|
|
assert_eq!(format!("{:#}", tmp), format!("{:#}", val));
|
|
|
|
//
|
|
|
|
let tmp = res.remove(0).result?;
|
|
|
|
let val = Value::parse(
|
|
|
|
"[
|
|
|
|
{
|
|
|
|
distance: 6f,
|
|
|
|
flag: true,
|
|
|
|
id: pts:5
|
|
|
|
},
|
|
|
|
{
|
|
|
|
distance: 14f,
|
|
|
|
flag: true,
|
|
|
|
id: pts:3
|
|
|
|
}
|
|
|
|
]",
|
|
|
|
);
|
|
|
|
assert_eq!(format!("{:#}", tmp), format!("{:#}", val));
|
|
|
|
//
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test_log::test(tokio::test)]
|
|
|
|
async fn select_bruteforce_knn_with_condition() -> Result<(), Error> {
|
|
|
|
let sql = r"
|
|
|
|
INSERT INTO pts [
|
|
|
|
{ id: pts:1, point: [ 10f ], flag: true },
|
|
|
|
{ id: pts:2, point: [ 20f ], flag: false },
|
|
|
|
{ id: pts:3, point: [ 30f ], flag: true },
|
|
|
|
{ id: pts:4, point: [ 40f ], flag: false },
|
|
|
|
{ id: pts:5, point: [ 50f ], flag: true },
|
|
|
|
{ id: pts:6, point: [ 60f ], flag: false },
|
|
|
|
{ id: pts:7, point: [ 70f ], flag: true }
|
|
|
|
];
|
|
|
|
LET $pt = [44f];
|
|
|
|
SELECT id, flag, vector::distance::knn() AS distance FROM pts
|
|
|
|
WHERE flag = true AND point <|2,EUCLIDEAN|> $pt
|
|
|
|
ORDER BY distance EXPLAIN;
|
|
|
|
SELECT id, flag, vector::distance::knn() AS distance FROM pts
|
|
|
|
WHERE flag = true AND point <|2,EUCLIDEAN|> $pt
|
|
|
|
ORDER BY distance;
|
|
|
|
";
|
|
|
|
let dbs = new_ds().await?;
|
|
|
|
let ses = Session::owner().with_ns("test").with_db("test");
|
|
|
|
let mut res = &mut dbs.execute(sql, &ses, None).await?;
|
|
|
|
assert_eq!(res.len(), 4);
|
|
|
|
//
|
2024-06-05 15:21:49 +00:00
|
|
|
skip_ok(&mut res, 2);
|
2024-05-24 13:45:21 +00:00
|
|
|
//
|
|
|
|
let tmp = res.remove(0).result?;
|
|
|
|
let val = Value::parse(
|
|
|
|
"[
|
|
|
|
{
|
|
|
|
detail: {
|
|
|
|
table: 'pts'
|
|
|
|
},
|
|
|
|
operation: 'Iterate Table'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
detail: {
|
|
|
|
reason: 'NO INDEX FOUND'
|
|
|
|
},
|
|
|
|
operation: 'Fallback'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
detail: {
|
|
|
|
type: 'Memory'
|
|
|
|
},
|
|
|
|
operation: 'Collector'
|
|
|
|
}
|
|
|
|
]",
|
|
|
|
);
|
|
|
|
assert_eq!(format!("{:#}", tmp), format!("{:#}", val));
|
|
|
|
//
|
|
|
|
let tmp = res.remove(0).result?;
|
|
|
|
let val = Value::parse(
|
|
|
|
"[
|
|
|
|
{
|
|
|
|
distance: 6f,
|
|
|
|
flag: true,
|
|
|
|
id: pts:5
|
|
|
|
},
|
|
|
|
{
|
|
|
|
distance: 14f,
|
|
|
|
flag: true,
|
|
|
|
id: pts:3
|
|
|
|
}
|
|
|
|
]",
|
|
|
|
);
|
|
|
|
assert_eq!(format!("{:#}", tmp), format!("{:#}", val));
|
|
|
|
//
|
|
|
|
Ok(())
|
|
|
|
}
|