lisp / de.setf.thrift Goto Github PK
View Code? Open in Web Editor NEWA Common Lisp binding for the Apache Thrift framework
A Common Lisp binding for the Apache Thrift framework
Hi James,
I'm trying to use this library in a slightly uncommon way: just to serialize data (the purpose is to compare different serialization methods, like: protocol-buffers, bson etc).
For that I use a simple example of a file-system hierarchy, that can be expressed in sexp form like this:
("root" :owner "root" :group "adm" :rights (7 5 5)
("docs" :owner "root" :group "adm" :rights (7 5 5)
("article.pdf" :owner "root" :group "adm" :rights (6 4 4)
"This is a sample article. It's rather short")
("example.pdf" :owner "root" :group "adm" :rights (6 4 4)
"123456")
("example.pdf~" :owner "root" :group "adm" :rights (6 4 0)
"And this is a backup of example.pdf")))
I've tried to implement it with the following structures:
(thrift:def-enum "node-type"
(("FILE" . 1)
("DIR" . 2)))
(thrift:def-struct "rights"
((u 0 :type 'byte :id 1)
(g 0 :type 'byte :id 2)
(o 0 :type 'byte :id 3)))
(thrift:def-struct "node"
((type nil :type 'node-type :id 1)
(name nil :type 'string :id 2)
(owner nil :type 'string :id 3)
(group nil :type 'string :id 4)
(rights nil :type 'rights :id 5)
(content nil :type 'string :optional t :id 6)
(nodes nil :type '(list node) :optional t :id 7)))
Then I've tried to encode them in binary form with thrift:stream-write-struct, but it failed (with the following error: There is no applicable method for the generic function #<STANDARD-GENERIC-FUNCTION ORG.APACHE.THRIFT.IMPLEMENTATION::STREAM-WRITE-FIELD-BEGIN (1)> when called with arguments (#<ORG.APACHE.THRIFT:BINARY-PROTOCOL {B43ED99}> TYPE 'NODE-TYPE 1).)
After a lot of searching I came to the conclusion, that Thrift in general and its client libraries (like this one in particular) really lack in terms of good and rich examples of IDL definitions and usage. Maybe, you could spend some time to create such example, using my data as a starting point? Or at least provide clues, how to move forward, and I'll try to create the example myself.
Thanks!
Vsevolod
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.