Skip to content

Commit 8848a02

Browse files
authored
Merge pull request #265 from datajoint/stage-external-storage
Add placeholders for Attach and Filepath datatypes
2 parents 5efbfd1 + 7f069e6 commit 8848a02

File tree

16 files changed

+187
-10
lines changed

16 files changed

+187
-10
lines changed

+dj/+internal/Declare.m

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,18 @@
1111
'STRING', '^((var)?char|enum|date|(var)?year|time|timestamp)', ...
1212
'INTERNAL_BLOB', '^(tiny|medium|long)?blob$', ...
1313
'EXTERNAL_BLOB', '^blob@(?<store>[a-z]\w*)$', ...
14-
'UUID', 'uuid$' ...
14+
'INTERNAL_ATTACH', '^attach$', ...
15+
'EXTERNAL_ATTACH', '^attach@(?<store>[a-z]\w*)$', ...
16+
'FILEPATH', '^filepath@(?<store>[a-z]\w*)$', ...
17+
'UUID', '^uuid$' ...
1518
)
16-
SPECIAL_TYPES = {'UUID', 'EXTERNAL_BLOB'}
17-
EXTERNAL_TYPES = {'EXTERNAL_BLOB'} % data referenced by a UUID in external tables
18-
SERIALIZED_TYPES = {'EXTERNAL_BLOB'} % requires packing data
19+
SPECIAL_TYPES = {'UUID', 'INTERNAL_ATTACH', 'EXTERNAL_ATTACH', 'EXTERNAL_BLOB', ...
20+
'FILEPATH', 'ADAPTED'}
21+
% data referenced by a UUID in external tables
22+
EXTERNAL_TYPES = {'EXTERNAL_ATTACH', 'EXTERNAL_BLOB', 'FILEPATH'}
23+
% requires packing data
24+
SERIALIZED_TYPES = {'EXTERNAL_ATTACH', 'INTERNAL_ATTACH', 'EXTERNAL_BLOB', ...
25+
'INTERNAL_BLOB'}
1926
end
2027

2128
methods(Static)
@@ -313,6 +320,8 @@ case regexp(line, ['^[a-z][a-z\d_]*\s*' ... % name
313320
% category: <string> DataJoint type match based on TYPE_PATTERN.
314321
if strcmpi(category, 'UUID')
315322
field.type = dj.internal.Declare.UUID_DATA_TYPE;
323+
elseif strcmpi(category, 'INTERNAL_ATTACH')
324+
field.type = 'LONGBLOB';
316325
elseif any(strcmpi(category, dj.internal.Declare.EXTERNAL_TYPES))
317326
field.store = strtrim(field.type((strfind(field.type,'@')+1):end));
318327
field.type = dj.internal.Declare.UUID_DATA_TYPE;

+dj/+internal/GeneralRelvar.m

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@ function disp(self)
7878

7979
attrList = cell(size(hdr.attributes));
8080
for i = 1:length(hdr.attributes)
81-
if hdr.attributes(i).isBlob
81+
if hdr.attributes(i).isBlob || hdr.attributes(i).isAttachment || ...
82+
hdr.attributes(i).isFilepath
8283
attrList{i} = sprintf('("=BLOB=") -> %s', hdr.names{i});
8384
else
8485
attrList{i} = hdr.names{i};
@@ -939,6 +940,10 @@ case isa(cond, 'dj.internal.GeneralRelvar')
939940
data(j).(attr(i).name) = new_value;
940941
end
941942
end
943+
elseif attr(i).isAttachment || attr(i).isFilepath
944+
error('DataJoint:DataType:NotYetSupported', ...
945+
'The field `%s` with datatype `%s` is not yet supported.', ...
946+
attr(i).name, attr(i).type)
942947
elseif attr(i).isBlob && attr(i).isExternal
943948
for j = 1:length(data)
944949
if ~isempty(data(j).(attr(i).name))

+dj/+internal/Header.m

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@
7878
attrs.isautoincrement = false(length(attrs.isnullable), 1);
7979
attrs.isNumeric = false(length(attrs.isnullable), 1);
8080
attrs.isString = false(length(attrs.isnullable), 1);
81+
attrs.isAttachment = false(length(attrs.isnullable), 1);
82+
attrs.isFilepath = false(length(attrs.isnullable), 1);
8183
attrs.isUuid = false(length(attrs.isnullable), 1);
8284
attrs.isBlob = false(length(attrs.isnullable), 1);
8385
attrs.isExternal = false(length(attrs.isnullable), 1);
@@ -107,6 +109,9 @@
107109
attrs.isString(i) = strcmpi(category, 'STRING');
108110
attrs.isUuid(i) = strcmpi(category, 'UUID');
109111
attrs.isBlob(i) = any(strcmpi(category, {'INTERNAL_BLOB', 'EXTERNAL_BLOB'}));
112+
attrs.isAttachment(i) = any(strcmpi(category, {'INTERNAL_ATTACH', ...
113+
'EXTERNAL_ATTACH'}));
114+
attrs.isFilepath(i) = strcmpi(category, 'FILEPATH');
110115
if any(strcmpi(category, dj.internal.Declare.EXTERNAL_TYPES))
111116
attrs.isExternal(i) = true;
112117
attrs.store{i} = attrs.type{i}(regexp(attrs.type{i}, '@', 'once')+1:end);
@@ -118,7 +123,7 @@
118123
end
119124

120125
validFields = [attrs.isNumeric] | [attrs.isString] | [attrs.isBlob] | ...
121-
[attrs.isUuid];
126+
[attrs.isUuid] | [attrs.isAttachment] | [attrs.isFilepath];
122127
if ~all(validFields)
123128
ix = find(~validFields, 1, 'first');
124129
error('unsupported field type "%s" in `%s`.`%s`', ...
@@ -178,6 +183,8 @@ function project(self, params)
178183
'isString', false, ...
179184
'isBlob', false, ...
180185
'isUuid', false, ...
186+
'isAttachment', false, ...
187+
'isFilepath', false, ...
181188
'isExternal', false, ...
182189
'store', [], ...
183190
'database', [], ...

+dj/+internal/TableAccessor.m

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,18 @@
2626
splitName = strsplit(className{1}, '.');
2727
name = splitName{2};
2828
addprop(self, name);
29-
self.(name) = dj.Relvar(className{1});
29+
tableName = schema.tableNames(className{1});
30+
tierClass = 'dj.Manual';
31+
for k=1:numel(dj.Schema.tierPrefixes)
32+
tierCharLen = length(dj.Schema.tierPrefixes{k});
33+
if tierCharLen > 0 && ~isempty(regexp(dj.Schema.tierPrefixes{k}, ...
34+
tableName(1:tierCharLen), 'ONCE'))
35+
tierClass = dj.Schema.tierClasses{k};
36+
break;
37+
end
38+
end
39+
tierClass = strsplit(tierClass, '.');
40+
self.(name) = dj.(tierClass{2})(className{1});
3041
end
3142
end
3243
end

+dj/+internal/UserRelation.m

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,7 @@
11
classdef UserRelation < dj.Relvar & dj.internal.Master
2+
methods
3+
function self = UserRelation(varargin)
4+
[email protected](varargin{:})
5+
end
6+
end
27
end

+dj/Computed.m

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
11
classdef Computed < dj.internal.AutoPopulate
22
% defines a computed table
3+
methods
4+
function self = Computed(varargin)
5+
[email protected](varargin{:})
6+
end
7+
end
38
end

+dj/Imported.m

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
11
classdef Imported < dj.internal.AutoPopulate
22
% defines an imported table
3+
methods
4+
function self = Imported(varargin)
5+
[email protected](varargin{:})
6+
end
7+
end
38
end

+dj/Jobs.m

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,7 @@
11
classdef Jobs < dj.Relvar
2+
methods
3+
function self = Jobs(varargin)
4+
[email protected](varargin{:})
5+
end
6+
end
27
end

+dj/Lookup.m

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
% defines a lookup table
33

44
methods
5-
function self = Lookup()
5+
function self = Lookup(varargin)
6+
[email protected](varargin{:})
67
if isprop(self, 'contents')
78
if length(self.contents) > count(self)
89
self.inserti(self.contents)

+dj/Manual.m

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
11
classdef Manual < dj.internal.UserRelation
22
% Defines a manual table
3+
methods
4+
function self = Manual(varargin)
5+
[email protected](varargin{:})
6+
end
7+
end
38
end

0 commit comments

Comments
 (0)