You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jackrabbit.apache.org by danisevsky <da...@gmail.com> on 2010/11/27 12:01:29 UTC
combining data from relational db and jcr
Hello, I have users stored in relational db. Each user has its own
jacrabbit folder in which are photos, comments, etc. Folder is created
after user registration. I do not know how to best create path to this
folder. I am thinking about this algorithm:
public static String createFolderPathForUser(User user) {
StringBuilder path = new StringBuilder();
String uuid = UUID.randomUUID().toString();
String shorterUUID = uuid.substring(0, 10);
char[] chars = new char[shorterUUID.length()];
shorterUUID.getChars(0, shorterUUID.length(), chars, 0);
for (int i = 0; i < chars.length; i++) {
path.append(chars[i] + "/");
}
path.append(user.getId());
return path.toString();
}
which get for user with id=123 e.g. this path:
1/4/c/9/6/7/b/c/-/e/123
and this path save to user field in relational db.
Is it good solutions? A have not much experiences with jackrabbit.
Thanks.
Re: combining data from relational db and jcr
Posted by Ard Schrijvers <a....@onehippo.com>.
2010/11/27 Fabián Mandelbaum <fm...@gmail.com>:
> Well, indeed I've heard that recommendation over and over again... but
> did you make tests with thousands of nodes and got bad performance? Or,
You don't need to test this as this is commonly know already. You will
get bad performance.
> I don't know about the 'cost' of doing such tests though, but I'd try
> 'em quickly because using the ID directly as the 'key' is far simpler
> than manipulating the ID everytime (which is also time consuming, even
> if computers do compute very fast).
I cannot say that it doesn't cost time, because obviously it does cost
some cpu cycles, but this won't be noticeable at all. Creating the
idea is like 1 billionth of the time it takes to actually create the
folders. I don't think the random folder structure is a bad idea. You
can also create the user 123 below
/users/1/2/3
Furthermore, I don't think you should store the jcr path back into the
database of the created user! You can much better store the identifier
of the created user node.
Regards Ard
>
> Just an idea. I'll let other, more experienced, JackRabbit guys jump in
> here if they have better ideas (I'm sure some will).
>
> El 27/11/10 08:50, danisevsky escribió:
>> Users may be tens of thousands and I think it is recomended "go deep"
>> instead of "go wide".
>>
Re: combining data from relational db and jcr
Posted by Fabián Mandelbaum <fm...@gmail.com>.
Well, indeed I've heard that recommendation over and over again... but
did you make tests with thousands of nodes and got bad performance? Or,
did you make tests with both approachs and got better performance with
createFolderPathForUser instead of using simply the ID 'as is'?
I don't know about the 'cost' of doing such tests though, but I'd try
'em quickly because using the ID directly as the 'key' is far simpler
than manipulating the ID everytime (which is also time consuming, even
if computers do compute very fast).
Just an idea. I'll let other, more experienced, JackRabbit guys jump in
here if they have better ideas (I'm sure some will).
El 27/11/10 08:50, danisevsky escribió:
> Users may be tens of thousands and I think it is recomended "go deep"
> instead of "go wide".
>
> 2010/11/27 Fabián Mandelbaum <fm...@gmail.com>:
>
>> El 27/11/10 08:01, danisevsky escribió:
>>
>>> Hello, I have users stored in relational db. Each user has its own
>>> jacrabbit folder in which are photos, comments, etc. Folder is created
>>> after user registration. I do not know how to best create path to this
>>> folder. I am thinking about this algorithm:
>>>
>>> public static String createFolderPathForUser(User user) {
>>> StringBuilder path = new StringBuilder();
>>> String uuid = UUID.randomUUID().toString();
>>> String shorterUUID = uuid.substring(0, 10);
>>> char[] chars = new char[shorterUUID.length()];
>>> shorterUUID.getChars(0, shorterUUID.length(), chars, 0);
>>> for (int i = 0; i < chars.length; i++) {
>>> path.append(chars[i] + "/");
>>> }
>>> path.append(user.getId());
>>> return path.toString();
>>> }
>>>
>>> which get for user with id=123 e.g. this path:
>>>
>>> 1/4/c/9/6/7/b/c/-/e/123
>>>
>>> and this path save to user field in relational db.
>>>
>>> Is it good solutions? A have not much experiences with jackrabbit.
>>>
>>> Thanks.
>>>
>>>
>> Hello,
>>
>> why not just /users/123 ?
>>
>>
Re: combining data from relational db and jcr
Posted by danisevsky <da...@gmail.com>.
Users may be tens of thousands and I think it is recomended "go deep"
instead of "go wide".
2010/11/27 Fabián Mandelbaum <fm...@gmail.com>:
> El 27/11/10 08:01, danisevsky escribió:
>> Hello, I have users stored in relational db. Each user has its own
>> jacrabbit folder in which are photos, comments, etc. Folder is created
>> after user registration. I do not know how to best create path to this
>> folder. I am thinking about this algorithm:
>>
>> public static String createFolderPathForUser(User user) {
>> StringBuilder path = new StringBuilder();
>> String uuid = UUID.randomUUID().toString();
>> String shorterUUID = uuid.substring(0, 10);
>> char[] chars = new char[shorterUUID.length()];
>> shorterUUID.getChars(0, shorterUUID.length(), chars, 0);
>> for (int i = 0; i < chars.length; i++) {
>> path.append(chars[i] + "/");
>> }
>> path.append(user.getId());
>> return path.toString();
>> }
>>
>> which get for user with id=123 e.g. this path:
>>
>> 1/4/c/9/6/7/b/c/-/e/123
>>
>> and this path save to user field in relational db.
>>
>> Is it good solutions? A have not much experiences with jackrabbit.
>>
>> Thanks.
>>
>
> Hello,
>
> why not just /users/123 ?
>
Re: combining data from relational db and jcr
Posted by Fabián Mandelbaum <fm...@gmail.com>.
El 27/11/10 08:01, danisevsky escribió:
> Hello, I have users stored in relational db. Each user has its own
> jacrabbit folder in which are photos, comments, etc. Folder is created
> after user registration. I do not know how to best create path to this
> folder. I am thinking about this algorithm:
>
> public static String createFolderPathForUser(User user) {
> StringBuilder path = new StringBuilder();
> String uuid = UUID.randomUUID().toString();
> String shorterUUID = uuid.substring(0, 10);
> char[] chars = new char[shorterUUID.length()];
> shorterUUID.getChars(0, shorterUUID.length(), chars, 0);
> for (int i = 0; i < chars.length; i++) {
> path.append(chars[i] + "/");
> }
> path.append(user.getId());
> return path.toString();
> }
>
> which get for user with id=123 e.g. this path:
>
> 1/4/c/9/6/7/b/c/-/e/123
>
> and this path save to user field in relational db.
>
> Is it good solutions? A have not much experiences with jackrabbit.
>
> Thanks.
>
Hello,
why not just /users/123 ?