Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Per Cederqvist
lyskom-server-ceder-1616-generations-topgit
Commits
bbc40c2d
Commit
bbc40c2d
authored
Sep 18, 1999
by
Per Cederqvist
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(l2g_expensive_set): New function, not yet completely implemented.
parent
9f307ce6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
111 additions
and
0 deletions
+111
-0
src/server/local-to-global.c
src/server/local-to-global.c
+111
-0
No files found.
src/server/local-to-global.c
View file @
bbc40c2d
...
...
@@ -708,6 +708,117 @@ l2g_append(Local_to_global *l2g,
binfo
->
zeroes
--
;
}
#if 0 /* Not yet completely implemented. */
void
l2g_expensive_set(Local_to_global *l2g,
Local_text_no lno,
Text_no tno)
{
struct l2g_block_info * binfo;
Local_text_no_iter ix;
if (lno >= l2g->first_unused)
{
l2g_append(l2g, lno, tno);
return;
}
if (tno == 0)
{
l2g_delete(l2g, lno);
return;
}
binfo = find_block(l2g, lno);
if (binfo == NULL)
{
/* Append a new block. */
FIXME;
}
else if (lno < binfo->start)
{
assert(binfo == l2g->blocks);
/* Prepend a new block. */
FIXME;
}
else if (is_dense(binfo))
{
assert(binfo->start <= lno);
if (lno < binfo->start + L2G_BLOCKSIZE)
{
while (binfo->start + binfo->first_free <= lno)
binfo->value_block[binfo->first_free++] = 0;
assert(lno < binfo->start + binfo->first_free);
assert(binfo->first_free < L2G_BLOCKSIZE);
if (binfo->value_block[lno - binfo->start] == 0)
binfo->zeroes--;
binfo->value_block[lno - binfo->start] = tno;
}
else
{
/* There is no room within this block. Insert a new block
after binfo. */
FIXME;
}
}
else
{
ix = sparse_locate_value(binfo, lno);
if (ix < binfo->first_free && binfo->key_block[ix] == lno)
{
assert(binfo->value_block[ix] != 0);
binfo->value_block[ix] = tno;
}
else
{
if (binfo->zeroes == 0)
{
/* Split the block to make room. */
FIXME; /* IF lno > [the greatest value in the
block] THEN create a new empty
block and let binfo point to it
ELSE move the final lno into the
new block and let binfo point to
the old block, that now contains an
empty slot ENDIF. The ordo for
this is not good when we do many
worst-case insertions, but that is
alright, since this function is
only used for disaster recovery. */
assert(binfo->zeroes == 1 || binfo->first_free == 0);
}
else
sparse_compact(binfo);
/* There is room for a new mapping in this block. */
for (ix = binfo->first_free; ix > 0; --ix)
{
assert(binfo->key_block[ix-1] != lno);
if (binfo->key_block[ix-1] > lno)
{
binfo->key_block[ix] = binfo->key_block[ix-1];
binfo->value_block[ix] = binfo->value_block[ix-1];
}
else
break;
}
assert(ix == 0 || binfo->key_block[ix-1] < lno);
assert(ix == binfo->first_free || binfo->key_block[ix+1] > lno);
binfo->key_block[ix] = lno;
binfo->value_block[ix] = tno;
binfo->first_free++;
binfo->zeroes--;
}
}
}
#endif
/*
* Delete the local text LNO from the structure L2G.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment