|
| 1 | +# Namespace Concepts |
| 2 | + |
| 3 | +## Namespace Definition |
| 4 | + |
| 5 | +A Lance namespace is a centralized repository for discovering, organizing, and managing Lance tables. |
| 6 | +It can either contain a collection of tables, or a collection of Lance namespaces recursively. |
| 7 | +It is designed to encapsulates concepts including namespace, metastore, database, schema, etc. |
| 8 | +that frequently appear in other similar data systems to allow easy integration with any system of any type of object hierarchy. |
| 9 | + |
| 10 | +Here is an example layout of a Lance namespace: |
| 11 | + |
| 12 | + |
| 13 | + |
| 14 | +## Parent & Child |
| 15 | + |
| 16 | +We use the term **parent** and **child** to describe relationship between 2 objects. |
| 17 | +If namespace A directly contains B, then A is the parent namespace of B, i.e. B is a child of A. |
| 18 | +For examples: |
| 19 | + |
| 20 | +- Namespace `ns1` contains a **child namespace** `ns4`. i.e. `ns1` is the **parent namespace** of `ns4`. |
| 21 | +- Namespace `ns2` contains a **child table** `t2`, i.e. `t2` belongs to **parent namespace** `ns2`. |
| 22 | + |
| 23 | +## Root Namespace |
| 24 | + |
| 25 | +A root namespace is a namespace that has no parent. |
| 26 | +The root namespace is assumed to always exist and is ready to be connected to by a tool to explore objects in the namespace. |
| 27 | +The lifecycle management (e.g. creation, deletion) of the root namespace is out of scope of this specification. |
| 28 | + |
| 29 | +## Object Name |
| 30 | + |
| 31 | +The **name** of an object is a string that uniquely identifies the object within the parent namespace it belongs to. |
| 32 | +The name of any object must be unique among all other objects that share the same parent namespace. |
| 33 | +For examples: |
| 34 | + |
| 35 | +- `cat2`, `cat3` and `cat4` are all unique names under the root namespace |
| 36 | +- `t3` and `t4` are both unique names under `cat4` |
| 37 | + |
| 38 | +## Object Identifier |
| 39 | + |
| 40 | +The **identifier** of an object uniquely identifies the object within the root namespace it belongs to. |
| 41 | +The identifier of any object must be unique among all other objects that share the same root namespace. |
| 42 | + |
| 43 | +Based on the uniqueness property of an object name within its parent namespace, |
| 44 | +an object identifier is the list of object names starting from (not including) the root namespace to (including) the object itself. |
| 45 | +This is also called an **list identifier**. |
| 46 | +For examples: |
| 47 | + |
| 48 | +- the list identifier of `cat5` is `[cat2, cat5]` |
| 49 | +- the list identifier of `t1` is `[cat2, cat5, t1]` |
| 50 | + |
| 51 | +The dot (`.`) symbol is typically used as the delimiter to join all the names to form an **string identifier**, |
| 52 | +but other symbols could also be used if dot is used in the object name. |
| 53 | +For examples: |
| 54 | + |
| 55 | +- the string identifier of `cat5` is `cat2.cat5` |
| 56 | +- the string identifier of `t1` is `cat2.cat5.t1` |
| 57 | +- the string identifier of `t3` is `cat4$t3` when using delimiter `$` |
| 58 | + |
| 59 | +## Name and Identifier for Root Namespace |
| 60 | + |
| 61 | +The root namespace itself has no name or identifier. |
| 62 | +When represented in code, its name and string identifier is represented by an empty or null string, |
| 63 | +and its list identifier is represented by an empty or null list. |
| 64 | + |
| 65 | +The actual name and identifier of the root namespace is typically |
| 66 | +assigned by users through some configuration when used in a tool. |
| 67 | +For example, a root namespace can be called `cat1` in Ray, but called `cat2` in Apache Spark, |
| 68 | +and they are both configured to connect to the same root namespace. |
| 69 | + |
| 70 | +## Namespace Level |
| 71 | + |
| 72 | +If every table has the same number of namespaces all the way to the root namespace, |
| 73 | +the namespace is called **leveled**. The [example above](#namespace-definition) is not leveled |
| 74 | +because `t1` has 2 namespaces `ns1` and `ns4` before root, whereas `t2` has 1 namespace `ns2` before root. |
| 75 | + |
| 76 | +For a leveled namespace, the number of namespaces up to and including the root for any table |
| 77 | +is referred to as the **number of levels**. |
| 78 | +For example, a [directory namespace](../impls/dir) is a 1-level namespace, |
| 79 | +and a [Hive 2.x namespace](../impls/hive) is a 2-level namespace. |
0 commit comments