| 1 | /* |
| 2 | * This Source Code Form is subject to the terms of the Mozilla Public |
| 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
| 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. |
| 5 | * |
| 6 | * Copyright 1997 - July 2008 CWI, August 2008 - 2019 MonetDB B.V. |
| 7 | */ |
| 8 | |
| 9 | #include "monetdb_config.h" |
| 10 | #include "mal.h" |
| 11 | #include "mal_exception.h" |
| 12 | #include "group.h" |
| 13 | #include "algebra.h" |
| 14 | |
| 15 | str |
| 16 | GRPsubgroup5(bat *ngid, bat *next, bat *nhis, const bat *bid, const bat *sid, const bat *gid, const bat *eid, const bat *hid) |
| 17 | { |
| 18 | BAT *b, *s, *g, *e, *h, *gn, *en, *hn; |
| 19 | gdk_return r; |
| 20 | |
| 21 | b = BATdescriptor(*bid); |
| 22 | s = sid ? BATdescriptor(*sid) : NULL; |
| 23 | g = gid ? BATdescriptor(*gid) : NULL; |
| 24 | e = eid ? BATdescriptor(*eid) : NULL; |
| 25 | h = hid ? BATdescriptor(*hid) : NULL; |
| 26 | if (b == NULL || |
| 27 | (sid != NULL && s == NULL) || |
| 28 | (gid != NULL && g == NULL) || |
| 29 | (eid != NULL && e == NULL) || |
| 30 | (hid != NULL && h == NULL)) { |
| 31 | if (b) |
| 32 | BBPunfix(b->batCacheid); |
| 33 | if (s) |
| 34 | BBPunfix(s->batCacheid); |
| 35 | if (g) |
| 36 | BBPunfix(g->batCacheid); |
| 37 | if (e) |
| 38 | BBPunfix(e->batCacheid); |
| 39 | if (h) |
| 40 | BBPunfix(h->batCacheid); |
| 41 | throw(MAL, gid ? "group.subgroup" : "group.group" , SQLSTATE(HY002) RUNTIME_OBJECT_MISSING); |
| 42 | } |
| 43 | if ((r = BATgroup(&gn, next ? &en : NULL, nhis ? &hn : NULL, b, s, g, e, h)) == GDK_SUCCEED) { |
| 44 | *ngid = gn->batCacheid; |
| 45 | BBPkeepref(*ngid); |
| 46 | if (next) { |
| 47 | *next = en->batCacheid; |
| 48 | BBPkeepref(*next); |
| 49 | } |
| 50 | if (nhis){ |
| 51 | *nhis = hn->batCacheid; |
| 52 | BBPkeepref(*nhis); |
| 53 | } |
| 54 | } |
| 55 | BBPunfix(b->batCacheid); |
| 56 | if (s) |
| 57 | BBPunfix(s->batCacheid); |
| 58 | if (g) |
| 59 | BBPunfix(g->batCacheid); |
| 60 | if (e) |
| 61 | BBPunfix(e->batCacheid); |
| 62 | if (h) |
| 63 | BBPunfix(h->batCacheid); |
| 64 | return r == GDK_SUCCEED ? MAL_SUCCEED : createException(MAL, gid ? "group.subgroup" : "group.group" , GDK_EXCEPTION); |
| 65 | } |
| 66 | |
| 67 | str |
| 68 | GRPsubgroup9(bat *ngid, bat *next, const bat *bid, const bat *sid, const bat *gid, const bat *eid, const bat *hid) |
| 69 | { |
| 70 | return GRPsubgroup5(ngid, next, NULL, bid, sid, gid, eid, hid); |
| 71 | } |
| 72 | |
| 73 | str |
| 74 | GRPsubgroup8(bat *ngid, bat *next, const bat *bid, const bat *gid, const bat *eid, const bat *hid) |
| 75 | { |
| 76 | return GRPsubgroup5(ngid, next, NULL, bid, NULL, gid, eid, hid); |
| 77 | } |
| 78 | |
| 79 | str |
| 80 | GRPsubgroup7(bat *ngid, bat *next, const bat *bid, const bat *sid, const bat *gid) |
| 81 | { |
| 82 | return GRPsubgroup5(ngid, next, NULL, bid, sid, gid, NULL, NULL); |
| 83 | } |
| 84 | |
| 85 | str |
| 86 | GRPsubgroup6(bat *ngid, bat *next, const bat *bid, const bat *gid) |
| 87 | { |
| 88 | return GRPsubgroup5(ngid, next, NULL, bid, NULL, gid, NULL, NULL); |
| 89 | } |
| 90 | |
| 91 | str |
| 92 | GRPsubgroup4(bat *ngid, bat *next, bat *nhis, const bat *bid, const bat *gid, const bat *eid, const bat *hid) |
| 93 | { |
| 94 | return GRPsubgroup5(ngid, next, nhis, bid, NULL, gid, eid, hid); |
| 95 | } |
| 96 | |
| 97 | str |
| 98 | GRPsubgroup3(bat *ngid, bat *next, bat *nhis, const bat *bid, const bat *sid, const bat *gid) |
| 99 | { |
| 100 | return GRPsubgroup5(ngid, next, nhis, bid, sid, gid, NULL, NULL); |
| 101 | } |
| 102 | |
| 103 | str |
| 104 | GRPsubgroup2(bat *ngid, bat *next, bat *nhis, const bat *bid, const bat *gid) |
| 105 | { |
| 106 | return GRPsubgroup5(ngid, next, nhis, bid, NULL, gid, NULL, NULL); |
| 107 | } |
| 108 | |
| 109 | str |
| 110 | GRPgroup4(bat *ngid, bat *next, const bat *bid, const bat *sid) |
| 111 | { |
| 112 | return GRPsubgroup5(ngid, next, NULL, bid, sid, NULL, NULL, NULL); |
| 113 | } |
| 114 | |
| 115 | str |
| 116 | GRPgroup3(bat *ngid, bat *next, const bat *bid) |
| 117 | { |
| 118 | return GRPsubgroup5(ngid, next, NULL, bid, NULL, NULL, NULL, NULL); |
| 119 | } |
| 120 | |
| 121 | str |
| 122 | GRPgroup2(bat *ngid, bat *next, bat *nhis, const bat *bid, const bat *sid) |
| 123 | { |
| 124 | return GRPsubgroup5(ngid, next, nhis, bid, sid, NULL, NULL, NULL); |
| 125 | } |
| 126 | |
| 127 | str |
| 128 | GRPgroup1(bat *ngid, bat *next, bat *nhis, const bat *bid) |
| 129 | { |
| 130 | return GRPsubgroup5(ngid, next, nhis, bid, NULL, NULL, NULL, NULL); |
| 131 | } |
| 132 | |
| 133 | str |
| 134 | GRPgroup11(bat *ngid, const bat *bid) |
| 135 | { |
| 136 | return GRPsubgroup5(ngid, NULL, NULL, bid, NULL, NULL, NULL, NULL); |
| 137 | } |
| 138 | |
| 139 | str |
| 140 | GRPgroup21(bat *ngid, const bat *bid, const bat *sid) |
| 141 | { |
| 142 | return GRPsubgroup5(ngid, NULL, NULL, bid, sid, NULL, NULL, NULL); |
| 143 | } |
| 144 | |
| 145 | str |
| 146 | GRPsubgroup51(bat *ngid, const bat *bid, const bat *sid, const bat *gid, const bat *eid, const bat *hid) |
| 147 | { |
| 148 | return GRPsubgroup5(ngid, NULL, NULL, bid, sid, gid, eid, hid); |
| 149 | } |
| 150 | |
| 151 | str |
| 152 | GRPsubgroup41(bat *ngid, const bat *bid, const bat *gid, const bat *eid, const bat *hid) |
| 153 | { |
| 154 | return GRPsubgroup5(ngid, NULL, NULL, bid, NULL, gid, eid, hid); |
| 155 | } |
| 156 | |
| 157 | str |
| 158 | GRPsubgroup31(bat *ngid, const bat *bid, const bat *sid, const bat *gid) |
| 159 | { |
| 160 | return GRPsubgroup5(ngid, NULL, NULL, bid, sid, gid, NULL, NULL); |
| 161 | } |
| 162 | |
| 163 | str |
| 164 | GRPsubgroup21(bat *ngid, const bat *bid, const bat *gid) |
| 165 | { |
| 166 | return GRPsubgroup5(ngid, NULL, NULL, bid, NULL, gid, NULL, NULL); |
| 167 | } |
| 168 | |