Line data Source code
1 : /* 2 : * SPDX-License-Identifier: MPL-2.0 3 : * 4 : * This Source Code Form is subject to the terms of the Mozilla Public 5 : * License, v. 2.0. If a copy of the MPL was not distributed with this 6 : * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 : * 8 : * Copyright 2024 MonetDB Foundation; 9 : * Copyright August 2008 - 2023 MonetDB B.V.; 10 : * Copyright 1997 - July 2008 CWI. 11 : */ 12 : 13 : #ifndef _GDK_DELTA_H_ 14 : #define _GDK_DELTA_H_ 15 : 16 : /* 17 : * We make sure here that the BUNs section of a BAT at least starts 4 18 : * bytes from the BUN start. This ensures that the first data item of 19 : * e.g. a BAT[void,bit] is (at least) integer aligned. This optimizes 20 : * processing on such BATs (DDBENCH). 21 : */ 22 : static inline void 23 9487279 : DELTAinit(BAT *b) 24 : { 25 9487279 : BATsetcount(b, 0); 26 9488559 : b->theap->free = 0; 27 9488559 : b->batInserted = 0; 28 9488559 : b->tshift = ATOMelmshift(b->twidth); 29 9488559 : TRC_DEBUG(DELTA, 30 : "%s free %zu ins " BUNFMT " base %p\n", 31 : BBP_logical(b->batCacheid), 32 : b->theap->free, 33 : b->batInserted, 34 : b->theap->base); 35 9488559 : } 36 : 37 : /* 38 : * Upon saving a BAT, we should convert the delta marker BUN pointers 39 : * into indexes and convert them back into pointers upon reload. 40 : * 41 : * The BATdirty(b) tells you whether a BAT's main memory 42 : * representation differs from its saved image on stable storage. But 43 : * *not* whether it has changed since last transaction commit (it can 44 : * be storage-clean, but transaction-dirty). For this we have 45 : * DELTAdirty(b). 46 : */ 47 : #define DELTAdirty(b) ((b)->batInserted < BATcount(b)) 48 : 49 : #endif /* _GDK_DELTA_H_ */