gusucode.com > bigdata 工具箱 matlab源码程序 > bigdata/@tall/innerjoin.m
function tt = innerjoin(tA, tB, varargin) %INNERJOIN Inner join between a tall table and a table. % Supported syntax for tall table: % C = INNERJOIN(A, B) % C = INNERJOIN(A, B, 'PARAM1',val1, 'PARAM2',val2, ...) % % LIMITATION: % (1) Second and third ouput is not supported % % See also TABLE/INNERJOIN. % Copyright 2016 The MathWorks, Inc. narginchk(2,inf); [tA, tB] = tall.validateType(tA, tB, upper(mfilename), {'table'}, 1:2); if istall(tA) && istall(tB) error(message('MATLAB:bigdata:array:InnerjoinTwoTallTableNotSupported')); end checkNotTall(upper(mfilename), 2, varargin{:}); % Create dummy table to determine variable names and types. Aname = inputname(1); if isempty(Aname) Aname = 'left'; end Bname = inputname(2); if isempty(Bname) Bname = 'right'; end [dummyA, knownClass1] = makeDummyTable(tA, mfilename); [dummyB, knownClass2] = makeDummyTable(tB, mfilename); dummyC = innerjoin(dummyA, dummyB, varargin{:}); outputNames = dummyC.Properties.VariableNames; % Ok, now we need to see if any columns have had '_dummyA' or '_dummyB' % appended. If they have, replace that with '_<aName>' or '_<bName>'. outputNames = regexprep(outputNames, '_dummyA$', ['_' Aname]); outputNames = regexprep(outputNames, '_dummyB$', ['_' Bname]); dummyC.Properties.VariableNames = outputNames; adaptors = getAdaptorsFromDummyTable(dummyC, knownClass1 & knownClass2); if istall(tA) tt = chunkfun(@(x)iLocalInnerjoin(x,tB,outputNames,varargin{:}),tA); else tt = chunkfun(@(x)iLocalInnerjoin(tA,x,outputNames,varargin{:}),tB); end tt.Adaptor = adaptors; end function tt = iLocalInnerjoin(A,B,outputNames,varargin) tt = innerjoin(A,B,varargin{:}); tt.Properties.VariableNames = outputNames; end