# hybridse::vm::LocalTablet

`#include <engine.h>`

Local tablet is responsible to run a task locally.

## Summary

```cpp
class hybridse::vm::LocalTablet;
```

Local tablet is responsible to run a task locally.

Local tablet won't invoke rpc to run a task remotely.

| Public functions                                                                                                                                                                                                                                                                                                                                                                                          |                                                                                                                                                                 |
| --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [**LocalTablet**](#function-localtablet)([hybridse::vm::Engine](https://tobe.gitbook.io/hybridsql/hybridse/shi-yong-wen-dang/c++-api-wen-dang/classes/classhybridse_1_1vm_1_1_engine) \* engine, std::shared\_ptr< [hybridse::vm::CompileInfoCache](https://tobe.gitbook.io/hybridsql/hybridse/shi-yong-wen-dang/c++-api-wen-dang/classes/classhybridse_1_1vm_1_1_compile_info_cache) > sp\_cache)        |                                                                                                                                                                 |
| [**\~LocalTablet**](#function-~localtablet)()                                                                                                                                                                                                                                                                                                                                                             |                                                                                                                                                                 |
| [**SubQuery**](#function-subquery)(uint32\_t task\_id, const std::string & db, const std::string & sql, const [Row](https://tobe.gitbook.io/hybridsql/hybridse/shi-yong-wen-dang/c++-api-wen-dang/classes/classhybridse_1_1codec_1_1_row) & row, const bool is\_procedure, const bool is\_debug) override                                                                                                 | std::shared\_ptr< [RowHandler](https://tobe.gitbook.io/hybridsql/hybridse/shi-yong-wen-dang/c++-api-wen-dang/classes/classhybridse_1_1vm_1_1_row_handler) >     |
| [**SubQuery**](#function-subquery)(uint32\_t task\_id, const std::string & db, const std::string & sql, const std::set< size\_t > & common\_column\_indices, const std::vector< [Row](https://tobe.gitbook.io/hybridsql/hybridse/shi-yong-wen-dang/c++-api-wen-dang/classes/classhybridse_1_1codec_1_1_row) > & in\_rows, const bool request\_is\_common, const bool is\_procedure, const bool is\_debug) | std::shared\_ptr< [TableHandler](https://tobe.gitbook.io/hybridsql/hybridse/shi-yong-wen-dang/c++-api-wen-dang/classes/classhybridse_1_1vm_1_1_table_handler) > |
| [**GetName**](#function-getname)() const                                                                                                                                                                                                                                                                                                                                                                  | <p>const std::string &<br>Return the name of tablet.</p>                                                                                                        |

## Inherited members

Inherited from [hybridse::vm::Tablet](https://tobe.gitbook.io/hybridsql/hybridse/shi-yong-wen-dang/c++-api-wen-dang/classes/classhybridse_1_1vm_1_1_tablet)

| Inherited Public functions                                                                                                                      |   |
| ----------------------------------------------------------------------------------------------------------------------------------------------- | - |
| [**Tablet**](https://tobe.gitbook.io/hybridsql/hybridse/shi-yong-wen-dang/c++-api-wen-dang/classhybridse_1_1vm_1_1_tablet#function-tablet)()    |   |
| [**\~Tablet**](https://tobe.gitbook.io/hybridsql/hybridse/shi-yong-wen-dang/c++-api-wen-dang/classhybridse_1_1vm_1_1_tablet#function-~tablet)() |   |

## Public Functions

#### function LocalTablet

```cpp
inline explicit LocalTablet(
    hybridse::vm::Engine * engine,
    std::shared_ptr< hybridse::vm::CompileInfoCache > sp_cache
)
```

#### function \~LocalTablet

```cpp
inline ~LocalTablet()
```

#### function SubQuery

```cpp
virtual std::shared_ptr< RowHandler > SubQuery(
    uint32_t task_id,
    const std::string & db,
    const std::string & sql,
    const Row & row,
    const bool is_procedure,
    const bool is_debug
) override
```

**Parameters**:

* **task\_id** id of task
* **db** name of database
* **sql** represents a sql string if `is_procedure` is ture, or represents a procedure name
* **row** request row
* **is\_procedure** whether sql is a procedure or not
* **is\_debug** whether printing debug information while running

**Return**: Return query result row as [RowHandler](https://tobe.gitbook.io/hybridsql/hybridse/shi-yong-wen-dang/c++-api-wen-dang/classes/classhybridse_1_1vm_1_1_row_handler) pointer

**Reimplements**: [hybridse::vm::Tablet::SubQuery](https://tobe.gitbook.io/hybridsql/hybridse/shi-yong-wen-dang/c++-api-wen-dang/classhybridse_1_1vm_1_1_tablet#function-subquery)

Run a task in request mode locally

#### function SubQuery

```cpp
virtual std::shared_ptr< TableHandler > SubQuery(
    uint32_t task_id,
    const std::string & db,
    const std::string & sql,
    const std::set< size_t > & common_column_indices,
    const std::vector< Row > & in_rows,
    const bool request_is_common,
    const bool is_procedure,
    const bool is_debug
)
```

**Parameters**:

* **task\_id** id of task
* **db** name of database
* **sql** represents a sql string if `is_procedure` is ture, or represents a procedure name
* **common\_column\_indices** a set of common column indices
* **in\_rows** a batch of request rows
* **request\_is\_common** whether request is common or not
* **is\_procedure** whether run procedure or not
* **is\_debug** whether printing debug information while running

**Return**: Return query result rows as [TableHandler](https://tobe.gitbook.io/hybridsql/hybridse/shi-yong-wen-dang/c++-api-wen-dang/classes/classhybridse_1_1vm_1_1_table_handler) pointer

**Reimplements**: [hybridse::vm::Tablet::SubQuery](https://tobe.gitbook.io/hybridsql/hybridse/shi-yong-wen-dang/c++-api-wen-dang/classhybridse_1_1vm_1_1_tablet#function-subquery)

Run a task in batch-request mode locally

#### function GetName

```cpp
inline virtual const std::string & GetName() const
```

Return the name of tablet.

**Reimplements**: [hybridse::vm::Tablet::GetName](https://tobe.gitbook.io/hybridsql/hybridse/shi-yong-wen-dang/c++-api-wen-dang/classhybridse_1_1vm_1_1_tablet#function-getname)
