-
Notifications
You must be signed in to change notification settings - Fork 7
/
query_experimental.go
77 lines (67 loc) · 2.24 KB
/
query_experimental.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
package tiledb
/*
#include <tiledb/tiledb.h>
#include <tiledb/tiledb_experimental.h>
#include <stdlib.h>
*/
import "C"
import (
"fmt"
)
// QueryStatusDetails contains detailed information about the query status
type QueryStatusDetails struct {
IncompleteReason QueryStatusDetailsReason
}
func (q *Query) RelevantFragmentNum() (uint64, error) {
var num C.uint64_t
if ret := C.tiledb_query_get_relevant_fragment_num(q.context.tiledbContext, q.tiledbQuery, &num); ret != C.TILEDB_OK {
return 0, fmt.Errorf("Error getting relevant fragment num from query: %s", q.context.LastError())
}
return uint64(num), nil
}
// StatusDetails returns extended query status details.
func (q *Query) StatusDetails() (QueryStatusDetails, error) {
var details QueryStatusDetails
var cDetails C.tiledb_query_status_details_t
if ret := C.tiledb_query_get_status_details(q.context.tiledbContext, q.tiledbQuery, &cDetails); ret != C.TILEDB_OK {
return details, fmt.Errorf("Error getting query status details: %s", q.context.LastError())
}
details.IncompleteReason = QueryStatusDetailsReason(cDetails.incomplete_reason)
return details, nil
}
// GetPlan returns a json encoding of the query plan for the query.
// Example:
//
// {
// "TileDB Query Plan": {
// "Array.Type": "sparse",
// "Array.URI": "file:///tmp/TestHandleQueryPlanRequest732268097/001/t-testhandlequeryplanrequest-b757271e",
// "Query.Attributes": [
// "a1",
// "a2",
// "a3",
// "a4",
// "a5"
// ],
// "Query.Dimensions": [
// "dim1"
// ],
// "Query.Layout": "unordered",
// "Query.Strategy.Name": "UnorderedWriter",
// "VFS.Backend": "file"
// }
// }
func (q *Query) GetPlan() (string, error) {
var plan *C.tiledb_string_t
ret := C.tiledb_query_get_plan(q.context.tiledbContext, q.tiledbQuery, &plan)
if ret != C.TILEDB_OK {
return "", fmt.Errorf("Error getting query plan: %s", q.context.LastError())
}
var sPlan *C.char
var sPlanSize C.size_t
ret = C.tiledb_string_view(plan, &sPlan, &sPlanSize)
if ret != C.TILEDB_OK {
return "", fmt.Errorf("Error extracting query query: %s", q.context.LastError())
}
return C.GoStringN(sPlan, C.int(sPlanSize)), nil
}