You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/docs/core/basics.md
+2-3Lines changed: 2 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -22,9 +22,8 @@ An indexing flow involves source data and transformed data (either as an interme
22
22
Each piece of data has a **data type**, falling into one of the following categories:
23
23
24
24
* Basic type.
25
-
* Composite type
26
-
* Struct: a collection of **fields**, each with a name and a type.
27
-
* Table: a collection of **rows**, each of which is a struct with specified schema.
25
+
* Struct type: a collection of **fields**, each with a name and a type.
26
+
* Collection type: a collection of **rows**, each of which is a struct with specified schema. A collection type can be a table (which has a key field) or a list (ordered but without key field).
28
27
29
28
An indexing flow always has a top-level struct, containing all data within and managed by the flow.
| json |`cocoindex.typing.Json`| Any type convertible to JSON by `json` package |
29
29
30
30
For some types, CocoIndex Python SDK provides annotated types with finer granularity than Python's original type, e.g. `Float32` and `Float64` for `float`, and `vector` has dimension information.
31
31
32
32
When defining [custom functions](/docs/core/custom_function), use the specific types as type annotations for arguments and return values.
33
33
So CocoIndex will have information about the specific type.
34
34
35
-
### Struct
35
+
### Struct Type
36
36
37
37
A struct has a bunch of fields, each with a name and a type.
38
38
39
-
### Table
39
+
In Python, a struct type is represented by a [dataclass](https://docs.python.org/3/library/dataclasses.html),
40
+
and all fields must be annotated with a specific type. For example:
40
41
41
-
A table has a collection of rows, each of which is a struct with specified schema.
42
+
```python
43
+
from dataclasses import dataclass
42
44
43
-
The first field of a table is always the primary key.
45
+
@dataclass
46
+
classOrder:
47
+
order_id: str
48
+
name: str
49
+
price: float
50
+
```
44
51
45
-
:::note
52
+
### Collection Types
46
53
47
-
CocoIndex will support functions taking struct and table types as arguments or returning composite types soon.
48
-
We'll update this section with corresponding Python types by then.
54
+
A collection type models a collection of rows, each of which is a struct with specific schema.
49
55
50
-
:::
56
+
We have two specific types of collection:
57
+
58
+
| Type | Description |Type in Python | Original Type in Python |
0 commit comments