What is the purpose of Raven-Clr-Type?

628 views
Skip to first unread message

Stacey

unread,
Jun 25, 2014, 8:06:02 AM6/25/14
to rav...@googlegroups.com
I thought that the metadata for Raven-Clr-Type was used for the process of deserialization and matching types with the generic given to .Query<T> and .Load<T> - but I tried messing around with it and gave it some pretty strange values, and things continued to work absolutely flawlessly.

So this confuses me a great deal. What purpose does this metadata serve? It doesn't seem like it should be safe to change, but I've not been able to cause a problem by changing it.

Please be aware, I'm not asking how to change it, I figured that part out - I'm just saying that changing it did nothing. However on the reverse, I recall Ayende having to get with me personally once over screen sharing to fix a migration to an app because the Raven-Clr-Type was not set properly.

So this situation suggests to me that the type IS important, and it DOES mean something important, but changing it didn't cause any change to deserialization or saving of documents. 

Alan Ciantar

unread,
Jun 25, 2014, 8:09:59 AM6/25/14
to rav...@googlegroups.com
If I moved the object to another directory

i.e
Project.Folder1.Folder2.Data.SampleData
to 
Project.Folder1.Data.SampleData

Any queries that loaded 'SampleData' type fail because raven-clr-type is using the old one.

Alan Ciantar

unread,
Jun 25, 2014, 8:11:08 AM6/25/14
to rav...@googlegroups.com
Actually, if I recall correctly, they would only fail if _all of the existing database objects_ had the old raven-clr-type. Adding a new one would make it work.

Stacey

unread,
Jun 25, 2014, 8:13:08 AM6/25/14
to rav...@googlegroups.com
The way you put that makes me think it is more like a "Flag" than an actual "type". Like a literal that tells something how to find it, instead of specifying what it is. Is the fact that it isn't causing any trouble just due to me not trying hard enough to break it, or has Raven 3 just advanced so much that it can find discrepancies regardless of what stupid things I put in the meta-data? 

Stacey

unread,
Jun 25, 2014, 8:14:23 AM6/25/14
to rav...@googlegroups.com
This all came about just out of curiosity. I have no need to change the Clr-Type in my program. It is just one of those things where I was writing code, and looking through the database documents, and saw it on the meta-data, and thought "Wow, I wonder what that can be used for ... " so I tried to destroy it. Changing it was actually pretty easy.

Alan Ciantar

unread,
Jun 25, 2014, 8:23:15 AM6/25/14
to rav...@googlegroups.com
I've had to change it before as we have a common "Business Logic" Layer shared among projects.
Whenever we decide to "close" one version to another, we'd have to update the Raven-clr-type as we append the version number to the project (i.e. BusinessLogic_v5)

if (this["@metadata"] != null && this["@metadata"]["Raven-Clr-Type"] != null) {
 
this["@metadata"]["Raven-Clr-Type"] = this["@metadata"]["Raven-Clr-Type"].replace("v5", "v6");
 
this["@metadata"]["Raven-Clr-Type"] = this["@metadata"]["Raven-Clr-Type"].replace("v5", "v6");
}

Stacey

unread,
Jun 25, 2014, 8:27:01 AM6/25/14
to rav...@googlegroups.com
Wow! That's a really good idea! That actually makes total sense. I had never even thought of using it that way. I've always worked on doing version numbers with a simple property on the object.

Michael Yarichuk

unread,
Jun 25, 2014, 8:31:48 AM6/25/14
to rav...@googlegroups.com
Basically what happens is 
1) RavenDB checks if Raven-Clr-Type is valid, and then deserializes to it. 
2) If not, it will try the type you specify (i.e. T in Load<T>() )
3) If all else fails, deserializes as DynamicJsonObject

btw - "Raven-Clr-Type" entry is not hardcoded - DocumentConventions you have FindClrType delegate


--
You received this message because you are subscribed to the Google Groups "RavenDB - 2nd generation document database" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ravendb+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Best regards,

 

Michael Yarichuk

RavenDB Core Team

Tel: 972-4-6227811

Fax:972-153-4-6227811

Email : michael....@hibernatingrhinos.com

 

Stacey

unread,
Jun 25, 2014, 8:39:12 AM6/25/14
to rav...@googlegroups.com
Yeah, FindClrType is what I used to actually do changes to the meta data to find all this out. I'm not asking anyone to write code for me, I'm literally just fascinated by Raven and am reading the source code, but it is WAY over my head, so I'm posting some questions I have here and there as I come across them.

I am at a point in my "career" where I am too educated for much of the traditional "schooling" I could possibly get into to benefit me, but I'm not "good enough" to really be a professional programmer. I have to bridge that gap, and I've determined the only way to do that is both actual experience, and to learn as much as I can, as often as I can, so I am reading through a lot of various projects source code to try and see how they work. I am hoping that it leads me to new things and helps me expand into a better developer. But I am finding Raven's code particularly fascinating.

Oren Eini (Ayende Rahien)

unread,
Jun 25, 2014, 8:43:33 AM6/25/14
to ravendb
matching types with the generic given to .Query<T> and .Load<T>

False


It is merely a helper for for the system, when you load the document, we can use it.

This is very useful if you do something like:

session.Load<ICommnad>(cmd); // get back LaunchMissleCommand



Oren Eini

CEO


Mobile: + 972-52-548-6969

Office:  + 972-4-622-7811

Fax:      + 972-153-4622-7811





--

Oren Eini (Ayende Rahien)

unread,
Jun 25, 2014, 8:43:52 AM6/25/14
to ravendb
No, it would all continue to work.,



Oren Eini

CEO


Mobile: + 972-52-548-6969

Office:  + 972-4-622-7811

Fax:      + 972-153-4622-7811





On Wed, Jun 25, 2014 at 3:11 PM, Alan Ciantar <alan.c...@casasoft.com.mt> wrote:
Actually, if I recall correctly, they would only fail if _all of the existing database objects_ had the old raven-clr-type. Adding a new one would make it work.

--

Oren Eini (Ayende Rahien)

unread,
Jun 25, 2014, 8:45:34 AM6/25/14
to ravendb
Basically, it is there when we don't have the type information, but it if isn't there, we don't sweat it usually, we can get it from the context given to us.

However, you might run into problems when you try to mix types.

For example:

session.Load<Person>("dogs/2");

If the Raven-Clr-Type points to Models.Dog, MyApp

It will throw invalid cast exception.

If it isn't set to a valid type, it will try to match it to Person as best it can.



Oren Eini

CEO


Mobile: + 972-52-548-6969

Office:  + 972-4-622-7811

Fax:      + 972-153-4622-7811





--

Oren Eini (Ayende Rahien)

unread,
Jun 25, 2014, 8:47:00 AM6/25/14
to ravendb
Stacey,
I think that what you are doing is great, and we'll do all we can to help you.

I suggest you pick a single topic, and dive into that, then another, etc.



Oren Eini

CEO


Mobile: + 972-52-548-6969

Office:  + 972-4-622-7811

Fax:      + 972-153-4622-7811





Phillip Haydon

unread,
Jun 25, 2014, 8:55:19 AM6/25/14
to rav...@googlegroups.com
session.Load<Person>("persons/2");

^Using this example...

If Person is define in more than 1 namespace, only the type stored originally will work. Is this still the same case for RavenDB 3 or has this been fixed?

Oren Eini (Ayende Rahien)

unread,
Jun 25, 2014, 8:58:33 AM6/25/14
to ravendb

If the type specified is valid, it must match this or be a super type

Stacey

unread,
Jun 25, 2014, 9:18:50 AM6/25/14
to rav...@googlegroups.com
Thank you, I intend to really pursue this hard. The company I work for recently allowed me to purchase a Pluralsight account too, but training videos only go so far. I see you post things on your blog, and every time I think "Hey, I'm not too bad. I've written a few programs and am getting paid for it" I see you post something like an "interview challenge" and my jaw drops. There is a gap - a severe one, between me and "real" programmers.

Raven is of particular interest to me because (A) you are reknown as an incredible programmer, reading anything that you code and take enough pride in to sell is probably a safe bet at learning something useful (B) I use it everyday, so learning about it directly impacts my day to day operations and choices (C) it HAS a community that is capable of giving me helpful feedback, such as this thread, and (D) it isn't something that is limited to "one" scope of technology. It covers a lot of things, so I think it's the best place to start. 

The topic I am currently working on is pretty much, as you have now guessed, metadata. It's actually pretty shocking stuff. If I am understanding everything right, Metadata isn't really "Meta" at all, but just normal properties on a JSON object that has a specific prefix or is is underneath a specific property so that it gets "Filtered" out when retrieved. 

Stacey

unread,
Jun 25, 2014, 9:21:21 AM6/25/14
to rav...@googlegroups.com
I remember that I once read a blog post where you discussed how you, yourself, go about "reading" a program's source code - if I am correct, you even admitted to me that it is a daunting task to do, and it is sometimes hard to know where to start. I'm trying to find that article again, though I'm not having any luck. Do you recall the title of it off hand?


On Wednesday, June 25, 2014 7:47:00 AM UTC-5, Oren Eini wrote:

Federico Lois

unread,
Jun 25, 2014, 10:07:13 AM6/25/14
to rav...@googlegroups.com
Lol believe me when I say that the interview questions Oren posts rules out 1 in 10 developers. I know because we do the same. We give candidates a week to do an small project with esoteric stuff like gpu, signal processing, etc to people that should be qualified by resume to do R&D. :D Only a handful pass it. Let alone complete them.

From: Stacey
Sent: 25/06/2014 10:18 a.m.
To: rav...@googlegroups.com
Subject: Re: [RavenDB] Re: What is the purpose of Raven-Clr-Type?

Thank you, I intend to really pursue this hard. The company I work for recently allowed me to purchase a Pluralsight account too, but training videos only go so far. I see you post things on your blog, and every time I think "Hey, I'm not too bad. I've written a few programs and am getting paid for it" I see you post something like an "interview challenge" and my jaw drops. There is a gap - a severe one, between me and "real" programmers.

Raven is of particular interest to me because (A) you are reknown as an incredible programmer, reading anything that you code and take enough pride in to sell is probably a safe bet at learning something useful (B) I use it everyday, so learning about it directly impacts my day to day operations and choices (C) it HAS a community that is capable of giving me helpful feedback, such as this thread, and (D) it isn't something that is limited to "one" scope of technology. It covers a lot of things, so I think it's the best place to start. 

The topic I am currently working on is pretty much, as you have now guessed, metadata. It's actually pretty shocking stuff. If I am understanding everything right, Metadata isn't really "Meta" at all, but just normal properties on a JSON object that has a specific prefix or is is underneath a specific property so that it gets "Filtered" out when retrieved. 

Stacey

unread,
Jun 25, 2014, 10:09:44 AM6/25/14
to rav...@googlegroups.com
That makes me feel a little better, at least I'm not just 'stupid', I'm in the same crate as a lot of others. But the fact still remains that there is very much a huge bridge to cross to get to the level where I could appropriately answer questions like that. And college sure didn't prepare me for it. I've done vocational school, and it did not help much, either. I must conclude that raw experience is the only way I can get to that. And to do that, the best I can manage is to scour the resources of greater developers and try to learn.

Kijana Woodard

unread,
Jun 25, 2014, 10:19:16 AM6/25/14
to rav...@googlegroups.com
Now do Load<dynamic> and inspect the object in the debugger....

Now imagine multi map with Query<dynamic>....

From: Stacey
Sent: ‎6/‎25/‎2014 7:06 AM
To: rav...@googlegroups.com
Subject: [RavenDB] What is the purpose of Raven-Clr-Type?

I thought that the metadata for Raven-Clr-Type was used for the process of deserialization and matching types with the generic given to .Query<T> and .Load<T> - but I tried messing around with it and gave it some pretty strange values, and things continued to work absolutely flawlessly.

So this confuses me a great deal. What purpose does this metadata serve? It doesn't seem like it should be safe to change, but I've not been able to cause a problem by changing it.

Please be aware, I'm not asking how to change it, I figured that part out - I'm just saying that changing it did nothing. However on the reverse, I recall Ayende having to get with me personally once over screen sharing to fix a migration to an app because the Raven-Clr-Type was not set properly.

So this situation suggests to me that the type IS important, and it DOES mean something important, but changing it didn't cause any change to deserialization or saving of documents. 

--

Kijana Woodard

unread,
Jun 25, 2014, 10:24:49 AM6/25/14
to rav...@googlegroups.com
The reality is that most people who get paid to program would be completely lost at Oren's interview. Don't sweat it. Just keep learning.

From: Stacey
Sent: ‎6/‎25/‎2014 8:18 AM

--
You received this message because you are subscribed to the Google Groups "RavenDB - 2nd generation document database" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ravendb+u...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.
--
Best regards,

 

Michael Yarichuk

RavenDB Core Team

Tel: 972-4-6227811

Fax:972-153-4-6227811

Email : michael....@hibernatingrhinos.com

 

--
You received this message because you are subscribed to the Google Groups "RavenDB - 2nd generation document database" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ravendb+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Kijana Woodard

unread,
Jun 25, 2014, 10:25:47 AM6/25/14
to rav...@googlegroups.com
Look for the series about LMDB

From: Stacey
Sent: ‎6/‎25/‎2014 8:21 AM

To: rav...@googlegroups.com
Subject: Re: [RavenDB] Re: What is the purpose of Raven-Clr-Type?

I remember that I once read a blog post where you discussed how you, yourself, go about "reading" a program's source code - if I am correct, you even admitted to me that it is a daunting task to do, and it is sometimes hard to know where to start. I'm trying to find that article again, though I'm not having any luck. Do you recall the title of it off hand?

Matt Warren

unread,
Jun 25, 2014, 11:02:32 AM6/25/14
to ravendb
I've heard first-hand of cases of supposedly experienced programmers failing FizzBuzz and I'm not the only one, see http://www.reddit.com/r/cscareerquestions/comments/1ap4ev/do_people_really_fail_fizzbuzz_during_interviews/

Federico Lois

unread,
Jun 26, 2014, 1:16:06 AM6/26/14
to rav...@googlegroups.com
Imho the biggest payoff is in going deep down but also in the diversity. To everyone that asks me I tell them that the biggest thing for me was a amazing selfless act on part of who ended up being my bachelor degree thesis advisor. I saw a couple of posters of Siggraph, being a 1st year student I happened (by random chance or destiny) to ask the Computer Graphics teacher what was it. Not only she explained it to me, she lend me (with the promise to return it after I was done) an original CD with the 1998 proceedings (1999 hadnt been published by the time) That bloody thing cost at the time a more that a month salary. Needless to say I read the entire proceeding during 2 months.

Long story short I learned that in diversity and going way beyond what you think you are able to do is the key. So dont despair with that attitude if you are not already ahead of the average you will be pretty soon. :D

About experience just make sure you are not having the same experience repeated every day ;)

Sent from my Windows Phone

From: Stacey
Sent: 25/06/2014 11:09 a.m.

To: rav...@googlegroups.com
Subject: Re: [RavenDB] Re: What is the purpose of Raven-Clr-Type?

That makes me feel a little better, at least I'm not just 'stupid', I'm in the same crate as a lot of others. But the fact still remains that there is very much a huge bridge to cross to get to the level where I could appropriately answer questions like that. And college sure didn't prepare me for it. I've done vocational school, and it did not help much, either. I must conclude that raw experience is the only way I can get to that. And to do that, the best I can manage is to scour the resources of greater developers and try to learn.

On Wednesday, June 25, 2014 9:07:13 AM UTC-5, Federico Lois wrote:
Lol believe me when I say that the interview questions Oren posts rules out 1 in 10 developers. I know because we do the same. We give candidates a week to do an small project with esoteric stuff like gpu, signal processing, etc to people that should be qualified by resume to do R&D. :D Only a handful pass it. Let alone complete them.

From: Stacey
Sent: 25/06/2014 10:18 a.m.

Stacey Thornton

unread,
Jun 26, 2014, 6:22:04 AM6/26/14
to rav...@googlegroups.com
I will agree to that, diversity is paramount. One of the reasons I have managed to stay aloft isn't because of how good a programmer I am, but because I am the kind of programmer that can put on almost any hat and do it marginally well. 

I come from a rather podunk community where the idea of teaching technology never caught on in schools, so it wasn't until college that I was able to "formally" pursue an education related to programming, and even then my selections were poor at best - at least poor if I wanted to stay near family, which, due to unrelated circumstances, I did. So I was driven on pure passion alone. I would basically save every paycheck and every penny beyond my rent and buy every single .NET book I could possibly find. I think I have by now read the ENTIRE works from Microsoft Press from 2001 to 2006, even things that had NOTHING to do with anything I would ever use.

Eventually, through a stroke of fortune, I happened upon some family friends that owned a tanning salon and they had 5 locations in our city. But they were having a big problem, because there is a specific law that prohibits you from allowing a customer to tan more than a certain period of time in 24 hours using your facilities. So what would happen is a customer would come to one store, tan, and then very quickly go to another store before there was any chance for information to be shared. They needed an answer to this - and I offered to take a stab at it.

What I produced was terrible, but it did work. It did the job, it runs slow as hell, it uses those laughable ASP.NET Web Forms "<dataset>" HTML user control things with horrendously awful queries, and it is so poorly coded that making changes to it is damn near impossible. But it worked. It really, really worked, and it solved their problem. I am even proud to say that even today, right now, they are still using it - and everytime they call me to say it is down, I cringe in horror at diving into that code base, but it's only gone down 3 times in 10 years, and I do not know about the rest of you but I think that is a net gain, and a very good record for any application - especially one that runs online.

So that is where I am starting again. I am rewriting that companies program using everything I have learned in the past several years and making it right this time. 


You received this message because you are subscribed to a topic in the Google Groups "RavenDB - 2nd generation document database" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ravendb/9T4BaohSUzY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ravendb+u...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages