Skip to content

Commit 879d9f5

Browse files
Merge pull request #128 from datajoint/pre/v2.0
Remove unsigned integer types from core types for DataJoint 2.0
2 parents 1f224ac + 2727f63 commit 879d9f5

37 files changed

+2740
-2360
lines changed

src/explanation/computation-model.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class Segmentation(dj.Computed):
1414
definition = """
1515
-> Scan
1616
---
17-
num_cells : uint32
17+
num_cells : int64
1818
cell_masks : <blob@>
1919
"""
2020

src/explanation/entity-integrity.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ attributes:
141141
class Recording(dj.Manual):
142142
definition = """
143143
-> Session
144-
recording_idx : uint16 # Recording number within session
144+
recording_idx : int32 # Recording number within session
145145
---
146146
duration : float32 # seconds
147147
"""
@@ -163,7 +163,7 @@ class Segmentation(dj.Computed):
163163
definition = """
164164
-> Scan # Depends on Scan
165165
---
166-
num_cells : uint32
166+
num_cells : int64
167167
"""
168168
```
169169

@@ -193,7 +193,7 @@ class Subject(dj.Manual):
193193
class Session(dj.Manual):
194194
definition = """
195195
-> Subject # Inherits subject_id
196-
session_idx : uint16 # NEW dimension: session_idx
196+
session_idx : int32 # NEW dimension: session_idx
197197
---
198198
session_date : date
199199
"""
@@ -202,7 +202,7 @@ class Session(dj.Manual):
202202
class Trial(dj.Manual):
203203
definition = """
204204
-> Session # Inherits subject_id, session_idx
205-
trial_idx : uint16 # NEW dimension: trial_idx
205+
trial_idx : int32 # NEW dimension: trial_idx
206206
---
207207
outcome : enum('success', 'fail')
208208
"""
@@ -245,7 +245,7 @@ class SessionSummary(dj.Computed):
245245
definition = """
246246
-> Session # PK = (subject_id, session_idx)
247247
---
248-
num_trials : uint32
248+
num_trials : int64
249249
accuracy : float32
250250
"""
251251
```
@@ -264,13 +264,13 @@ class Detection(dj.Computed):
264264
-> Image # Inherits image_id
265265
-> DetectionParams # Inherits params_id
266266
---
267-
num_blobs : uint32
267+
num_blobs : int64
268268
"""
269269

270270
class Blob(dj.Part):
271271
definition = """
272272
-> master # Inherits (image_id, params_id)
273-
blob_idx : uint16 # NEW dimension within detection
273+
blob_idx : int32 # NEW dimension within detection
274274
---
275275
x : float32
276276
y : float32
@@ -339,9 +339,9 @@ experimental structure and ensures correct joins through semantic matching.
339339
# Wrong: experiment_id alone isn't unique
340340
class Trial(dj.Manual):
341341
definition = """
342-
experiment_id : uint32
342+
experiment_id : int64
343343
---
344-
trial_number : uint16 # Should be part of key!
344+
trial_number : int32 # Should be part of key!
345345
result : float32
346346
"""
347347
```
@@ -352,7 +352,7 @@ class Trial(dj.Manual):
352352
# Wrong: timestamp makes every row unique, losing entity semantics
353353
class Measurement(dj.Manual):
354354
definition = """
355-
subject_id : uint32
355+
subject_id : int64
356356
timestamp : datetime(6) # Microsecond precision
357357
---
358358
value : float32

src/explanation/type-system.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,10 @@ Standardized, scientist-friendly types that work identically across backends.
6262
| `int16` | 16-bit signed | -32,768 to 32,767 |
6363
| `int32` | 32-bit signed | ±2 billion |
6464
| `int64` | 64-bit signed | ±9 quintillion |
65-
| `uint8` | 8-bit unsigned | 0 to 255 |
66-
| `uint16` | 16-bit unsigned | 0 to 65,535 |
67-
| `uint32` | 32-bit unsigned | 0 to 4 billion |
68-
| `uint64` | 64-bit unsigned | 0 to 18 quintillion |
65+
| `int16` | 8-bit unsigned | 0 to 255 |
66+
| `int32` | 16-bit unsigned | 0 to 65,535 |
67+
| `int64` | 32-bit unsigned | 0 to 4 billion |
68+
| `int64` | 64-bit unsigned | 0 to 18 quintillion |
6969
| `float32` | 32-bit float | ~7 significant digits |
7070
| `float64` | 64-bit float | ~15 significant digits |
7171
| `decimal(n,f)` | Fixed-point | Exact decimal |

src/explanation/whats-new-2.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ If you're upgrading from legacy DataJoint, these changes require code updates:
2424
| **Fetch API** | `table.fetch()` | `table.to_dicts()` or `.to_arrays()` |
2525
| **Update** | `(table & key)._update('attr', val)` | `table.update1({**key, 'attr': val})` |
2626
| **Join** | `table1 @ table2` | `table1 * table2` (with semantic check) |
27-
| **Type syntax** | `longblob`, `int unsigned` | `<blob>`, `uint32` |
27+
| **Type syntax** | `longblob`, `int unsigned` | `<blob>`, `int64` |
2828
| **Jobs** | `~jobs` table | Per-table `~~table_name` |
2929

3030
See the [Migration Guide](../how-to/migrate-to-v20.md) for complete upgrade steps.
@@ -75,7 +75,7 @@ Legacy DataJoint overloaded MySQL types with implicit conversions:
7575
| `longblob` | `<blob>` |
7676
| `attach` | `<attach>` |
7777
| `blob@store` | `<blob@store>` |
78-
| `int unsigned` | `uint32` |
78+
| `int unsigned` | `int64` |
7979

8080
### Three-Tier Architecture
8181

@@ -207,7 +207,7 @@ This enables efficient access to large datasets stored in Zarr, HDF5, or custom
207207
### Deprecated Features
208208

209209
- **AdaptedTypes**: Replaced by codec system (still works but migration recommended)
210-
- **Native type syntax**: `int unsigned``uint32` (warnings on new tables)
210+
- **Native type syntax**: `int unsigned``int64` (warnings on new tables)
211211
- **Legacy external storage** (`blob@store`): Replaced by `<blob@store>` codec syntax
212212

213213
### Legacy Support
@@ -238,7 +238,7 @@ Upgrading from DataJoint 0.x is a **phased process** designed to minimize risk:
238238
- **No database changes** — legacy clients still work
239239

240240
### Phase 2: Type Migration (Reversible)
241-
- Update database column comments to use core types (`:uint32:`, `:<blob>:`)
241+
- Update database column comments to use core types (`:int64:`, `:<blob>:`)
242242
- Rebuild `~lineage` tables for semantic matching
243243
- Update Python table definitions
244244
- **Legacy clients still work** — only metadata changed

src/how-to/choose-storage-type.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,7 @@ class SpikeWaveforms(dj.Computed):
523523
"""Extracted spike shapes"""
524524
definition = """
525525
-> ContinuousData
526-
unit_id : uint32
526+
unit_id : int64
527527
---
528528
waveforms : <npy@> # 20 MB array, lazy load
529529
"""
@@ -571,7 +571,7 @@ class FluorescenceTraces(dj.Computed):
571571
"""Extracted time series"""
572572
definition = """
573573
-> SegmentedCells
574-
cell_id : uint32
574+
cell_id : int64
575575
---
576576
trace : <blob@> # 500 KB per cell, deduplicated
577577
"""

src/how-to/define-tables.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class MyTable(dj.Manual):
4141
```python
4242
definition = """
4343
subject_id : varchar(16) # Subject identifier
44-
session_idx : uint16 # Session number
44+
session_idx : int32 # Session number
4545
---
4646
...
4747
"""
@@ -137,7 +137,7 @@ See [Design Primary Keys](design-primary-keys.md) for detailed guidance on key s
137137
|------|-------------|
138138
| `bool` | Boolean (true/false) |
139139
| `int8`, `int16`, `int32`, `int64` | Signed integers |
140-
| `uint8`, `uint16`, `uint32`, `uint64` | Unsigned integers |
140+
| `int16`, `int32`, `int64`, `int64` | Unsigned integers |
141141
| `float32`, `float64` | Floating point |
142142
| `decimal(m,n)` | Fixed precision decimal |
143143
| `varchar(n)` | Variable-length string |
@@ -196,7 +196,7 @@ Native types are flagged with a warning at declaration time but are allowed. Cor
196196
class Session(dj.Manual):
197197
definition = """
198198
-> Subject # References Subject table
199-
session_idx : uint16
199+
session_idx : int32
200200
---
201201
session_date : date
202202
"""
@@ -227,15 +227,15 @@ class TaskType(dj.Lookup):
227227
class Session(dj.Manual):
228228
definition = """
229229
-> Subject
230-
session_idx : uint16
230+
session_idx : int32
231231
---
232232
session_date : date
233233
"""
234234

235235
class Trial(dj.Part):
236236
definition = """
237237
-> master
238-
trial_idx : uint16
238+
trial_idx : int32
239239
---
240240
outcome : enum('hit', 'miss')
241241
reaction_time : float32
@@ -250,7 +250,7 @@ class SessionStats(dj.Computed):
250250
definition = """
251251
-> Session
252252
---
253-
n_trials : uint32
253+
n_trials : int64
254254
hit_rate : float32
255255
"""
256256

@@ -270,7 +270,7 @@ Declare indexes at the end of the definition, after all attributes:
270270
```python
271271
definition = """
272272
subject_id : varchar(16)
273-
session_idx : uint16
273+
session_idx : int32
274274
---
275275
session_date : date
276276
experimenter : varchar(50)
@@ -288,7 +288,7 @@ Tables are declared in the database when the `@schema` decorator applies to the
288288
@schema # Table is declared here
289289
class Session(dj.Manual):
290290
definition = """
291-
session_id : uint16
291+
session_id : int32
292292
---
293293
session_date : date
294294
"""

src/how-to/design-primary-keys.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ Combine attributes when a single attribute isn't unique:
3939
class Session(dj.Manual):
4040
definition = """
4141
-> Subject
42-
session_idx : uint16 # Session number within subject
42+
session_idx : int32 # Session number within subject
4343
---
4444
session_date : date
4545
"""
@@ -100,7 +100,7 @@ Foreign keys above the `---` become part of the primary key:
100100
class Trial(dj.Manual):
101101
definition = """
102102
-> Session # In primary key
103-
trial_idx : uint16 # In primary key
103+
trial_idx : int32 # In primary key
104104
---
105105
-> Stimulus # NOT in primary key
106106
outcome : enum('hit', 'miss')
@@ -111,11 +111,11 @@ class Trial(dj.Manual):
111111

112112
### Keep Keys Small
113113

114-
Prefer `uint16` over `int64` when the range allows:
114+
Prefer `int32` over `int64` when the range allows:
115115

116116
```python
117117
# Good: Appropriate size
118-
session_idx : uint16 # Max 65,535 sessions per subject
118+
session_idx : int32 # Max 65,535 sessions per subject
119119

120120
# Avoid: Unnecessarily large
121121
session_idx : int64 # Wastes space, slower joins
@@ -145,7 +145,7 @@ session_date : date
145145

146146
# Good: Add a sequence number
147147
-> Subject
148-
session_idx : uint16
148+
session_idx : int32
149149
---
150150
session_date : date
151151
```
@@ -172,7 +172,7 @@ Once a table has data, primary keys cannot be changed. Plan carefully:
172172
class Scan(dj.Manual):
173173
definition = """
174174
-> Session
175-
scan_idx : uint8 # Might need uint16 for high-throughput
175+
scan_idx : int16 # Might need int32 for high-throughput
176176
---
177177
...
178178
"""

src/how-to/manage-pipeline-project.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ class Probe(dj.Lookup):
6161
definition = """
6262
probe_type : varchar(32)
6363
---
64-
num_channels : uint16
64+
num_channels : int32
6565
"""
6666

6767
@schema

0 commit comments

Comments
 (0)