aboutsummaryrefslogtreecommitdiff
path: root/pkg/utilities/nttools/tjoin/removejcol.x
blob: 1578021b6992f74e3e479dca43c5c17fa846c50b (plain) (blame)
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
include "tjoin.h"

# B.Simon	16-Apr-99	first code

# REMOVE_JCOL -- Remove join columns from list of data columns

procedure remove_jcol (tj, tol)

pointer	tj		# i: Descriptor of table information
pointer	tol		# i: Vector of tolerances used in equality test
#--
bool	match
int	icol, jcol, kcol

begin
	kcol = 0
	do icol = 1, TJ_DNUM(tj) {
	    # Determine if this column is a join column
	    # with strict equality testing

	    match = false
	    do jcol = 1, TJ_JNUM(tj) {
		if (TJ_DCOL(tj,icol) == TJ_JCOL(tj,jcol) &&
		    TOL_VAL(tol,jcol) == 0.0) {
		    match = true
		    break
		}
	    }

	    # Don't copy these columns as they duplicate the values
	    # in the join column in the other table. Also don't copy 
	    # if icol == kcol in order to save time

	    if (! match) {
		kcol = kcol + 1
		if (kcol < icol)
		    TJ_DCOL(tj,kcol) = TJ_DCOL(tj,icol)
	    }
	}

	TJ_DNUM(tj) = kcol
end