Commit 6e757371 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 4f4592cb
// Code generated by gen-δtail I64 int64; DO NOT EDIT.
// (from lab.nexedi.com/kirr/neo/go/zodb @ v1.9-2078-gae3c4829)
// (from lab.nexedi.com/kirr/neo/go/zodb @ v1.9-2080-gd1f63f32)
// Copyright (C) 2018-2019 Nexedi SA and Contributors.
// Kirill Smelkov <kirr@nexedi.com>
......@@ -24,18 +24,18 @@ package main
import "lab.nexedi.com/kirr/neo/go/zodb"
// XXX do we really need ΔTailI64 to be exported from zodb?
// (other users are low level caches + maybe ZEO/NEO -> zplumbing? but then import cycle)
import (
"fmt"
)
// XXX do we really need ΔTailI64 to be exported from zodb?
// (other users are low level caches + maybe ZEO/NEO -> zplumbing? but then import cycle)
// ΔTailI64 represents tail of revisional changes.
//
// It semantically consists of
//
// [](rev↑, []id)
// [](rev↑, []id) XXX + head?
//
// and index
//
......@@ -48,10 +48,10 @@ import (
//
// It provides operations to
//
// - XXX Head
// - append information to the tail about next revision,
// - forget information in the tail past specified revision, and
// - query the tail about what is last revision that changed an id.
// - query the tail about what head/tail XXX?
//
// ΔTailI64 is safe to access for multiple-readers / single writer.
//
......@@ -60,6 +60,7 @@ import (
// oid - ZODB object identifier, when ΔTailI64 represents changes to ZODB objects,
// #blk - file block number, when ΔTailI64 represents changes to a file.
type ΔTailI64 struct {
head zodb.Tid
tailv []δRevEntryI64
lastRevOf map[int64]zodb.Tid // index for LastRevOf queries
......@@ -78,9 +79,12 @@ func NewΔTailI64() *ΔTailI64 {
return &ΔTailI64{lastRevOf: make(map[int64]zodb.Tid)}
}
// XXX + .Head() -> max(rev) XXX or 0 if len(tailv) == 0?
// Head returns database state starting from which δtail has history coverage. XXX
//
// For newly created ΔTailI64 Head returns 0.
// Head is ↑, in particular it does not go back to 0 when δtail becomes empty.
func (δtail *ΔTailI64) Head() zodb.Tid {
panic("TODO")
return δtail.head
}
// XXX add way to extend coverage without appending changed data? (i.e. if a
......@@ -91,13 +95,11 @@ func (δtail *ΔTailI64) Head() zodb.Tid {
// rev must be ↑.
func (δtail *ΔTailI64) Append(rev zodb.Tid, changev []int64) {
// check rev↑
// XXX better also check even when δtail is ø (after forget)
if l := len(δtail.tailv); l > 0 {
if revPrev := δtail.tailv[l-1].rev; revPrev >= rev {
panic(fmt.Sprintf("δtail.Append: rev not ↑: %s -> %s", revPrev, rev))
}
if δtail.head >= rev {
panic(fmt.Sprintf("δtail.Append: rev not ↑: %s -> %s", δtail.head, rev))
}
δtail.head = rev
δtail.tailv = append(δtail.tailv, δRevEntryI64{rev, changev})
for _, id := range changev {
δtail.lastRevOf[id] = rev
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment