(q string)
| 44 | } |
| 45 | |
| 46 | func (p *Processor) Query(q string) (*service.QueryResult, error) { |
| 47 | p.mutex.Lock() |
| 48 | defer p.mutex.Unlock() |
| 49 | |
| 50 | r := &service.QueryResult{} |
| 51 | |
| 52 | qPtr := C.CString(q) |
| 53 | res := C.execute_query(p.handle, qPtr) |
| 54 | // Convert the cgo memory pointer to a go slice and parse the proto. |
| 55 | err := proto.Unmarshal((*[1 << 31]byte)(unsafe.Pointer(res.data))[:int(res.size)], r) |
| 56 | C.free(unsafe.Pointer(res.data)) |
| 57 | C.free(unsafe.Pointer(qPtr)) |
| 58 | |
| 59 | return r, err |
| 60 | } |
| 61 | |
| 62 | func (p *Processor) Close() { |
| 63 | C.delete_processor(p.handle) |
no test coverage detected