Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > [ANN] Mongoose 0.2.0

Reply
Thread Tools

[ANN] Mongoose 0.2.0

 
 
Jamey Cribbs
Guest
Posts: n/a
 
      07-21-2006
You can download it from: http://rubyforge.org/projects/mongoose/

*What's New*

Thanks, to Ezra Zygmuntowicz, this release features a much cleaner query
language, so I decided to get this out before anyone gets too used to
the old version. Ezra pointed out how I could eliminate having to pass
the table's class as a block parameter to the query, and also eliminate
having to qualify every column name in the query with the table's
class. So, a query that looked like this:

Plane.find do |plane|
plane.speed > 350
plane.any do
plane.country == 'USA'
plane.country == 'Great Britain'
end
end

Now, looks like this:

Plane.find do
speed > 350
any do
country == 'USA'
country == 'Great Britain'
end
end

Much cleaner. Thanks Ezra!

Also, Ezra contributed a Table.create method and Logan Capaldo
contributed a fix to eliminate a string eval. There is a new example
script from Daniel Sheppard showing how to integrate ActiveRecord
validations into Mongoose. Plus the usual code cleanup and bug fixes.

*What is Mongoose?*

Mongoose is a database management system written in Ruby. It has an
ActiveRecord-like interface, uses Skiplists for its indexing, and
Marshal for its data serialization. I named it Mongoose, because, like
Rudyard Kipling's Rikki-Tikki-Tavi, my aim is for it to be small, quick,
and friendly.

You can find rudimentary documentation in the README file and some
sample scripts in the example directory.

Jamey Cribbs


 
Reply With Quote
 
 
 
 
Logan Capaldo
Guest
Posts: n/a
 
      07-21-2006

On Jul 21, 2006, at 12:49 PM, Jamey Cribbs wrote:

> You can download it from: http://rubyforge.org/projects/mongoose/
>
> *What's New*
>
> Thanks, to Ezra Zygmuntowicz, this release features a much cleaner
> query language, so I decided to get this out before anyone gets too
> used to the old version. Ezra pointed out how I could eliminate
> having to pass the table's class as a block parameter to the query,
> and also eliminate having to qualify every column name in the query
> with the table's class. So, a query that looked like this:
>
> Plane.find do |plane|
> plane.speed > 350
> plane.any do
> plane.country == 'USA' plane.country == 'Great Britain'
> end
> end
>
> Now, looks like this:
>
> Plane.find do
> speed > 350
> any do
> country == 'USA'
> country == 'Great Britain'
> end
> end
>
> Much cleaner. Thanks Ezra!
>
> Also, Ezra contributed a Table.create method and Logan Capaldo
> contributed a fix to eliminate a string eval. There is a new
> example script from Daniel Sheppard showing how to integrate
> ActiveRecord validations into Mongoose. Plus the usual code
> cleanup and bug fixes.
>
> *What is Mongoose?*
>
> Mongoose is a database management system written in Ruby. It has
> an ActiveRecord-like interface, uses Skiplists for its indexing,
> and Marshal for its data serialization. I named it Mongoose,
> because, like Rudyard Kipling's Rikki-Tikki-Tavi, my aim is for it
> to be small, quick, and friendly.
>
> You can find rudimentary documentation in the README file and some
> sample scripts in the example directory.
>
> Jamey Cribbs
>
>


I'm just too slow with sending in my patches.


 
Reply With Quote
 
 
 
 
simonh
Guest
Posts: n/a
 
      07-21-2006
Jamey, just out of curiosity, how long did it take you to write
mongoose 0.1.0? Also Do you think mongoose will be more maintainable
now its split into multiple files?

 
Reply With Quote
 
Jamey Cribbs
Guest
Posts: n/a
 
      07-21-2006
simonh wrote:
> Jamey, just out of curiosity, how long did it take you to write
> mongoose 0.1.0? Also Do you think mongoose will be more maintainable
> now its split into multiple files?
>
>

I probably started working on it the middle of last week and have been
working on it in most of my spare time (probably a 2-3 hours a day; my
wife would probably say more like 5-6 hours a day ). However, over
the last few months, I had already been experimenting with Skiplists and
with using Marshal for storage. Also, I was able to borrow some great
code from Logan Capaldo's KirbyRecord.

Yes, I do think it will be more maintainable. KirbyBase is one BIG file
and, so far, I definitely like the feel of having Mongoose split up into
different files for different components.

Jamey

Confidentiality Notice: This email message, including any attachments, is for the sole use of the intended recipient(s) and may contain confidential and/or privileged information. If you are not the intended recipient(s), you are hereby notified that any dissemination, unauthorized review, use, disclosure or distribution of this email and any materials contained in any attachments is prohibited. If you receive this message in error, or are not the intended recipient(s), please immediately notify the sender by email and destroy all copies of the original message, including attachments.

 
Reply With Quote
 
Logan Capaldo
Guest
Posts: n/a
 
      07-21-2006

On Jul 21, 2006, at 2:39 PM, Jamey Cribbs wrote:

> simonh wrote:
>> Jamey, just out of curiosity, how long did it take you to write
>> mongoose 0.1.0? Also Do you think mongoose will be more maintainable
>> now its split into multiple files?
>>
>>

> I probably started working on it the middle of last week and have
> been working on it in most of my spare time (probably a 2-3 hours a
> day; my wife would probably say more like 5-6 hours a day ).
> However, over the last few months, I had already been experimenting
> with Skiplists and with using Marshal for storage. Also, I was
> able to borrow some great code from Logan Capaldo's KirbyRecord.
>
> Yes, I do think it will be more maintainable. KirbyBase is one BIG
> file and, so far, I definitely like the feel of having Mongoose
> split up into different files for different components.
>
> Jamey
>
> Confidentiality Notice: This email message, including any
> attachments, is for the sole use of the intended recipient(s) and
> may contain confidential and/or privileged information. If you are
> not the intended recipient(s), you are hereby notified that any
> dissemination, unauthorized review, use, disclosure or distribution
> of this email and any materials contained in any attachments is
> prohibited. If you receive this message in error, or are not the
> intended recipient(s), please immediately notify the sender by
> email and destroy all copies of the original message, including
> attachments.
>


Jamey, while we are on the topic of Mongoose, since the query
language isn't straight up "loop thru all the records of the table,
pass the row into this proc and see if it returns true", any chance
of query optimization and or arbitrary joins? If not, would you
object if I tried my hand at adding joins and query optimization?
(This is not a promise, it's more like if I have time it will slowly
start to show up).

I have a couple of ideas, One involving how to do Hash-based equi-
joins and cheat a little bit, if what i believe about Marshal is true
and reliable.


 
Reply With Quote
 
John W. Long
Guest
Posts: n/a
 
      07-21-2006
Jamey Cribbs wrote:
> Plane.find do |plane|
> plane.speed > 350
> plane.any do
> plane.country == 'USA' plane.country == 'Great Britain'
> end
> end
>
> Now, looks like this:
>
> Plane.find do
> speed > 350
> any do
> country == 'USA'
> country == 'Great Britain'
> end
> end


James, could you elaborate on how this is done? I would assume that the
first method is better because you don't lose the the surrounding scope.
What's going on in that do block?

--
John Long
http://wiseheartdesign.com

 
Reply With Quote
 
Jamey Cribbs
Guest
Posts: n/a
 
      07-21-2006
Logan Capaldo wrote:
>
> Jamey, while we are on the topic of Mongoose, since the query language
> isn't straight up "loop thru all the records of the table, pass the
> row into this proc and see if it returns true", any chance of query
> optimization and or arbitrary joins? If not, would you object if I
> tried my hand at adding joins and query optimization? (This is not a
> promise, it's more like if I have time it will slowly start to show up).
>

That would be great. That's one of the things I am really excited about
Mongoose is that, now that I can look at the query *before* it is
executed (unlike KirbyBase), it can be optimized. I've already got a
few ideas about query optimization, but I would definitely welcome both
ideas and code.
> I have a couple of ideas, One involving how to do Hash-based
> equi-joins and cheat a little bit, if what i believe about Marshal is
> true and reliable.
>
>
>

Sounds good!

Jamey

Confidentiality Notice: This email message, including any attachments, is for the sole use of the intended recipient(s) and may contain confidential and/or privileged information. If you are not the intended recipient(s), you are hereby notified that any dissemination, unauthorized review, use, disclosure or distribution of this email and any materials contained in any attachments is prohibited. If you receive this message in error, or are not the intended recipient(s), please immediately notify the sender by email and destroy all copies of the original message, including attachments.

 
Reply With Quote
 
Jamey Cribbs
Guest
Posts: n/a
 
      07-21-2006
Joey wrote:
> country in ['USA','Great Britian']
> would be nice!

I will add it to the feature requests list.

By the way, you can currently do:

country.one_of 'USA', 'Great Britain'

which is pretty close.

Jamey

Confidentiality Notice: This email message, including any attachments, is for the sole use of the intended recipient(s) and may contain confidential and/or privileged information. If you are not the intended recipient(s), you are hereby notified that any dissemination, unauthorized review, use, disclosure or distribution of this email and any materials contained in any attachments is prohibited. If you receive this message in error, or are not the intended recipient(s), please immediately notify the sender by email and destroy all copies of the original message, including attachments.

 
Reply With Quote
 
Jamey Cribbs
Guest
Posts: n/a
 
      07-21-2006
John W. Long wrote:
> Jamey Cribbs wrote:
>> Plane.find do |plane|
>> plane.speed > 350
>> plane.any do
>> plane.country == 'USA' plane.country == 'Great Britain'
>> end
>> end
>>
>> Now, looks like this:
>>
>> Plane.find do
>> speed > 350
>> any do
>> country == 'USA'
>> country == 'Great Britain'
>> end
>> end

>
> James, could you elaborate on how this is done? I would assume that
> the first method is better because you don't lose the the surrounding
> scope. What's going on in that do block?

Actually, I like the second way better, because you don't have to
clutter up your query with lots of references to your table class.

The way it works is that in the Plane.find method, I grab the block and
pass it to #instance_eval. This executes the block in the Plane classes
environment, so it knows that when it sees the attribute "speed" or
"country" in the block, it knows to call Plane.speed and Plane.country.
Planes.speed happens to be a reference to a SkiplistColumn instance and
it knows how to handle the "> 350" passed to it.

I have to credit Ezra for pointing me to this.

The reference to "any" just calls Plane.any which is a method in the
Plane class that knows how to take the block inside of it and format it
as a sub-query of the main query.

Jamey

Confidentiality Notice: This email message, including any attachments, is for the sole use of the intended recipient(s) and may contain confidential and/or privileged information. If you are not the intended recipient(s), you are hereby notified that any dissemination, unauthorized review, use, disclosure or distribution of this email and any materials contained in any attachments is prohibited. If you receive this message in error, or are not the intended recipient(s), please immediately notify the sender by email and destroy all copies of the original message, including attachments.

 
Reply With Quote
 
John W. Long
Guest
Posts: n/a
 
      07-22-2006
Jamey Cribbs wrote:
> The way it works is that in the Plane.find method, I grab the block and
> pass it to #instance_eval. This executes the block in the Plane classes
> environment, so it knows that when it sees the attribute "speed" or
> "country" in the block, it knows to call Plane.speed and Plane.country.
> Planes.speed happens to be a reference to a SkiplistColumn instance and
> it knows how to handle the "> 350" passed to it.


The problem with this approach is that you loose access to instance
variables. For instance:

>> class Object
>> def with(&block)
>> instance_eval(&block)
>> end
>> end

=> nil
>> @test = 1

=> 1
>> Object.new.with { puts @test }

=> nil

In the above example @test when used within the context of the with
block is thought to be an instance variable of the object, which is why
it returns nil instead of 1. I consider this behavior undesirable.

--
John Long
http://wiseheartdesign.com

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to do HTTPS using mongoose as a library? claudiomsjunior@yahoo.com C++ 4 07-17-2012 10:57 PM
[ANN] Mongoose 0.2.5 - The "Two Steps Forward, One Step Back"release Jamey Cribbs Ruby 19 07-28-2006 07:02 PM
[ANN] Mongoose 0.1.1 Jamey Cribbs Ruby 0 07-20-2006 07:02 PM
[ANN] Mongoose 0.1.0 Jamey Cribbs Ruby 4 07-20-2006 01:13 AM
[ANN] "Mongoose" catches runaway Pythons (Initial release v0.1) Follower Python 0 05-07-2004 02:47 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57