| 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 | #ifndef _GDK_DELTA_H_ |
| 10 | #define _GDK_DELTA_H_ |
| 11 | |
| 12 | /* |
| 13 | * We make sure here that the BUNs section of a BAT at least starts 4 |
| 14 | * bytes from the BUN start. This ensures that the first data item of |
| 15 | * e.g. a BAT[void,bit] is (at least) integer aligned. This optimizes |
| 16 | * processing on such BATs (DDBENCH). |
| 17 | */ |
| 18 | #define DELTAinit(P1) \ |
| 19 | do { \ |
| 20 | BATsetcount((P1), 0); \ |
| 21 | (P1)->theap.free = 0; \ |
| 22 | (P1)->batInserted = 0; \ |
| 23 | (P1)->tshift = ATOMelmshift(Tsize(P1)); \ |
| 24 | DELTADEBUG fprintf(stderr, \ |
| 25 | "#DELTAinit %s free %zu ins " BUNFMT \ |
| 26 | " base %p\n", \ |
| 27 | BATgetId(P1), \ |
| 28 | (P1)->theap.free, \ |
| 29 | (P1)->batInserted, \ |
| 30 | (P1)->theap.base); \ |
| 31 | } while (0) |
| 32 | /* |
| 33 | * Upon saving a BAT, we should convert the delta marker BUN pointers |
| 34 | * into indexes and convert them back into pointers upon reload. |
| 35 | * |
| 36 | * The BATdirty(b) tells you whether a BAT's main memory |
| 37 | * representation differs from its saved image on stable storage. But |
| 38 | * *not* whether it has changed since last transaction commit (it can |
| 39 | * be storage-clean, but transaction-dirty). For this we have |
| 40 | * DELTAdirty(b). |
| 41 | */ |
| 42 | #define DELTAdirty(b) ((b)->batInserted < BUNlast(b)) |
| 43 | |
| 44 | #endif /* _GDK_DELTA_H_ */ |
| 45 | |