-
Notifications
You must be signed in to change notification settings - Fork 2
/
dssave.m
executable file
·122 lines (117 loc) · 3.26 KB
/
dssave.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
% Author: Carl Doersch (cdoersch at cs dot cmu dot edu)
%
% Save unsaved variables in dswork to disk. matchstr specifies
% the variable or set of variables, and accepts *-wildcards, indexes
% in brackets, and absolute and relative paths. dssave() is equivalent
% to dssave('*');
%
function dssave(matchstr)
if(exist('matchstr','var'))
disp(['dssave(' matchstr ')']);
else
disp('dssave');
end
global ds;
if(dsbool(ds,'conf','checksaves'));
task='savechk';
else
task='save';
end
% if(nargin<2)
outpath=ds.sys.outdir;
% end
if(nargin<1)
matchstr='*';
end
mymkdir([outpath '/ds/']);
%[matchstr brakidx]=dssplitmatchstr(matchstr);
%if((numel(matchstr)>=3)&&strcmp(matchstr(1:3),'ds.'))
% matchstr=matchstr(4:end)
%end
%brakidx
%if(isfield(ds,'distproc'))
% distproc=ds.distproc;
% ds=rmfield(ds,'distproc');
%end
%if(isfield(ds,'distproc'))
% distproc=ds.distproc;
% ds2=rmfield(ds,'distproc');
%else
% ds2=ds;
%end
%if(isfield(ds,'savestate'))
% ds2=rmfield(ds2,'savestate');
% savestate=ds.savestate;
%else
% savestate=struct();
%end
[matchstr brakidx]=dssplitmatchstr(matchstr)
matchstr=dsabspath(matchstr)
matchstr=matchstr(5:end)
if(isfield(ds,'sys'))
ds2=ds.sys.root;%rmfield(ds,'sys');
sys=ds.sys;
eval(['ds2' sys.currpath '=rmfield(ds,''sys'');'])
else
sys=struct();
sys.savestate=struct();
ds2=ds;
end
if(~isfield(sys,'currpath'))
sys.currpath='';
end
savestate=sys.savestate;
%[realpath,~,~,savestate]=dsdiskpath(['ds' sys.currpath],1);
if(isempty(savestate))
return;
end
specialvars=struct('name',{},'type',{});
'readmapredmap'
%ds.sys.distproc
if(dsfield(ds,'sys','distproc','mapredmapvars'))
%specialvars=struct('mapvars',ds.sys.savestate.mapredmapvars);
for(i=1:numel(ds.sys.distproc.mapredmapvars))
specialvars(i)=struct('name',ds.sys.distproc.mapredmapvars{i}(5:end),'type','map');
end
end
specialvars
% if(~isfield(ds,'savestate'))
%we start by completing ALL moves so we don't overwrite files
%that have been moved in memory but not on disk
% savestate_tmp=dsrecurse(ds,[outpath '/ds'],[outpath '/ds'],struct(),'*',{'ds','savestate'},'move',[]);
% ds.savestate=dsrecurse(ds,[outpath '/ds'],[outpath '/ds'],savestate_tmp,matchstr,{'ds'},'save',brakidx);
% else
%savestate=dsrecurse(ds2,[outpath '/ds'],[outpath '/ds'],savestate,'*',{'ds','savestate'},'move',[]);
if(dsbool(ds,'sys','distproc','mapreducer'))
task='savedistr';
else
task='save';
end
if(strcmp(task,'savedistr') && ~isfield(ds.sys,'saved'))
ds.sys.saved={};
end
[savestate,~,respath]=dsrecurse(ds2,[outpath '/ds'],[outpath '/ds'],savestate,matchstr,{'ds'},task,brakidx,specialvars,'.ds');
disp('saved')
if(isfield(ds.sys,'saved'))
ds.sys.saved
end
sys.savestate=savestate;
if(isfield(ds.sys,'saved'))
sys.saved=ds.sys.saved;
end
%if(strcmp(task,'savedistr'))
% for(i=1:size(respath,1))
% respath{i,1}=['.ds.' respath{i,1}];
% end
% if(isfield(sys,'saved'))
% sys.saved=[sys.saved;respath];
% else
% sys.saved=respath;
% end
%end
ds.sys=sys;
% end
% if(exist('distproc','var'))
% ds.distproc=distproc;
% end
end