[Monetdb-developers] what should happen when appending to a nil bat?

Consider this scenario: mil>var a := new(oid,void).insert(0@0,nil); mil>a.print(); #-----------------# # h t # name # oid void # type #-----------------# [ 0@0, nil ] mil>var b := new(oid,oid).insert(0@0,1@0); mil>b.print(); #-----------------# # h t # name # oid oid # type #-----------------# [ 0@0, 1@0 ] mil>a.append(b); mil>a.print(); The question is, what should the result be? As I see it, there are two possibilities: #-----------------# # h t # name # oid void # type #-----------------# [ 0@0, nil ] [ 1@0, nil ] or #-----------------# # h t # name # oid oid # type #-----------------# [ 0@0, nil ] [ 1@0, 1@0 ] The former keeps the nil tail (the tail of a was void without seqbase and stays that way), whereas the latter materializes the tail so that the tail value of b gets inserted. Opinions? -- Sjoerd Mullender

I also vote for the second alternative. If/where desired the first result can then achieved by a.append(b.mark(nil)); Stefan On Wed, Dec 21, 2005 at 01:26:08PM +0100, Ying Zhang wrote:
-- | Dr. Stefan Manegold | mailto:Stefan.Manegold@cwi.nl | | CWI, P.O.Box 94079 | http://www.cwi.nl/~manegold/ | | 1090 GB Amsterdam | Tel.: +31 (20) 592-4212 | | The Netherlands | Fax : +31 (20) 592-4312 |

In the current example the head is oid. The same question however arises with void|void bats. Both cases should be treated equally. I therefore also vote for the second alternative as the sequence construction in XQuery e.g. uses append/insert and expects the behaviour of the second version. Otherwise values will get lost as their reference (1@0) is replaced by nil values. Jan PS: Is their a difference between append and insert in this scenario?

Jan Rittinger wrote:
Most cases of append are implemented internally using the equivalent of insert. Hence my earlier reply which crossed yours. I got to this because a problem I'm facing in my XML Update code. The problem I have is described in bug #1385067: "bug appending to [void,void] bat".
-- Sjoerd Mullender

Note that this solution also means that when you insert a non-nil value into a nil column, the column should get materialized as well (this is currently not the case): mil>var a := new(oid,void).insert(0@0,nil); mil>a.print(); #-----------------# # h t # name # oid void # type #-----------------# [ 0@0, nil ] mil>a.insert(1@0,1@0); mil>a.print(); #-----------------# # h t # name # oid oid # type #-----------------# [ 0@0, nil ] [ 1@0, 1@0 ] Stefan Manegold wrote:
-- Sjoerd Mullender

Note that the void type has more hidden semantics that are not yet mentioned in behaviours 1 and 2... Some people use/have used insert(nil) meaning to say insert(lastoid++) - For example: MonetDB>var a := new(oid,void); MonetDB>a.insert(oid(0),nil); MonetDB>a.print(); #-----------------# # h t # name # oid void # type #-----------------# [ 0@0, nil ] MonetDB>a.reverse().seqbase(oid(0)); MonetDB>a.print(); #-----------------# # h t # name # oid void # type #-----------------# [ 0@0, 0@0 ] MonetDB>a.insert(oid(1),nil); MonetDB>a.print(); #-----------------# # h t # name # oid void # type #-----------------# [ 0@0, 0@0 ] [ 1@0, 1@0 ] Note that this latter result is inconsistent with the decision for option 2!! (while it is consistent with that of option 1 - seqbase is nil!) | Note that this solution also means that when you insert a non-nil value | into a nil column, the column should get materialized as well (this is | currently not the case): BTW, in principle nil-values could be represented in other ways to avoid materialisation - e.g., a bit-vector, or a list of all nil-values; this may be interesting alternatives when columns contain only a small number of nil values (though affecting all current operators of course). Arjen | | mil>var a := new(oid,void).insert(0@0,nil); | mil>a.print(); | #-----------------# | # h t # name | # oid void # type | #-----------------# | [ 0@0, nil ] | mil>a.insert(1@0,1@0); | mil>a.print(); | #-----------------# | # h t # name | # oid oid # type | #-----------------# | [ 0@0, nil ] | [ 1@0, 1@0 ]

On Wed, Dec 21, 2005 at 09:31:43PM +0100, Arjen P. de Vries wrote:
but the way we will go with X100 ;-)
-- Niels Nes, Centre for Mathematics and Computer Science (CWI) Kruislaan 413, 1098 SJ Amsterdam, The Netherlands room C0.02, phone ++31 20 592-4098, fax ++31 20 592-4312 url: http://www.cwi.nl/~niels e-mail: Niels.Nes@cwi.nl
participants (6)
-
Arjen P. de Vries
-
Jan Rittinger
-
Niels Nes
-
Sjoerd Mullender
-
Stefan Manegold
-
Ying Zhang