Re: Low-level, Efficient Ternary Search Trees for Storing Strings?
- From: "dpapathanasiou" <denis.papathanasiou@xxxxxxxxx>
- Date: 30 Mar 2007 05:56:14 -0700
Point taken about the array definition; I should *not* use :element-
type 'char since only :split-char is a char and all the :*-kid
components are themselves trie objects, not chars.
But even if I switch from an array to a defstruct, I still wind up
with a very bulky S-expression.
Using this (which, as you say is better, since it offers built-in
make, access and setting functions):
(defstruct trie
split-char
lo-kid
eq-kid
hi-kid)
If I create a trie to hold a two-letter string, e.g. "as", I get this
S-expression:
#S(TRIE
:SPLIT-CHAR #\a
:LO-KID #S(TRIE :SPLIT-CHAR NIL :LO-KID NIL :EQ-KID NIL :HI-KID
NIL)
:EQ-KID #S(TRIE
:SPLIT-CHAR #\s
:LO-KID #S(TRIE
:SPLIT-CHAR NIL
:LO-KID NIL
:EQ-KID NIL
:HI-KID NIL)
:EQ-KID #S(TRIE
:SPLIT-CHAR NIL
:LO-KID NIL
:EQ-KID NIL
:HI-KID NIL)
:HI-KID #S(TRIE
:SPLIT-CHAR NIL
:LO-KID NIL
:EQ-KID NIL
:HI-KID NIL))
:HI-KID #S(TRIE :SPLIT-CHAR NIL :LO-KID NIL :EQ-KID NIL :HI-KID
NIL))
Serialized to disk, that's 866 bytes.
Versus just 2 bytes (4 counting the double-quotes to denote it as a
string object) if I write "as" just like that.
So what I was getting at was: is there any way of packing the trie
data into a low-level, compact, efficient data structure, similar to
what the other post did for multiple integers into fixnums?
I'd like to be able to use tries for searching, but if I'm stuck
serializing such large S-expressions, I'd be better off saving them as
raw strings and using a fast library like cl-ppcre instead.
.
- Follow-Ups:
- Re: Low-level, Efficient Ternary Search Trees for Storing Strings?
- From: Thomas F. Bur***
- Re: Low-level, Efficient Ternary Search Trees for Storing Strings?
- From: truls . becken
- Re: Low-level, Efficient Ternary Search Trees for Storing Strings?
- References:
- Low-level, Efficient Ternary Search Trees for Storing Strings?
- From: dpapathanasiou
- Re: Low-level, Efficient Ternary Search Trees for Storing Strings?
- From: Rainer Joswig
- Low-level, Efficient Ternary Search Trees for Storing Strings?
- Prev by Date: Re: sharp-back syntax
- Next by Date: Re: Low-level, Efficient Ternary Search Trees for Storing Strings?
- Previous by thread: Re: Low-level, Efficient Ternary Search Trees for Storing Strings?
- Next by thread: Re: Low-level, Efficient Ternary Search Trees for Storing Strings?
- Index(es):