# groonga - An open-source fulltext search engine and column store.

- 日本語

# 7.3.39. `object_inspect`

## 7.3.39.1. Summary

New in version 6.0.0.

`object_inspect` inspects an object. You can confirm details of an object.

For example:

> - If the object is a table, you can confirm the number of records in the table.
> - If the object is a column, you can confirm the type of value of the column.

## 7.3.39.2. Syntax

This command takes only one optional parameter:

    object_inspect [name=null]

## 7.3.39.3. Usage

You can inspect an object in the database specified by `name`:

Execution example:

    table_create Users TABLE_HASH_KEY ShortText
    # [[0, 1337566253.89858, 0.000355720520019531], true]
    load --table Users
    [
    {"_key": "Alice"}
    ]
    # [[0, 1337566253.89858, 0.000355720520019531], 1]
    object_inspect Users
    # [
    #   [
    #     0,
    #     1337566253.89858,
    #     0.000355720520019531
    #   ],
    #   {
    #     "name": "Users",
    #     "n_records": 1,
    #     "value": {
    #       "type": null
    #     },
    #     "key": {
    #       "total_size": 5,
    #       "max_total_size": 4294967295,
    #       "type": {
    #         "size": 4096,
    #         "type": {
    #           "id": 32,
    #           "name": "type"
    #         },
    #         "id": 14,
    #         "name": "ShortText"
    #       }
    #     },
    #     "type": {
    #       "id": 48,
    #       "name": "table:hash_key"
    #     },
    #     "id": 256
    #   }
    # ]

The `object_inspect Users` returns the following information:

> - The name of the table: `"name": Users`
> - The total used key size: `"key": {"total_size": 5}` (`"Alice"` is 5 byte data)
> - The maximum total key size: `"key": {"max_total_size": 4294967295}`
> - and so on.

You can inspect the database by not specifying `name`:

Execution example:

    object_inspect
    # [
    #   [
    #     0,
    #     1337566253.89858,
    #     0.000355720520019531
    #   ],
    #   {
    #     "name_table": {
    #       "name": "",
    #       "n_records": 256,
    #       "value": null,
    #       "key": {
    #         "type": null
    #       },
    #       "type": {
    #         "id": 50,
    #         "name": "table:dat_key"
    #       },
    #       "id": 0
    #     },
    #     "type": {
    #       "id": 55,
    #       "name": "db"
    #     }
    #   }
    # ]

The `object_inspect` returns the following information:

> - The table type for object name management: `"key": {"type": {"name": "table:dat_key"}}`
> - and so on.

## 7.3.39.4. Parameters

This section describes all parameters.

### 7.3.39.4.1. Required parameters

There is no required parameter.

### 7.3.39.4.2. Optional parameters

There is only one optional parameter.

#### 7.3.39.4.2.1. `name`

Specifies the object name to be inspected.

If `name` isn't specified, the database is inspected.

## 7.3.39.5. Return value

The command returns an object (nested key and value pairs) that includes details of the object (such as table) as body:

    [HEADER, object]

See Output format for `HEADER`.

The format of the details is depends on object type. For example, table has key information but function doesn't have key information.

### 7.3.39.5.1. Database

Database inspection returns the following information:

    {
      "type": {
        "id": DATABASE_TYPE_ID,
        "name": DATABASE_TYPE_NAME
      },
      "name_table": DATABASE_NAME_TABLE
    }

#### 7.3.39.5.1.1. `DATABASE_TYPE_ID`

`DATABASE_TYPE_ID` is always `55`.

#### 7.3.39.5.1.2. `DATABASE_TYPE_NAME`

`DATABASE_TYPE_NAME` is always `"db"`.

#### 7.3.39.5.1.3. `DATABASE_NAME_TABLE`

`DATABASE_NAME_TABLE` is a table for managing object names in the database. The table is TABLE_PAT_KEY or TABLE_DAT_KEY. Normally, it's TABLE_DAT_KEY.

See Table for format details.

### 7.3.39.5.2. Table

Table inspection returns the following information:

    {
      "name": TABLE_NAME,
      "type": {
        "id": TABLE_TYPE_ID,
        "name": TABLE_TYPE_NAME
      },
      "key": {
        "type": TABLE_KEY_TYPE,
        "total_size": TABLE_KEY_TOTAL_SIZE
        "max_total_size": TABLE_KEY_MAX_TOTAL_SIZE
      },
      "value": {
        "type": TABLE_VALUE_TYPE,
      },
      "n_records": TABLE_N_RECORDS
    }

There are some exceptions:

> - TABLE_NO_KEY doesn't return key information because it doesn't have key.
> - TABLE_DAT_KEY doesn't return value information because it doesn't have value.

#### 7.3.39.5.2.1. `TABLE_NAME`

The name of the inspected table.

#### 7.3.39.5.2.2. `TABLE_TYPE_ID`

The type ID of the inspected table.

Here is a list of type IDs:

Table type | ID
--- | ---
TABLE_HASH_KEY | `48`
TABLE_PAT_KEY | `49`
TABLE_DAT_KEY | `50`
TABLE_NO_KEY | `51`

#### 7.3.39.5.2.3. `TABLE_TYPE_NAME`

The type name of the inspected table.

Here is a list of type names:

Table type | Name
--- | ---
TABLE_HASH_KEY | `"table:hash_key"`
TABLE_PAT_KEY | `"table:pat_key"`
TABLE_DAT_KEY | `"table:dat_key"`
TABLE_NO_KEY | `"table:no_key"`

#### 7.3.39.5.2.4. `TABLE_KEY_TYPE`

The type of key of the inspected table.

See Type for format details.

#### 7.3.39.5.2.5. `TABLE_KEY_TOTAL_SIZE`

The total key size of the inspected table in bytes.

#### 7.3.39.5.2.6. `TABLE_KEY_MAX_TOTAL_SIZE`

The maximum total key size of the inspected table in bytes.

#### 7.3.39.5.2.7. `TABLE_VALUE_TYPE`

The type of value of the inspected table.

See Type for format details.

#### 7.3.39.5.2.8. `TABLE_N_RECORDS`

The number of records of the inspected table.

It's a 64bit unsigned integer value.

#### 7.3.39.5.2.9. Type

Type inspection returns the following information:

    {
      "id": TYPE_ID,
      "name": TYPE_NAME,
      "type": {
        "id": TYPE_ID_OF_TYPE,
        "name": TYPE_NAME_OF_TYPE
      },
      "size": TYPE_SIZE
    }

#### 7.3.39.5.2.10. `TYPE_ID`

The ID of the inspected type.

Here is an ID list of builtin types:

Type | ID
--- | ---
Bool | `3`
Int8 | `4`
UInt8 | `5`
Int16 | `6`
UInt16 | `7`
Int32 | `8`
UInt32 | `9`
Int64 | `10`
UInt64 | `11`
Float | `12`
Time | `13`
ShortText | `14`
Text | `15`
LongText | `16`
TokyoGeoPoint | `17`
WGS84GeoPoint | `18`

#### 7.3.39.5.2.11. `TYPE_NAME`

The name of the inspected type.

Here is a name list of builtin types:

> - Bool
> - Int8
> - UInt8
> - Int16
> - UInt16
> - Int32
> - UInt32
> - Int64
> - UInt64
> - Float
> - Time
> - ShortText
> - Text
> - LongText
> - TokyoGeoPoint
> - WGS84GeoPoint

#### 7.3.39.5.2.12. `TYPE_ID_OF_TYPE`

`TYPE_ID_OF_TYPE` is always `32`.

#### 7.3.39.5.2.13. `TYPE_NAME_OF_TYPE`

`TYPE_NAME_OF_TYPE` is always `type`.

#### 7.3.39.5.2.14. `TYPE_SIZE`

`TYPE_SIZE` is the size of the inspected type in bytes. If the inspected type is variable size type, the size means the maximum size.