You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-dev@db.apache.org by Daniel John Debrunner <dj...@apache.org> on 2007/03/15 16:11:10 UTC
Collation implementation WAS Re: Should COLLATION attribute related
code go in BasicDatabase?
Mamta Satoor wrote:
> Ok, so I spent some time trying to move COLLATION attribute code from
> DataDictionaryImpl.boot to DataValueFactoryImpl.boot. I thought I could
> simply put following piece of code in DataValueFactoryImpl.boot method
> and the Property.COLLATION will get saved in the properties
> conglomerate.
I think some of this goes back to the intended implementation.
The intended implementation seems to be that there will be variants of
the four character datatypes with locale based collation. This is four
new (internal) datatypes in Derby that share most code with the existing
CHAR, VARCHAR, LONG VARCHHAR and CLOB types.
I'm not sure this is the correct approach.
My first thought is that this doesn't scale and doesn't seem like an OO
solution. To think ahead this means any addition collation style will
also add four new datatypes, which means there could easily be sixteen
or more datatypes to represent the characters. Each datatype will come
with some code cost, classes and/or methods per type.
My second concern is that many places get characters and the change must
ensure they get the correct datatype, apart from potentially being a lot
of work, the chance of missing some or picking the wrong character types
seems high.
What is really required is 'character type + collation'. I've been
thinking that looking at the problem in this way may make it more
manageable and easier to contain, with the main idea being only worry
about collation type when actually performing a collation. So some
initial ideas:
- collation is a attribute of DataTypeDescriptor, not valid for non
character types, 0 for UCS_BASIC, 1 for UNICODE etc.
int getCollationType();
- A method on DataValueFactory, returns null if type is UCS_BASIC
RuleBasedCollator getCharacterCollator(int type)
- A method on StringDataValue
StringDataValue getValue(RuleBasedCollator collator)
For SQLChar:
getValue(null) would return itself
getValue(non-null) would return a new CollateSQLChar() with
the value of the SQLChar and the collator set.
For CollatorSQLChar
getValue(null) would return a new SQLChar() with the value
of the CollateSQLChar
getValue(non-null) would return itself with the collator set
correctly.
- The collation type (the integer) is written into the meta-data for an
index just as ascending/descending is today (including the btree control
row, thus making the information available for recovery). Collation type
applies to all character columns in the index.
- At SQL collation time, the code generation sets up the various types
correctly using the new methods.
- At recovery time the btree uses the collation type and the data value
factory to setup its template row array correctly. Something like
for each dvd in row array
if (dvd instanceof StringDataValue)
dvd = dvd.getValue(dvf.getCharacterCollator(type));
- setting the collation property remains in the data dictionary
- basic database sets the locale for the DataValueFactory after it boots
it, using a new method on DVF
void setLocale(Locale locale);
I think approaching the problem this way will lead to a cleaner solution
in the long term and be somewhat easier to implement.
Thanks,
Dan.
Re: Collation implementation WAS Re: Should COLLATION attribute related
code go in BasicDatabase?
Posted by Mike Matrigali <mi...@sbcglobal.net>.
Mamta Satoor wrote:
> Excuse my ignorance, but what does it mean by "order by that spills to
> the disk"?
My interpretation of this is that when derby executes a statement with
an order by it has to somehow sort the rows. Derby has 2 methods of
doing this:
1) Carefully craft the execution plan to take advantage of an existing
index that exactly matches the order by.
2) Throw all the result rows into the sorter.
In case 2 there are basically 2 paths through the code:
1) if we have enough memory we sort all the rows in memory.
2) if we don't have enough memory we "spill to disk", basically we use
a disk based sort algorithm. This code is different from the btree
index code.
>
> Mamta
>
>
> On 3/15/07, *Mike Matrigali* <mikem_app@sbcglobal.net
> <ma...@sbcglobal.net>> wrote:
>
>
>
> Daniel John Debrunner wrote:
> > Rick Hillegas wrote:
> >
> >> Daniel John Debrunner wrote:
> >>
> >>> ...
> >>>
> >>> - The collation type (the integer) is written into the
> meta-data for
> >>> an index just as ascending/descending is today (including the btree
> >>> control row, thus making the information available for recovery).
> >>> Collation type applies to all character columns in the index.
> >>>
> >> This suggests that all of the columns in the index must have the
> same
> >> collation? I don't think that is powerful enough to support the
> >> full-blown SQL collation language, which allows you to mix
> differently
> >> collated columns in an ORDER BY clause. Why can't the collation
> type
> >> be an array of ints just as the sort direction is an array of
> booleans
> >> in IndexDescriptor?
> >
> >
> > That would be more flexible, but is it required? Is an order by that
> > spills to disk implemented using a BTREE?
>
> No, order by that spills to disk is implemented by the sorter.
>
> >
> > Thanks,
> > Dan.
> >
> >
> >
>
>
Re: Collation implementation WAS Re: Should COLLATION attribute related code go in BasicDatabase?
Posted by Mamta Satoor <ms...@gmail.com>.
Excuse my ignorance, but what does it mean by "order by that spills to the
disk"?
Mamta
On 3/15/07, Mike Matrigali <mi...@sbcglobal.net> wrote:
>
>
>
> Daniel John Debrunner wrote:
> > Rick Hillegas wrote:
> >
> >> Daniel John Debrunner wrote:
> >>
> >>> ...
> >>>
> >>> - The collation type (the integer) is written into the meta-data for
> >>> an index just as ascending/descending is today (including the btree
> >>> control row, thus making the information available for recovery).
> >>> Collation type applies to all character columns in the index.
> >>>
> >> This suggests that all of the columns in the index must have the same
> >> collation? I don't think that is powerful enough to support the
> >> full-blown SQL collation language, which allows you to mix differently
> >> collated columns in an ORDER BY clause. Why can't the collation type
> >> be an array of ints just as the sort direction is an array of booleans
> >> in IndexDescriptor?
> >
> >
> > That would be more flexible, but is it required? Is an order by that
> > spills to disk implemented using a BTREE?
>
> No, order by that spills to disk is implemented by the sorter.
>
> >
> > Thanks,
> > Dan.
> >
> >
> >
>
>
Re: Collation implementation WAS Re: Should COLLATION attribute related
code go in BasicDatabase?
Posted by Mike Matrigali <mi...@sbcglobal.net>.
Daniel John Debrunner wrote:
> Rick Hillegas wrote:
>
>> Daniel John Debrunner wrote:
>>
>>> ...
>>>
>>> - The collation type (the integer) is written into the meta-data for
>>> an index just as ascending/descending is today (including the btree
>>> control row, thus making the information available for recovery).
>>> Collation type applies to all character columns in the index.
>>>
>> This suggests that all of the columns in the index must have the same
>> collation? I don't think that is powerful enough to support the
>> full-blown SQL collation language, which allows you to mix differently
>> collated columns in an ORDER BY clause. Why can't the collation type
>> be an array of ints just as the sort direction is an array of booleans
>> in IndexDescriptor?
>
>
> That would be more flexible, but is it required? Is an order by that
> spills to disk implemented using a BTREE?
No, order by that spills to disk is implemented by the sorter.
>
> Thanks,
> Dan.
>
>
>
Re: Collation implementation WAS Re: Should COLLATION attribute related
code go in BasicDatabase?
Posted by Daniel John Debrunner <dj...@apache.org>.
Mike Matrigali wrote:
> physically I am not sure the best way to store it.
>
> Are we sure the collation id can be represented as an INT? I may have
> missed it but do we expect a different number here for each different
> language, or is there a single number that says sort based on language
> and go look up language somewhere else?
Single values, the locale is fixed by the database:
0 - collation using code point order UCS_BASIC
1 - collation using the locale of the current database ("unicode")
2 - collation using LOWER() with the locale of the current database
("unicode")
3 - collation using UPPER() with the locale of the current database
("unicode")
These map to the way SQL does it, which is fixed names for collations.
Now I guess in theory there could be additional futures of:
collate according a specific locale (e.g. french) in a database of a
different locale.
collate according to a user defined class
My guess these could be handled with an integer and indirection. The
DataValueFactory would assign values dynamically within a database, so
it would use 100 for locale french and also store in service.properties
the mapping between collation 100 and locale french. And of course in a
different database 100 might mean collate using com.acme.myapp.MyCollator.
So I think single values will suffice.
> options include:
> 1) most straight forward would be an array with an entry for each column
> whether it is character or not. If we use compressedInteger format we
> can get away with only 1 byte per "null" entry. Note on the way out it
> is easy to tell if it is a character, but on the way back we only have
> format id's. I was hoping to have a single call to datafactory(format
> id, collate id) and get back the correct object.
>
> Will it ever make sense to assocate a collation with something other
> than a character type?
Not that I can think of, and I think an int range provides for lots of
expansion.
> 2) some sort of encoded sparse index with entries only for the character
> columns (anyone know if there is a java utility to do this)? The
> downside is that this usually means even more data stored than option 1
> in some cases.
One option is if there are no character columns don't have the array.
> 3) some sort of format that on read would depend on first getting an
> uncollated datatype of type format-id and then regetting it based on
> some code. So maybe some extra object creation and extra cpu overhead
> to create the template in readExternal.
Not sure how this would work.
Dan.
Re: Collation implementation WAS Re: Should COLLATION attribute related
code go in BasicDatabase?
Posted by Mike Matrigali <mi...@sbcglobal.net>.
Daniel John Debrunner wrote:
> Mike Matrigali wrote:
>
>> Ok, so effectively language will store collation information on a per
>> column basis. 10.3 will interpret 0 representing USC_BASIC, and some
>> to be defined method will assign other values for other collations.
>> Will need to make sure there aren't any jdbc calls that blindly return
>> scale currently for character types.
>
>
> I had to rush the last e-mail about scale since I had to pick my son up
> from school, so sorry for that.
>
> I'm not saying that DataTypeDescriptor.getScale() for a character column
> changes in any way, its api remains the same which would be to return
> zero for any character column.
>
> However for a character datatype we could use the space on-disk that
> scale currently occupies to write collation information, since it's
> always written as zero currently for characters. So the writeExternal()
> would have something like (not actual methods)
>
> if (i_am_character_type)
> out.writeInt(collation);
> else
> out.writeInt(scale);
>
>
> and the readExternal
>
> int v = in.readInt();
> if (i_am_character_type)
> {
> collation = v;
> scale = 0;
> }
> else
> {
> scale = v;
> }
>
> Hope that clears that up.
> Dan.
thanks, that is what I thought. I didn't really think about how the
metadata would be returned for scale - probably still worth making sure
we test the metadata scale call in a collated db.
I am just getting clear in my mind what we are doing with language
metadata in the proposal. Since we are writing per-column metadata for
collation in language, it is harder for
me to argue against per column metadata in store.
physically I am not sure the best way to store it.
Are we sure the collation id can be represented as an INT? I may have
missed it but do we expect a different number here for each different
language, or is there a single number that says sort based on language
and go look up language somewhere else?
options include:
1) most straight forward would be an array with an entry for each column
whether it is character or not. If we use compressedInteger format we
can get away with only 1 byte per "null" entry. Note on the way out it
is easy to tell if it is a character, but on the way back we only have
format id's. I was hoping to have a single call to datafactory(format
id, collate id) and get back the correct object.
Will it ever make sense to assocate a collation with something other
than a character type?
2) some sort of encoded sparse index with entries only for the character
columns (anyone know if there is a java utility to do this)? The
downside is that this usually means even more data stored than option 1
in some cases.
3) some sort of format that on read would depend on first getting an
uncollated datatype of type format-id and then regetting it based on
some code. So maybe some extra object creation and extra cpu overhead
to create the template in readExternal.
>
>
>
>
Re: Collation implementation WAS Re: Should COLLATION attribute related
code go in BasicDatabase?
Posted by Daniel John Debrunner <dj...@apache.org>.
Mike Matrigali wrote:
> Ok, so effectively language will store collation information on a per
> column basis. 10.3 will interpret 0 representing USC_BASIC, and some
> to be defined method will assign other values for other collations. Will
> need to make sure there aren't any jdbc calls that blindly return
> scale currently for character types.
I had to rush the last e-mail about scale since I had to pick my son up
from school, so sorry for that.
I'm not saying that DataTypeDescriptor.getScale() for a character column
changes in any way, its api remains the same which would be to return
zero for any character column.
However for a character datatype we could use the space on-disk that
scale currently occupies to write collation information, since it's
always written as zero currently for characters. So the writeExternal()
would have something like (not actual methods)
if (i_am_character_type)
out.writeInt(collation);
else
out.writeInt(scale);
and the readExternal
int v = in.readInt();
if (i_am_character_type)
{
collation = v;
scale = 0;
}
else
{
scale = v;
}
Hope that clears that up.
Dan.
Re: Collation implementation WAS Re: Should COLLATION attribute related
code go in BasicDatabase?
Posted by Daniel John Debrunner <dj...@apache.org>.
Mike Matrigali wrote:
>
>
> Daniel John Debrunner wrote:
>> Mike Matrigali wrote:
>>
>>>
>>>
>>> Rick Hillegas wrote:
>>>
>>>>>
>>>>> Thanks, Mike. This overhead seems pretty small to me. It's hard for
>>>>> me to predict whether this is useful generality or over-design.
>>>>>
>>>>> In the SQL standard, collations can be declared per column. That
>>>>> affects index descriptors. In addition, via CASTs, collations can
>>>>> be declared per sortable expression in an ORDER BY clause. That
>>>>> affects the sorter. I'm not the person scratching this initial
>>>>> itch. I just want to register my instinct to design-in the
>>>>> generality up front. I think this has two advantages:
>>>>>
>>>>> 1) It will remove an upgrade issue later on when someone wants to
>>>>> implement more of the SQL collation support.
>>>>>
>>>>> 2) It generally lowers the barrier to implementing more of the
>>>>> standard.
>>>>>
>>>>> Regards,
>>>>> -Rick
>>>>
>>>>
>>> I am just not sure how comfortable I feel forcing an upgrade issue on a
>>> developer for a particular feature that is not their itch. Mamta is
>>> trying to solve single collation database problem, not full SQL
>>> collation support.
>>
>>
>> There's a number of factors that come in, one is the long term
>> maintainability of the code. I think that trumps any single
>> developer's itch. The developer can work with the community in coming
>> up with a solution that keeps a good balance between what the
>> community see as maintainability and scratching their itch.
>>
>> I'm actually trying to save the contributor (Mamta) work here, I think
>> changing all the locations that generate characters to have the
>> correct "new-character-type" is a huge amount of work and subject to
>> errors (just from the amount of changes and interesting situations).
>> E.g. in some situations a literal will be a CHAR (sorting by
>> ucs_basic) and others a CHAR (sorting by locale). That decision may
>> not be able to be made until very late in the bind time, and may not
>> possibly even matter even thought code would have to pick one. Only
>> caring about this when collation is involved may make it easier.
>
> I obviously don't know "all the places", so it is not clear to me why
> some of the places don't have to change. It is not clear to me why one
> does not in the new proposal have to change all the locations that
> generate characters to have the correct "new-collation-type". I think
> this is because I dont understand the runtime usages. Am I at least
> right about the following locations where we persist the columns. If
> we get the right info into them when we persist them, then we can get
> the right info into them when we read them back.
Let me see if I can explain the general compile time situations I'm
thinking about.
Assume a SQL expression where all the types are CHAR.
f('fred', col1, col2) = col3
Now currently the bind code is going to resolve types in this order:
B1) 'fred' - CHAR
B2) col1 - CHAR
B3) col2 - CHAR
B4) f('fred', col1, col2) - CHAR
B5) col3 - CHAR
B6) result - BOOLEAN
once pass, got the right result! :-)
So with the proposed dual type system we have the two internal character
types for CHAR:
CHAR(locale) - CHAR with collation for user columns
CHAR(ucs_basic) - CHAR collation for UCS_BASIC for system columns
Now in the proposed dual type system, the same bind ordering will occur.
Let's assume all col1 & col2 are user columns.
So the bind will result in
B1) 'fred' - unknown
B2) col1 - CHAR(locale)
B3) col2 - CHAR(locale)
B4) f('fred', col1, col2) - unknown
B5) col3 - CHAR(locale)
B6) result - unknown - don't know if types can be compared.
So come the end of bind time we haven't resolved the types,
so a second bind phase would be needed, which doesn't exist at the moment.
So what would that second phase do?
Bii1) 'fred' still unknown, no good reason to pick either type. Could
base it on the other arguments but what if no other character arguments
or other character arguments are a mix of CHAR(locale) and CHAR(ucs_basic)?
Bii2) f('fred', col1, col2) - unknown, don't know how to look up the
function without a type
Bii3) result - unknown - don't know if types can be compared.
Whoops, no progress, fail query.
Now one could introduce a partial type, or a third CHAR type -
CHAR(unknown), which might solve the problem. First phase would be:
B1) 'fred' - CHAR(unknown)
B2) col1 - CHAR(locale)
B3) col2 - CHAR(locale)
B4) f('fred', col1, col2) - CHAR(unknown)
B5) col3 - CHAR(locale)
B6) result - BOOLEAN
Hmmmm, so I've got the right result but I've been left with a series of
CHAR(unknown) in the tree, four options:
1) add extra bind phases to resolve them, but I think this will fail
for the same reasons where we didn't have CHAR(unknown).
2) make CHAR(unknown) a first class internal type, fully supported at
runtime and compile time.
3) resolve them in a second bind phase to CHAR(ucs_basic), doesn't
work because can't compare across collations
4) resolve them in a smarter second bind phase where the unknown
types are converted to the matching type in a collation operator and
CHAR(ucs_basic) elsewhere.
So a possible solution, but note a third character type has been added
for CHAR and either needs to fully implement an internal type to make
sure it works in the compile and execution system or I need a second
bind phase.
To me this seems like it's heading off in the direction of a hack, a
third character internal type for CHAR? Hacks lead to bugs, bugs lead to
the dark side :-)
-------------------------------------
So what about having collation as an attribute of a character type, then
we have:
B1) 'fred' - CHAR collation=unknown
B2) col1 - CHAR collation=locale
B3) col2 - CHAR collation=locale
B4) f('fred', col1, col2) - CHAR collation=unknown
B5) col3 - CHAR collation=locale
B6) result - CHAR collation=locale
First pass got the right result, just like the three type CHAR(unknown)
case. :-) What about those unknown collations, no problem, I know that
if a collation was unknown then that information is not needed, and
since they are just the standard CHAR type I already know that works at
compile and execute time.
[in both the compare unknown collation to known collation the compiler
would generate code to execute the comparison using the known collation.
This may happen automatically using the precedence system or compiler
inserts some promote code, which possibly goes back to the some of the
methods I proposed earlier. ]
-----------------------------------------------
Ok, double check, let's make the expression
f('fred', col1, syscol2) = syscol3
Of course the current code is going to bind everything to CHAR.
let's try the multi-type system with CHAR(unknown)
B1) 'fred' - CHAR(unknown)
B2) col1 - CHAR(locale)
B3) syscol2- CHAR(ucs_basic)
B4) f('fred', col1, syscol2) - CHAR(unknown)
B5) syscol3 - CHAR(ucs_basic)
B6) result - BOOLEAN
and similar for the attribute case
B1) 'fred' - CHAR collation=unknown
B2) col1 - CHAR collation=locale
B3) syscol2- CHAR collation=ucs_basic
B4) f('fred', col1, syscol2) - CHAR collation=unknown
B5) syscol3 - CHAR collation=ucs_basic
B6) result - BOOLEAN
---------------------------------------------------
and in case you are wondering why a literal such as 'fred' or a function
return doesn't just resolve to CHAR(locale), consider these examples:
'fred' = syscol1 - would fail, can't compare across collations, but
database meta data queries depend on this behaviour
'fred' = col1
---------------------------------------------------
and just for kicks
'fred' = 'barney'
Both are unknown collation types, in this case I think the result of
collation would the default user type, collation=locale.
Sorry for the long e-mail.
Hope this is clear.
Dan.
Re: Collation implementation WAS Re: Should COLLATION attribute related
code go in BasicDatabase?
Posted by Mike Matrigali <mi...@sbcglobal.net>.
Daniel John Debrunner wrote:
> Mike Matrigali wrote:
>
>>
>>
>> Rick Hillegas wrote:
>>
>>>>
>>>> Thanks, Mike. This overhead seems pretty small to me. It's hard for
>>>> me to predict whether this is useful generality or over-design.
>>>>
>>>> In the SQL standard, collations can be declared per column. That
>>>> affects index descriptors. In addition, via CASTs, collations can be
>>>> declared per sortable expression in an ORDER BY clause. That affects
>>>> the sorter. I'm not the person scratching this initial itch. I just
>>>> want to register my instinct to design-in the generality up front. I
>>>> think this has two advantages:
>>>>
>>>> 1) It will remove an upgrade issue later on when someone wants to
>>>> implement more of the SQL collation support.
>>>>
>>>> 2) It generally lowers the barrier to implementing more of the
>>>> standard.
>>>>
>>>> Regards,
>>>> -Rick
>>>
>>>
>> I am just not sure how comfortable I feel forcing an upgrade issue on a
>> developer for a particular feature that is not their itch. Mamta is
>> trying to solve single collation database problem, not full SQL
>> collation support.
>
>
> There's a number of factors that come in, one is the long term
> maintainability of the code. I think that trumps any single developer's
> itch. The developer can work with the community in coming up with a
> solution that keeps a good balance between what the community see as
> maintainability and scratching their itch.
>
> I'm actually trying to save the contributor (Mamta) work here, I think
> changing all the locations that generate characters to have the correct
> "new-character-type" is a huge amount of work and subject to errors
> (just from the amount of changes and interesting situations). E.g. in
> some situations a literal will be a CHAR (sorting by ucs_basic) and
> others a CHAR (sorting by locale). That decision may not be able to be
> made until very late in the bind time, and may not possibly even matter
> even thought code would have to pick one. Only caring about this when
> collation is involved may make it easier.
I obviously don't know "all the places", so it is not clear to me why
some of the places don't have to change. It is not clear to me why one
does not in the new proposal have to change all the locations that
generate characters to have the correct "new-collation-type". I think
this is because I dont understand the runtime usages. Am I at least
right about the following locations where we persist the columns. If
we get the right info into them when we persist them, then we can get
the right info into them when we read them back.
The main places I think about are the persistent ones:
1) system catalog creation code.
o I assume you still have to change this code so that when the
character columns are created, they get the proper info stored in the
metadata.
language metadata:
old proposal an old typeid, 0 in scale.
new proposal an old typeid, 0 in scale.
store metadata:
old proposal an old typeid, no new metadata.
new proposal an old typeid, some new metadata maybe per-column,
maybe per conglomerate
2) user table creation code.
o I assume you still have to change this code so that when the
character columns are created, they get the proper info stored in the
metadata.
language metadata:
old proposal an new typeid if collated db, 0 in scale.
new proposal an old typeid, new collate id if collated db in scale.
store metadata:
old proposal an new typeid if collated db, no new metadata.
new proposal an old typeid, some new metadata maybe per-column,
maybe per conglomerate.
In the new proposal it looks to me like new collation metadata is stored
on a per column basis in language.
>
>> Your suggestion may get us more there, not arguing that. But a solution
>> shorter along an agreed upon direction seems fine to me, and I would not
>> hold up a developer contribution that did that. If the community
>> feels that
>> 4 new classes is ok, but 4 new types is not the right direction then
>> it is reasonable to work with the community to get the direction right.
>>
>> I am waiting on Dan's reply as I think there are SYSTABLES and/or
>> SYSCOLUMNS metadata changes necessary that haven't been discussed.
>
>
> No changes to SYSTABLES or SYSCOLUMNS are needed for what Mamta is
> proposing. Support per-schema collation would probably need some change,
> though strangely enough per-column would probably not.
>
> Possibly changing the way TypeDescriptorImpl writes itself out to disk
> would be needed, but there's enough room in the current format to store
> the collation information by overloading the on-disk space occupied by
> scale, since scale is always zero for a character type.
>
Ok, so effectively language will store collation information on a per
column basis. 10.3 will interpret 0 representing USC_BASIC, and some
to be defined method will assign other values for other collations.
Will need to make sure there aren't any jdbc calls that blindly return
scale currently for character types.
> Dan.
>
>
>
Re: Collation implementation WAS Re: Should COLLATION attribute related
code go in BasicDatabase?
Posted by Daniel John Debrunner <dj...@apache.org>.
Mike Matrigali wrote:
>
>
> Rick Hillegas wrote:
>
>>>
>>> Thanks, Mike. This overhead seems pretty small to me. It's hard for
>>> me to predict whether this is useful generality or over-design.
>>>
>>> In the SQL standard, collations can be declared per column. That
>>> affects index descriptors. In addition, via CASTs, collations can be
>>> declared per sortable expression in an ORDER BY clause. That affects
>>> the sorter. I'm not the person scratching this initial itch. I just
>>> want to register my instinct to design-in the generality up front. I
>>> think this has two advantages:
>>>
>>> 1) It will remove an upgrade issue later on when someone wants to
>>> implement more of the SQL collation support.
>>>
>>> 2) It generally lowers the barrier to implementing more of the standard.
>>>
>>> Regards,
>>> -Rick
>>
> I am just not sure how comfortable I feel forcing an upgrade issue on a
> developer for a particular feature that is not their itch. Mamta is
> trying to solve single collation database problem, not full SQL
> collation support.
There's a number of factors that come in, one is the long term
maintainability of the code. I think that trumps any single developer's
itch. The developer can work with the community in coming up with a
solution that keeps a good balance between what the community see as
maintainability and scratching their itch.
I'm actually trying to save the contributor (Mamta) work here, I think
changing all the locations that generate characters to have the correct
"new-character-type" is a huge amount of work and subject to errors
(just from the amount of changes and interesting situations). E.g. in
some situations a literal will be a CHAR (sorting by ucs_basic) and
others a CHAR (sorting by locale). That decision may not be able to be
made until very late in the bind time, and may not possibly even matter
even thought code would have to pick one. Only caring about this when
collation is involved may make it easier.
> Your suggestion may get us more there, not arguing that. But a solution
> shorter along an agreed upon direction seems fine to me, and I would not
> hold up a developer contribution that did that. If the community feels
> that
> 4 new classes is ok, but 4 new types is not the right direction then
> it is reasonable to work with the community to get the direction right.
>
> I am waiting on Dan's reply as I think there are SYSTABLES and/or
> SYSCOLUMNS metadata changes necessary that haven't been discussed.
No changes to SYSTABLES or SYSCOLUMNS are needed for what Mamta is
proposing. Support per-schema collation would probably need some change,
though strangely enough per-column would probably not.
Possibly changing the way TypeDescriptorImpl writes itself out to disk
would be needed, but there's enough room in the current format to store
the collation information by overloading the on-disk space occupied by
scale, since scale is always zero for a character type.
Dan.
Re: Collation implementation WAS Re: Should COLLATION attribute related
code go in BasicDatabase?
Posted by Mike Matrigali <mi...@sbcglobal.net>.
Rick Hillegas wrote:
>>
>> Thanks, Mike. This overhead seems pretty small to me. It's hard for me
>> to predict whether this is useful generality or over-design.
>>
>> In the SQL standard, collations can be declared per column. That
>> affects index descriptors. In addition, via CASTs, collations can be
>> declared per sortable expression in an ORDER BY clause. That affects
>> the sorter. I'm not the person scratching this initial itch. I just
>> want to register my instinct to design-in the generality up front. I
>> think this has two advantages:
>>
>> 1) It will remove an upgrade issue later on when someone wants to
>> implement more of the SQL collation support.
>>
>> 2) It generally lowers the barrier to implementing more of the standard.
>>
>> Regards,
>> -Rick
>
I am just not sure how comfortable I feel forcing an upgrade issue on a
developer for a particular feature that is not their itch. Mamta is
trying to solve single collation database problem, not full SQL
collation support.
Your suggestion may get us more there, not arguing that. But a solution
shorter along an agreed upon direction seems fine to me, and I would not
hold up a developer contribution that did that. If the community feels
that
4 new classes is ok, but 4 new types is not the right direction then
it is reasonable to work with the community to get the direction right.
I am waiting on Dan's reply as I think there are SYSTABLES and/or
SYSCOLUMNS metadata changes necessary that haven't been discussed. If
so I think these are actually more upgrade work than the store ones
(I am not sure, I know exactly how to do the store upgrade ones - no
idea what is involved in SYSCOLUMNS/SYSTABLES upgrades). A real
advantage of original proposal to have new format ids was I think there
was no upgrade necessary. I still don't really understand the upgrade
ramifications as the current proposal only affects newly created
databases, so in theory there is no upgrade per se. But it may mean
that runtime code needs to handle multiple versions of metadata.
>
>
>
Re: Collation implementation WAS Re: Should COLLATION attribute
related code go in BasicDatabase?
Posted by Rick Hillegas <Ri...@Sun.COM>.
Somehow this ended up with the odd subject "QL". Here it is with the
right subject.
Regards,
-Rick
Rick Hillegas wrote:
> Mike Matrigali wrote:
>>
>>
>> Rick Hillegas wrote:
>>>>>
>>>>
>>>> This is where I get confused. Are multiple collations required in
>>>> a single database? With plans for DERBY-1478 it isn't. With new
>>>> collations it isn't.
>>>> With collation per-schema it is, but should we pay overhead now for a
>>>> possible future, as long as we have a design that supports an upgrade
>>>> path to it?
>>>> I am not seeing the value in the argument for storing it once per
>>>> table vs. once per database today.
>>>
>>> Hi Mike,
>>>
>>> Can you expand on this? What is the overhead we're avoiding?
>>>
>>> Thanks,
>>> -Rick
>>
>> Pushing an extra argument on every object creation for each member of
>> a template. Interpreting the extra argument in the object creation call.
>> Storage space in the conglomerate. Code to read/write the extra
>> metadata. The templates in the worst case are created once for each
>> conglomerate/index accessed in each sql statement. In best case the
>> templates are reused across executions of same prepared statement.
>>
>> I admit all this may be small, and if we NEED it then I have no problem
>> it being added. I just have a problem if there is no need. I have been
>> burnt in the past adding stuff that I thought might be useful in the
>> future, so now I tend to lean toward implementing what we need today,
>> while making sure there is a reasonable upgrade path in the future.
>> If I thought today's code was making it harder for a future path that
>> would be a different case. For
>> example what if whatever way we decide to store the value of the
>> collation today, turns out not to work for future expansions of the
>> collation - and we could have gotten away with storing it once per
>> db vs once per table. Now we have a much bigger upgrade issue.
>>
>> The system catalog implication may make this all a moot discussion,
>> it may be the reason we need per-schema collations. Mamta's original
>> design handled system catalog vs non system catalog with format id's so
>> there was no need for per conglomerate collations. I didn't realize
>> until my last message that Dan's proposal would need multiple
>> collations in a single db in 10.3.
> Thanks, Mike. This overhead seems pretty small to me. It's hard for me
> to predict whether this is useful generality or over-design.
>
> In the SQL standard, collations can be declared per column. That
> affects index descriptors. In addition, via CASTs, collations can be
> declared per sortable expression in an ORDER BY clause. That affects
> the sorter. I'm not the person scratching this initial itch. I just
> want to register my instinct to design-in the generality up front. I
> think this has two advantages:
>
> 1) It will remove an upgrade issue later on when someone wants to
> implement more of the SQL collation support.
>
> 2) It generally lowers the barrier to implementing more of the standard.
>
> Regards,
> -Rick
QL
Posted by Rick Hillegas <Ri...@Sun.COM>.
Mike Matrigali wrote:
>
>
> Rick Hillegas wrote:
>>>>
>>>
>>> This is where I get confused. Are multiple collations required in a
>>> single database? With plans for DERBY-1478 it isn't. With new
>>> collations it isn't.
>>> With collation per-schema it is, but should we pay overhead now for a
>>> possible future, as long as we have a design that supports an upgrade
>>> path to it?
>>> I am not seeing the value in the argument for storing it once per
>>> table vs. once per database today.
>>
>> Hi Mike,
>>
>> Can you expand on this? What is the overhead we're avoiding?
>>
>> Thanks,
>> -Rick
>
> Pushing an extra argument on every object creation for each member of
> a template. Interpreting the extra argument in the object creation call.
> Storage space in the conglomerate. Code to read/write the extra
> metadata. The templates in the worst case are created once for each
> conglomerate/index accessed in each sql statement. In best case the
> templates are reused across executions of same prepared statement.
>
> I admit all this may be small, and if we NEED it then I have no problem
> it being added. I just have a problem if there is no need. I have been
> burnt in the past adding stuff that I thought might be useful in the
> future, so now I tend to lean toward implementing what we need today,
> while making sure there is a reasonable upgrade path in the future.
> If I thought today's code was making it harder for a future path that
> would be a different case. For
> example what if whatever way we decide to store the value of the
> collation today, turns out not to work for future expansions of the
> collation - and we could have gotten away with storing it once per
> db vs once per table. Now we have a much bigger upgrade issue.
>
> The system catalog implication may make this all a moot discussion, it
> may be the reason we need per-schema collations. Mamta's original
> design handled system catalog vs non system catalog with format id's so
> there was no need for per conglomerate collations. I didn't realize
> until my last message that Dan's proposal would need multiple
> collations in a single db in 10.3.
Thanks, Mike. This overhead seems pretty small to me. It's hard for me
to predict whether this is useful generality or over-design.
In the SQL standard, collations can be declared per column. That affects
index descriptors. In addition, via CASTs, collations can be declared
per sortable expression in an ORDER BY clause. That affects the sorter.
I'm not the person scratching this initial itch. I just want to register
my instinct to design-in the generality up front. I think this has two
advantages:
1) It will remove an upgrade issue later on when someone wants to
implement more of the SQL collation support.
2) It generally lowers the barrier to implementing more of the standard.
Regards,
-Rick
Re: Collation implementation WAS Re: Should COLLATION attribute related
code go in BasicDatabase?
Posted by Mike Matrigali <mi...@sbcglobal.net>.
Rick Hillegas wrote:
>>>
>>
>> This is where I get confused. Are multiple collations required in a
>> single database? With plans for DERBY-1478 it isn't. With new
>> collations it isn't.
>> With collation per-schema it is, but should we pay overhead now for a
>> possible future, as long as we have a design that supports an upgrade
>> path to it?
>> I am not seeing the value in the argument for storing it once per
>> table vs. once per database today.
>
> Hi Mike,
>
> Can you expand on this? What is the overhead we're avoiding?
>
> Thanks,
> -Rick
Pushing an extra argument on every object creation for each member of a
template. Interpreting the extra argument in the object creation call.
Storage space in the conglomerate. Code to read/write the extra
metadata. The templates in the worst case are created once for each
conglomerate/index accessed in each sql statement. In best case the
templates are reused across executions of same prepared statement.
I admit all this may be small, and if we NEED it then I have no problem
it being added. I just have a problem if there is no need. I have been
burnt in the past adding stuff that I thought might be useful in the
future, so now I tend to lean toward implementing what we need today,
while making sure there is a reasonable upgrade path in the future. If
I thought today's code was making it harder for a future path that would
be a different case. For
example what if whatever way we decide to store the value of the
collation today, turns out not to work for future expansions of the
collation - and we could have gotten away with storing it once per
db vs once per table. Now we have a much bigger upgrade issue.
The system catalog implication may make this all a moot discussion, it
may be the reason we need per-schema collations. Mamta's original
design handled system catalog vs non system catalog with format id's so
there was no need for per conglomerate collations. I didn't realize
until my last message that Dan's proposal would need multiple collations
in a single db in 10.3.
>
>>>
>>> Thanks,
>>> Dan.
>>>
>>>
>>>
>>>
>>
>
>
>
Re: Collation implementation WAS Re: Should COLLATION attribute
related code go in BasicDatabase?
Posted by Rick Hillegas <Ri...@Sun.COM>.
Mike Matrigali wrote:
>
>
> Daniel John Debrunner wrote:
>> Rick Hillegas wrote:
>>
>>> Daniel John Debrunner wrote:
>>>
>>>> Rick Hillegas wrote:
>>>>
>>>>> Daniel John Debrunner wrote:
>>>>>
>>>>>> ...
>>>>>>
>>>>>> - The collation type (the integer) is written into the meta-data
>>>>>> for an index just as ascending/descending is today (including the
>>>>>> btree control row, thus making the information available for
>>>>>> recovery). Collation type applies to all character columns in the
>>>>>> index.
>>>>>>
>>>>> This suggests that all of the columns in the index must have the
>>>>> same collation? I don't think that is powerful enough to support
>>>>> the full-blown SQL collation language, which allows you to mix
>>>>> differently collated columns in an ORDER BY clause. Why can't the
>>>>> collation type be an array of ints just as the sort direction is
>>>>> an array of booleans in IndexDescriptor?
>>>>
>>>>
>>>> That would be more flexible, but is it required?
>>>
>>> I believe so. I don't see any rule which requires one collation for
>>> all of the character expressions in an ORDER BY clause. There does
>>> seem to be a rule requiring one collation for both sides of a
>>> comparison, e.g., for both sides of a < operator.
>>
>>
>> I understand ORDER BY with different collations is required, but I
>> meant are multiple collations required in a single BTREE index,
>> which is where this meta data would be stored. With the plans for
>> DERBY-1478 it isn't, with new collations it isn't, with collation
>> per-schema it isn't, so I was wondering what would trigger it? If
>> it's not in the foreseeable future or an option through SQL then I
>> would say a simple single collation will work. Future expansion could
>> change it to be per-column when required.
>
> This is where I get confused. Are multiple collations required in a
> single database? With plans for DERBY-1478 it isn't. With new
> collations it isn't.
> With collation per-schema it is, but should we pay overhead now for a
> possible future, as long as we have a design that supports an upgrade
> path to it?
> I am not seeing the value in the argument for storing it once per
> table vs. once per database today.
Hi Mike,
Can you expand on this? What is the overhead we're avoiding?
Thanks,
-Rick
>>
>> Thanks,
>> Dan.
>>
>>
>>
>>
>
Re: Collation implementation WAS Re: Should COLLATION attribute related
code go in BasicDatabase?
Posted by Daniel John Debrunner <dj...@apache.org>.
Daniel John Debrunner wrote:
> Mike Matrigali wrote:
>>
>>
>> Daniel John Debrunner wrote:
>>> Rick Hillegas wrote:
>>>
>>>> Daniel John Debrunner wrote:
>>>>
>>>>> Rick Hillegas wrote:
>>>>>
>>>>>> Daniel John Debrunner wrote:
>>>>>>
>>>>>>> ...
>>>>>>>
>>>>>>> - The collation type (the integer) is written into the meta-data
>>>>>>> for an index just as ascending/descending is today (including the
>>>>>>> btree control row, thus making the information available for
>>>>>>> recovery). Collation type applies to all character columns in the
>>>>>>> index.
>>>>>>>
>>>>>> This suggests that all of the columns in the index must have the
>>>>>> same collation? I don't think that is powerful enough to support
>>>>>> the full-blown SQL collation language, which allows you to mix
>>>>>> differently collated columns in an ORDER BY clause. Why can't the
>>>>>> collation type be an array of ints just as the sort direction is
>>>>>> an array of booleans in IndexDescriptor?
>>>>>
>>>>>
>>>>> That would be more flexible, but is it required?
>>>>
>>>> I believe so. I don't see any rule which requires one collation for
>>>> all of the character expressions in an ORDER BY clause. There does
>>>> seem to be a rule requiring one collation for both sides of a
>>>> comparison, e.g., for both sides of a < operator.
>>>
>>>
>>> I understand ORDER BY with different collations is required, but I
>>> meant are multiple collations required in a single BTREE index,
>>> which is where this meta data would be stored. With the plans for
>>> DERBY-1478 it isn't, with new collations it isn't, with collation
>>> per-schema it isn't, so I was wondering what would trigger it? If
>>> it's not in the foreseeable future or an option through SQL then I
>>> would say a simple single collation will work. Future expansion could
>>> change it to be per-column when required.
>>
>> This is where I get confused. Are multiple collations required in a
>> single database? With plans for DERBY-1478 it isn't. With new
>> collations it isn't.
>> With collation per-schema it is, but should we pay overhead now for a
>> possible future, as long as we have a design that supports an upgrade
>> path to it?
>> I am not seeing the value in the argument for storing it once per
>> table vs. once per database today.
>
> That's true. If the store used this per-database value when setting up
> the row arrays for an index then the path forward to per-schema
> collations would be clear. In that case in the future the store could
> override the per-database value with the value from the index meta data.
>
> This would then mean that the default collation type must be stored in
> service.properties and thus be available to the store when it boots. The
> reading of the attribute logic could continue to be in DataValueFactory
> and should work similar to the code Mamta posted earlier.
Actually I think the above won't work, since 10.3 will have *two*
collations per database. UCS_BASIC for system tables and locale based
for user tables. Thus I think the information is needed at the index
level unless store has a mechanism to figure out which are system indexes.
The different format identifier for the same type is what worries me, it
seems there is ample opportunity to end up with the wrong CHAR data type
and thus lead to bugs. Today's code handles this ok and it more obvious
since there is a 1-1 mapping between:
SQL type name (e.g. INTEGER) and derby internal type
JDBC type name (e.g. Types.CHAR) and derby internal type
breaking that to be a 1-N mapping seems to be a huge risk. There is a
lot of places in the code where a character datatype is created, can we
guarantee to catch all of them? Limiting the exposure to collation
related activity seems safer to me.
Dan.
Re: Collation implementation WAS Re: Should COLLATION attribute related
code go in BasicDatabase?
Posted by Daniel John Debrunner <dj...@apache.org>.
Mike Matrigali wrote:
>
>
> Daniel John Debrunner wrote:
>> Rick Hillegas wrote:
>>
>>> Daniel John Debrunner wrote:
>>>
>>>> Rick Hillegas wrote:
>>>>
>>>>> Daniel John Debrunner wrote:
>>>>>
>>>>>> ...
>>>>>>
>>>>>> - The collation type (the integer) is written into the meta-data
>>>>>> for an index just as ascending/descending is today (including the
>>>>>> btree control row, thus making the information available for
>>>>>> recovery). Collation type applies to all character columns in the
>>>>>> index.
>>>>>>
>>>>> This suggests that all of the columns in the index must have the
>>>>> same collation? I don't think that is powerful enough to support
>>>>> the full-blown SQL collation language, which allows you to mix
>>>>> differently collated columns in an ORDER BY clause. Why can't the
>>>>> collation type be an array of ints just as the sort direction is an
>>>>> array of booleans in IndexDescriptor?
>>>>
>>>>
>>>> That would be more flexible, but is it required?
>>>
>>> I believe so. I don't see any rule which requires one collation for
>>> all of the character expressions in an ORDER BY clause. There does
>>> seem to be a rule requiring one collation for both sides of a
>>> comparison, e.g., for both sides of a < operator.
>>
>>
>> I understand ORDER BY with different collations is required, but I
>> meant are multiple collations required in a single BTREE index, which
>> is where this meta data would be stored. With the plans for DERBY-1478
>> it isn't, with new collations it isn't, with collation per-schema it
>> isn't, so I was wondering what would trigger it? If it's not in the
>> foreseeable future or an option through SQL then I would say a simple
>> single collation will work. Future expansion could change it to be
>> per-column when required.
>
> This is where I get confused. Are multiple collations required in a
> single database? With plans for DERBY-1478 it isn't. With new
> collations it isn't.
> With collation per-schema it is, but should we pay overhead now for a
> possible future, as long as we have a design that supports an upgrade
> path to it?
> I am not seeing the value in the argument for storing it once per
> table vs. once per database today.
That's true. If the store used this per-database value when setting up
the row arrays for an index then the path forward to per-schema
collations would be clear. In that case in the future the store could
override the per-database value with the value from the index meta data.
This would then mean that the default collation type must be stored in
service.properties and thus be available to the store when it boots. The
reading of the attribute logic could continue to be in DataValueFactory
and should work similar to the code Mamta posted earlier.
Dan.
Re: Collation implementation WAS Re: Should COLLATION attribute related
code go in BasicDatabase?
Posted by Mike Matrigali <mi...@sbcglobal.net>.
Daniel John Debrunner wrote:
> Rick Hillegas wrote:
>
>> Daniel John Debrunner wrote:
>>
>>> Rick Hillegas wrote:
>>>
>>>> Daniel John Debrunner wrote:
>>>>
>>>>> ...
>>>>>
>>>>> - The collation type (the integer) is written into the meta-data
>>>>> for an index just as ascending/descending is today (including the
>>>>> btree control row, thus making the information available for
>>>>> recovery). Collation type applies to all character columns in the
>>>>> index.
>>>>>
>>>> This suggests that all of the columns in the index must have the
>>>> same collation? I don't think that is powerful enough to support the
>>>> full-blown SQL collation language, which allows you to mix
>>>> differently collated columns in an ORDER BY clause. Why can't the
>>>> collation type be an array of ints just as the sort direction is an
>>>> array of booleans in IndexDescriptor?
>>>
>>>
>>> That would be more flexible, but is it required?
>>
>> I believe so. I don't see any rule which requires one collation for
>> all of the character expressions in an ORDER BY clause. There does
>> seem to be a rule requiring one collation for both sides of a
>> comparison, e.g., for both sides of a < operator.
>
>
> I understand ORDER BY with different collations is required, but I meant
> are multiple collations required in a single BTREE index, which is
> where this meta data would be stored. With the plans for DERBY-1478 it
> isn't, with new collations it isn't, with collation per-schema it isn't,
> so I was wondering what would trigger it? If it's not in the foreseeable
> future or an option through SQL then I would say a simple single
> collation will work. Future expansion could change it to be per-column
> when required.
This is where I get confused. Are multiple collations required in a
single database? With plans for DERBY-1478 it isn't. With new
collations it isn't.
With collation per-schema it is, but should we pay overhead now for a
possible future, as long as we have a design that supports an upgrade
path to it?
I am not seeing the value in the argument for storing it once per
table vs. once per database today.
>
> Thanks,
> Dan.
>
>
>
>
Re: Collation implementation WAS Re: Should COLLATION attribute related
code go in BasicDatabase?
Posted by Daniel John Debrunner <dj...@apache.org>.
Rick Hillegas wrote:
> Daniel John Debrunner wrote:
>> Rick Hillegas wrote:
>>> Daniel John Debrunner wrote:
>>>> Rick Hillegas wrote:
>>>>> Daniel John Debrunner wrote:
>>>>>> ...
>>>>>>
>>>>>> - The collation type (the integer) is written into the meta-data
>>>>>> for an index just as ascending/descending is today (including the
>>>>>> btree control row, thus making the information available for
>>>>>> recovery). Collation type applies to all character columns in the
>>>>>> index.
>>>>>>
>>>>> This suggests that all of the columns in the index must have the
>>>>> same collation? I don't think that is powerful enough to support
>>>>> the full-blown SQL collation language, which allows you to mix
>>>>> differently collated columns in an ORDER BY clause. Why can't the
>>>>> collation type be an array of ints just as the sort direction is an
>>>>> array of booleans in IndexDescriptor?
>>>>
>>>> That would be more flexible, but is it required?
>>> I believe so. I don't see any rule which requires one collation for
>>> all of the character expressions in an ORDER BY clause. There does
>>> seem to be a rule requiring one collation for both sides of a
>>> comparison, e.g., for both sides of a < operator.
>>
>> I understand ORDER BY with different collations is required, but I
>> meant are multiple collations required in a single BTREE index, which
>> is where this meta data would be stored. With the plans for DERBY-1478
>> it isn't, with new collations it isn't, with collation per-schema it
>> isn't, so I was wondering what would trigger it? If it's not in the
>> foreseeable future or an option through SQL then I would say a simple
>> single collation will work. Future expansion could change it to be
>> per-column when required.
>>
>> Thanks,
>> Dan.
>>
>>
> I guess I'm not understanding why we wouldn't design this generality
> into the on-disk representation from the start. What is the
> danger/cost/problem we're trying to avoid? Designing for the general
> case will save us an upgrade issue later on.
So SQL does allow per-column collations, SQL Standard 11.4 <column
definition> has a <collate clause>.
Dan.
Re: Collation implementation WAS Re: Should COLLATION attribute
related code go in BasicDatabase?
Posted by Rick Hillegas <Ri...@Sun.COM>.
Daniel John Debrunner wrote:
> Rick Hillegas wrote:
>> Daniel John Debrunner wrote:
>>> Rick Hillegas wrote:
>>>> Daniel John Debrunner wrote:
>>>>> ...
>>>>>
>>>>> - The collation type (the integer) is written into the meta-data
>>>>> for an index just as ascending/descending is today (including the
>>>>> btree control row, thus making the information available for
>>>>> recovery). Collation type applies to all character columns in the
>>>>> index.
>>>>>
>>>> This suggests that all of the columns in the index must have the
>>>> same collation? I don't think that is powerful enough to support
>>>> the full-blown SQL collation language, which allows you to mix
>>>> differently collated columns in an ORDER BY clause. Why can't the
>>>> collation type be an array of ints just as the sort direction is an
>>>> array of booleans in IndexDescriptor?
>>>
>>> That would be more flexible, but is it required?
>> I believe so. I don't see any rule which requires one collation for
>> all of the character expressions in an ORDER BY clause. There does
>> seem to be a rule requiring one collation for both sides of a
>> comparison, e.g., for both sides of a < operator.
>
> I understand ORDER BY with different collations is required, but I
> meant are multiple collations required in a single BTREE index, which
> is where this meta data would be stored. With the plans for DERBY-1478
> it isn't, with new collations it isn't, with collation per-schema it
> isn't, so I was wondering what would trigger it? If it's not in the
> foreseeable future or an option through SQL then I would say a simple
> single collation will work. Future expansion could change it to be
> per-column when required.
>
> Thanks,
> Dan.
>
>
I guess I'm not understanding why we wouldn't design this generality
into the on-disk representation from the start. What is the
danger/cost/problem we're trying to avoid? Designing for the general
case will save us an upgrade issue later on.
Regards,
-Rick
Re: Collation implementation WAS Re: Should COLLATION attribute related
code go in BasicDatabase?
Posted by Daniel John Debrunner <dj...@apache.org>.
Rick Hillegas wrote:
> Daniel John Debrunner wrote:
>> Rick Hillegas wrote:
>>> Daniel John Debrunner wrote:
>>>> ...
>>>>
>>>> - The collation type (the integer) is written into the meta-data for
>>>> an index just as ascending/descending is today (including the btree
>>>> control row, thus making the information available for recovery).
>>>> Collation type applies to all character columns in the index.
>>>>
>>> This suggests that all of the columns in the index must have the same
>>> collation? I don't think that is powerful enough to support the
>>> full-blown SQL collation language, which allows you to mix
>>> differently collated columns in an ORDER BY clause. Why can't the
>>> collation type be an array of ints just as the sort direction is an
>>> array of booleans in IndexDescriptor?
>>
>> That would be more flexible, but is it required?
> I believe so. I don't see any rule which requires one collation for all
> of the character expressions in an ORDER BY clause. There does seem to
> be a rule requiring one collation for both sides of a comparison, e.g.,
> for both sides of a < operator.
I understand ORDER BY with different collations is required, but I meant
are multiple collations required in a single BTREE index, which is
where this meta data would be stored. With the plans for DERBY-1478 it
isn't, with new collations it isn't, with collation per-schema it isn't,
so I was wondering what would trigger it? If it's not in the foreseeable
future or an option through SQL then I would say a simple single
collation will work. Future expansion could change it to be per-column
when required.
Thanks,
Dan.
Re: Collation implementation WAS Re: Should COLLATION attribute
related code go in BasicDatabase?
Posted by Rick Hillegas <Ri...@Sun.COM>.
Daniel John Debrunner wrote:
> Rick Hillegas wrote:
>> Daniel John Debrunner wrote:
>>> ...
>>>
>>> - The collation type (the integer) is written into the meta-data for
>>> an index just as ascending/descending is today (including the btree
>>> control row, thus making the information available for recovery).
>>> Collation type applies to all character columns in the index.
>>>
>> This suggests that all of the columns in the index must have the same
>> collation? I don't think that is powerful enough to support the
>> full-blown SQL collation language, which allows you to mix
>> differently collated columns in an ORDER BY clause. Why can't the
>> collation type be an array of ints just as the sort direction is an
>> array of booleans in IndexDescriptor?
>
> That would be more flexible, but is it required?
I believe so. I don't see any rule which requires one collation for all
of the character expressions in an ORDER BY clause. There does seem to
be a rule requiring one collation for both sides of a comparison, e.g.,
for both sides of a < operator.
> Is an order by that spills to disk implemented using a BTREE?
I don't know the answer to this one.
Regards,
-Rick
>
> Thanks,
> Dan.
>
Re: Collation implementation WAS Re: Should COLLATION attribute related
code go in BasicDatabase?
Posted by Daniel John Debrunner <dj...@apache.org>.
Rick Hillegas wrote:
> Daniel John Debrunner wrote:
>> ...
>>
>> - The collation type (the integer) is written into the meta-data for
>> an index just as ascending/descending is today (including the btree
>> control row, thus making the information available for recovery).
>> Collation type applies to all character columns in the index.
>>
> This suggests that all of the columns in the index must have the same
> collation? I don't think that is powerful enough to support the
> full-blown SQL collation language, which allows you to mix differently
> collated columns in an ORDER BY clause. Why can't the collation type be
> an array of ints just as the sort direction is an array of booleans in
> IndexDescriptor?
That would be more flexible, but is it required? Is an order by that
spills to disk implemented using a BTREE?
Thanks,
Dan.
Re: Collation implementation WAS Re: Should COLLATION attribute
related code go in BasicDatabase?
Posted by Rick Hillegas <Ri...@Sun.COM>.
Daniel John Debrunner wrote:
> ...
>
> - The collation type (the integer) is written into the meta-data for
> an index just as ascending/descending is today (including the btree
> control row, thus making the information available for recovery).
> Collation type applies to all character columns in the index.
>
This suggests that all of the columns in the index must have the same
collation? I don't think that is powerful enough to support the
full-blown SQL collation language, which allows you to mix differently
collated columns in an ORDER BY clause. Why can't the collation type be
an array of ints just as the sort direction is an array of booleans in
IndexDescriptor?
Re: Collation implementation WAS Re: Should COLLATION attribute related code go in BasicDatabase?
Posted by Mamta Satoor <ms...@gmail.com>.
I think we will be fine if we don't add the COLLATION property to
pre-10.3databases during hard upgrade. If the property is not set, we
can just
assume it to be UCS_BASIC. I am not sure how the store column metadata will
look like after upgrade to 10.3. If we decide not to upgrade the store
metadata during hard upgrade, then when store calls
RowUtil.newClassInfoTemplate, it would need to pass the collator_ids
array initialized to UCS_BASIC even though there is no info about collation
type on the disk in store's metadata. But a newly created 10.3 database will
have the store metadata containing collation type and the collator_ids must
be initialized with the values from the disk. Does store keep a version
id on store metadata? Is that how it will differentiate between a newly
created 10.3 db against an upgraded 10.3 db?
thanks,
Mamta
On 3/21/07, Mamta Satoor <ms...@gmail.com> wrote:
>
> Actually, let me start by asking a store question. Is store going to write
> the collation type column metadata only if the user has requested
> TERRITORY_BASED collation ie can 2 newly created 10.3 databases have
> different column metadata structure(ie with and without collation type
> info) depending on whether the user has requested TERRITORY_BASED or
> UCS_BASIC collation?
>
> Mamta
>
> On 3/21/07, Mike Matrigali <mikem_app@sbcglobal.net > wrote:
> >
> >
> >
> > Mamta Satoor wrote:
> > > 2)At the time of upgrade of pre-10.3 database, we should make sure
> > that
> > > derby.database.collation property with value UCS_BASIC in added to
> > > services.properties. This is because we do not plan on supporting
> > > collation change for existing databases.
> > Is this required? How does the code handle a soft upgrade database
> > where this property is not set? Could you say what you plan to do
> > in both the hard and soft upgrade cases?
> >
> > I was assuming that only new databases would be affected and that
> > somehow new code would just work on existing databases with no upgrade
> > changes at all. So something like no collation property at all
> > would be interpreted as UCS_BASIC. And of course old format SYSCOLUMN
> > entries would be valid as well as old format conglomerate store
> > metadata.
> > >
> > >
> > > On 3/20/07, *Mamta Satoor* <msatoor@gmail.com
> > > <mailto: msatoor@gmail.com>> wrote:
> > >
> > > Thanks, Mike and Dan for your responses. Based on this and
> > following
> > > from Dan's first mail in this thread
> > > ******start of part of Dan's first mail in this thread*******
> > > - basic database sets the locale for the DataValueFactory after it
> > > boots it, using a new method on DVF
> > > void setLocale(Locale locale);
> > > ******end of part of Dan's first mail in this thread*******
> > I may have missed this, is locale information already available from
> > from services.properties ? For the store boot issue store will provide
> > format id and collation id, but I believe you need locale information
> > to determine the RuleBasedCollator and it can't depend on anything in
> > the property conglomerate.
> >
> > > we donot need the collation attribute information at the DVF boot
> > > time. It is sufficient to have locale info set on DVF at the boot
> > > time using setLocale method by basic database. If store code calls
> >
> > > DVF to give proper DVD using formatid and collation type, DVF can
> > > determine the correct RuleBasedCollator using the locale if the
> > > collation type is territory based. So, DVF has everything it needs
> >
> > > to find the correct RuleBasedCollator for given collation type.
> > >
> > > I will go ahead and remove the following requirement from
> > > Outstanding items under
> > > http://wiki.apache.org/db-derby/BuiltInLanguageBasedOrderingDERBY-1478
> >
> > > <http://wiki.apache.org/db-derby/BuiltInLanguageBasedOrderingDERBY-1478
> > >
> > > 1)Add jdbc url attribute COLLATION into services.properties as
> > > derby.database.collation property. If no COLLATION is specified at
> > > database create time, then have UCS_BASIC as the value for
> > > derby.database.collation We need the property in the
> > > services.properties rather than properties conglomerate because
> > > DataValueFactory <http://wiki.apache.org/db-derby/DataValueFactory
> > >
> > > needs this property before store has been booted completely.
> > >
> > > In addition, I will add an entry as follows under Implemented
> > Items
> > > on
> > > http://wiki.apache.org/db-derby/BuiltInLanguageBasedOrderingDERBY-1478
> >
> > > <http://wiki.apache.org/db-derby/BuiltInLanguageBasedOrderingDERBY-1478
> > >
> > > At the time of database create time, optional JDBC url attribute
> > > COLLATION is validated by the boot code in data dictionary and the
> >
> > > validated value of COLLATION(if none specified by user, then it
> > will
> > > default to UCS_BASIC which is also the only collation available on
> > > pre-10.3 databases) attribute is saved as derby.database.collation
> > > property in the properties conglomerate. This work was done by
> > > revision 511283
> > >
> > > As always, any feedback is welcomed,
> > > Mamta
> > >
> > > On 3/20/07, *Mike Matrigali* < mikem_app@sbcglobal.net
> > > <ma...@sbcglobal.net>> wrote:
> > >
> > >
> > >
> > > Mamta Satoor wrote:
> > >> Mike, I am not sure if your question, about how in store DVD with
> > >> correction collation type is loaded, was answered or not. In
> > > other
> > >> words, you had question about following piece of pseudo code
> > > from Dan
> > >> if (dvd instanceof StringDataValue)
> > >> dvd = dvd.getValue(dvf.getCharacterCollator(type));
> > >>
> > >> Let me attempt to answer it. It will help clear up things in
> > > my mind too
> > >> and make sure that I am understanding this correctly.
> > >>
> > >> Currently,
> > >>
> > >
> > derby.impl.dtore.access.conglomerate.OpenConglomerateScratchSpace
> > > has
> > >> get_row_for_export which first gets a class template row using
> > >> RowUtil.newClassInfoTemplate This method in RowUtil calls
> > >> Monitor.classFromIdentifier to get the InstanceGetter for each
> > > of the
> > >> format ids identified by store. Once
> > >> OpenConglomerateScratchSpace.get_row_for_export has the class
> > > template
> > >> row, it will call RowUtil.newRowFromClassInfoTemplate . This is the
> > >> method, Dan is proposing to modify, ie store should pass an
> > > additional
> > >> array of int to RowUtil.newRowFromClassInfoTemplate which
> > > will have the
> > >> collation type associated with the formatids of the template row.
> > >> RowUtil.newRowFromClassInfoTemplate will first get the DVD as
> > > it does
> > >> today using following
> > >> columns[column_index] =
> > >> (DataValueDescriptor)
> > > classinfo_template[column_index].getNewInstance();
> > >> In addition, it will need to do something like following
> > >> if (columns[column_index] instanceof StringDataValue)
> > >> dvd =
> > >>
> > > columns[column_index].getValue( dvf.getCharacterCollator
> > (collationTypesForTemplateRows[column_index]));
> > >
> > > My opinion is that this work should be done in the datavalue
> > > factory and
> > > not outside. Dan suggested at one point that some of the work
> > of
> > > generating classes/instances should move from Monitor to
> > > datavalue factory.
> > >
> > > So I was assuming something like RowUtil.newClassInfoTemplate
> > > instead
> > > of calling Monitor.classFromIdentifier(format_ids[i]) get an
> > > array of
> > > InstanceGetter's, it would call something like
> > > datavaluefactory.classFromIdentifier(format_ids[i],
> > > collator_ids[i]) -
> > > then every InstanceGetter would produce the right type with
> > > collator set
> > > from then on.
> > >
> > >
> > > Internal to dvf it can do the work of checking for instanceof
> > if it
> > > needs to, but because it is inside dvf maybe it can do
> > something
> > > smarter .
> > >>
> > >> Dan, let me know if I understood you right. This will help me
> > > answer
> > >> your question on the Derby wiki page
> > >>
> > >
> > http://wiki.apache.org/db-derby/BuiltInLanguageBasedOrderingDERBY-1478
> > > <http://wiki.apache.org/db-derby/BuiltInLanguageBasedOrderingDERBY-1478
> > >
> > >> <
> > >
> > http://wiki.apache.org/db-derby/BuiltInLanguageBasedOrderingDERBY-1478
> > > <http://wiki.apache.org/db-derby/BuiltInLanguageBasedOrderingDERBY-1478
> > >>
> > > I
> > >> know that we don't need to get into the implementation code
> > > details in
> > >> the design phase, but I need to be able to picture this
> > > particular case
> > >> in my mind to understand where I am going.
> > >>
> > >> thanks,
> > >> Mamta
> > >>
> > >>
> > >> On 3/15/07, *Mike Matrigali* < mikem_app@sbcglobal.net
> > > <ma...@sbcglobal.net>
> > >> <mailto: mikem_app@sbcglobal.net
> > > <mailto: mikem_app@sbcglobal.net>>> wrote:
> > >>
> > >>
> > >>
> > >> Daniel John Debrunner wrote:
> > >> > Mamta Satoor wrote:
> > >> >
> > >> ...
> > >>
> > >> >
> > >> > - At recovery time the btree uses the collation type and
> > > the data
> > >> value
> > >> > factory to setup its template row array correctly.
> > > Something like
> > >> > for each dvd in row array
> > >> > if (dvd instanceof StringDataValue)
> > >> > dvd = dvd.getValue(dvf.getCharacterCollator
> > > (type));
> > >>
> > >> Note that the store issue is not just a recovery time
> > > issue, templates
> > >> are required during normal runtime. Creation of these
> > > templates used
> > >> to show up (a long time ago) in performance analysis and
> > > work was done
> > >> to optimize the performance. So I am interested in making
> > > these
> > >> template creations as efficient as possible.
> > >>
> > >> Your proposal above does not look right to me - it could
> > > just be I don't
> > >> understand where the psuedo code is. The code I expect in
> > > store would
> > >> be something like below - letting the datafactory do
> > > whatever is right
> > >> based on the format id and the collation, if store is going
> > > to "own"
> > >> knowing
> > >> the collation of a given column then I would expect
> > > something like:
> > >>
> > >> for each format id in row array
> > >> dvd = datavaluefactory.getObject(format id,
> > > character_collator_type)
> > >>
> > >> note this means extra overhead for every object creation in
> > > the
> > >> template.
> > >>
> > >> To me it seems unfortunate to pass in this info per column,
> > > when at
> > >> least in 10.3 the current code it is one per database. I
> > > saw the
> > >> direction as:
> > >>
> > >> o 10.3 only needs one collation per database so hide the
> > > info in the
> > >> datafactory, basically there is one DEFAULT collation per
> > > database.
> > >> Thus no need for second argument to
> > > datavaluefactory.getObject ()
> > >>
> > >> o future release needs to have different collations per
> > > conglomerate,
> > >> then at that time we can store a collator type per
> > > conglomerate - we
> > >> have mechanism today to upgrade on the fly. If we want
> > > to support
> > >> adding a collation to an existing database I would
> > > suggest continueing
> > >> the DEFAULT collation concept with some magic number
> > > representing
> > >> DEFAULT db collation in the datavaluefactory.getObject ()
> > > call - which
> > >> would mean use db wide default rather than specify
> > > specific one. For
> > >> new databases we would not need default, we could at that
> > > time
> > >> specify
> > >> one per conglomerate.
> > >> At this point we either change all the
> > > datavaluefactory.getObject()
> > >> calls to have 2 args and support DEFAULT_VALUE as second
> > > argument, or
> > >> maybe support both 1 and 2 arg calls - not sure.
> > >>
> > >> 0 future future release needs to have different collations
> > > per column,
> > >> then at that time we can store a collator type per column
> > > - we
> > >> continue to have mechanism to upgrade on fly as long as we
> > > can come up
> > >> with a default value for old tables. Same issues as above.
> > >>
> > >>
> > >>
> > >> >
> > >> > - setting the collation property remains in the data
> > > dictionary
> > >> >
> > >> > - basic database sets the locale for the
> > > DataValueFactory after
> > >> it boots
> > >> > it, using a new method on DVF
> > >> > void setLocale(Locale locale);
> > >> >
> > >> > I think approaching the problem this way will lead to a
> > > cleaner
> > >> solution
> > >> > in the long term and be somewhat easier to implement.
> > >> >
> > >> > Thanks,
> > >> > Dan.
> > >> >
> > >> >
> > >> >
> > >> >
> > >> >
> > >> >
> > >>
> > >>
> > >
> > >
> > >
> >
> >
>
Re: Collation implementation WAS Re: Should COLLATION attribute related code go in BasicDatabase?
Posted by Mamta Satoor <ms...@gmail.com>.
Hi Mike,
Let me answer your second question first, because it's easy.
*****************Mike wrote**************
I may have missed this, is locale information already available from
from services.properties? For the store boot issue store will provide
format id and collation id, but I believe you need locale information
to determine the RuleBasedCollator and it can't depend on anything in
the property conglomerate.
*******************************************
services.properties file already has the locale informaiton and hence
BasicDatabase will be able to set the locale on DVF after DVF boots and DVF
will use that locale to determine the RuleBasedCollator when store will call
DVF with collation type of TERRITORY_BASED.
Mamta
On 3/21/07, Mike Matrigali <mi...@sbcglobal.net> wrote:
>
>
>
> Mamta Satoor wrote:
> > 2)At the time of upgrade of pre-10.3 database, we should make sure that
> > derby.database.collation property with value UCS_BASIC in added to
> > services.properties. This is because we do not plan on supporting
> > collation change for existing databases.
> Is this required? How does the code handle a soft upgrade database
> where this property is not set? Could you say what you plan to do
> in both the hard and soft upgrade cases?
>
> I was assuming that only new databases would be affected and that
> somehow new code would just work on existing databases with no upgrade
> changes at all. So something like no collation property at all
> would be interpreted as UCS_BASIC. And of course old format SYSCOLUMN
> entries would be valid as well as old format conglomerate store metadata.
> >
> >
> > On 3/20/07, *Mamta Satoor* <msatoor@gmail.com
> > <ma...@gmail.com>> wrote:
> >
> > Thanks, Mike and Dan for your responses. Based on this and following
> > from Dan's first mail in this thread
> > ******start of part of Dan's first mail in this thread*******
> > - basic database sets the locale for the DataValueFactory after it
> > boots it, using a new method on DVF
> > void setLocale(Locale locale);
> > ******end of part of Dan's first mail in this thread*******
> I may have missed this, is locale information already available from
> from services.properties? For the store boot issue store will provide
> format id and collation id, but I believe you need locale information
> to determine the RuleBasedCollator and it can't depend on anything in
> the property conglomerate.
>
> > we donot need the collation attribute information at the DVF boot
> > time. It is sufficient to have locale info set on DVF at the boot
> > time using setLocale method by basic database. If store code calls
> > DVF to give proper DVD using formatid and collation type, DVF can
> > determine the correct RuleBasedCollator using the locale if the
> > collation type is territory based. So, DVF has everything it needs
> > to find the correct RuleBasedCollator for given collation type.
> >
> > I will go ahead and remove the following requirement from
> > Outstanding items under
> >
> http://wiki.apache.org/db-derby/BuiltInLanguageBasedOrderingDERBY-1478
> > <
> http://wiki.apache.org/db-derby/BuiltInLanguageBasedOrderingDERBY-1478>
> > 1)Add jdbc url attribute COLLATION into services.properties as
> > derby.database.collation property. If no COLLATION is specified at
> > database create time, then have UCS_BASIC as the value for
> > derby.database.collation We need the property in the
> > services.properties rather than properties conglomerate because
> > DataValueFactory <http://wiki.apache.org/db-derby/DataValueFactory>
> > needs this property before store has been booted completely.
> >
> > In addition, I will add an entry as follows under Implemented Items
> > on
> >
> http://wiki.apache.org/db-derby/BuiltInLanguageBasedOrderingDERBY-1478
> > <
> http://wiki.apache.org/db-derby/BuiltInLanguageBasedOrderingDERBY-1478>
> > At the time of database create time, optional JDBC url attribute
> > COLLATION is validated by the boot code in data dictionary and the
> > validated value of COLLATION(if none specified by user, then it will
> > default to UCS_BASIC which is also the only collation available on
> > pre-10.3 databases) attribute is saved as derby.database.collation
> > property in the properties conglomerate. This work was done by
> > revision 511283
> >
> > As always, any feedback is welcomed,
> > Mamta
> >
> > On 3/20/07, *Mike Matrigali* <mikem_app@sbcglobal.net
> > <ma...@sbcglobal.net>> wrote:
> >
> >
> >
> > Mamta Satoor wrote:
> >> Mike, I am not sure if your question, about how in store DVD with
> >> correction collation type is loaded, was answered or not. In
> > other
> >> words, you had question about following piece of pseudo code
> > from Dan
> >> if (dvd instanceof StringDataValue)
> >> dvd = dvd.getValue(dvf.getCharacterCollator(type));
> >>
> >> Let me attempt to answer it. It will help clear up things in
> > my mind too
> >> and make sure that I am understanding this correctly.
> >>
> >> Currently,
> >>
> >
> derby.impl.dtore.access.conglomerate.OpenConglomerateScratchSpace
> > has
> >> get_row_for_export which first gets a class template row using
> >> RowUtil.newClassInfoTemplate This method in RowUtil calls
> >> Monitor.classFromIdentifier to get the InstanceGetter for each
> > of the
> >> format ids identified by store. Once
> >> OpenConglomerateScratchSpace.get_row_for_export has the class
> > template
> >> row, it will call RowUtil.newRowFromClassInfoTemplate. This is the
> >> method, Dan is proposing to modify, ie store should pass an
> > additional
> >> array of int to RowUtil.newRowFromClassInfoTemplate which
> > will have the
> >> collation type associated with the formatids of the template row.
> >> RowUtil.newRowFromClassInfoTemplate will first get the DVD as
> > it does
> >> today using following
> >> columns[column_index] =
> >> (DataValueDescriptor)
> > classinfo_template[column_index].getNewInstance();
> >> In addition, it will need to do something like following
> >> if (columns[column_index] instanceof StringDataValue)
> >> dvd =
> >>
> > columns[column_index].getValue(dvf.getCharacterCollator
> (collationTypesForTemplateRows[column_index]));
> >
> > My opinion is that this work should be done in the datavalue
> > factory and
> > not outside. Dan suggested at one point that some of the work
> of
> > generating classes/instances should move from Monitor to
> > datavalue factory.
> >
> > So I was assuming something like RowUtil.newClassInfoTemplate
> > instead
> > of calling Monitor.classFromIdentifier(format_ids[i]) get an
> > array of
> > InstanceGetter's, it would call something like
> > datavaluefactory.classFromIdentifier(format_ids[i],
> > collator_ids[i]) -
> > then every InstanceGetter would produce the right type with
> > collator set
> > from then on.
> >
> >
> > Internal to dvf it can do the work of checking for instanceof if
> it
> > needs to, but because it is inside dvf maybe it can do something
> > smarter .
> >>
> >> Dan, let me know if I understood you right. This will help me
> > answer
> >> your question on the Derby wiki page
> >>
> >
> http://wiki.apache.org/db-derby/BuiltInLanguageBasedOrderingDERBY-1478
> > <
> http://wiki.apache.org/db-derby/BuiltInLanguageBasedOrderingDERBY-1478>
> >> <
> >
> http://wiki.apache.org/db-derby/BuiltInLanguageBasedOrderingDERBY-1478
> > <
> http://wiki.apache.org/db-derby/BuiltInLanguageBasedOrderingDERBY-1478>>
> > I
> >> know that we don't need to get into the implementation code
> > details in
> >> the design phase, but I need to be able to picture this
> > particular case
> >> in my mind to understand where I am going.
> >>
> >> thanks,
> >> Mamta
> >>
> >>
> >> On 3/15/07, *Mike Matrigali* < mikem_app@sbcglobal.net
> > <ma...@sbcglobal.net>
> >> <mailto:mikem_app@sbcglobal.net
> > <ma...@sbcglobal.net>>> wrote:
> >>
> >>
> >>
> >> Daniel John Debrunner wrote:
> >> > Mamta Satoor wrote:
> >> >
> >> ...
> >>
> >> >
> >> > - At recovery time the btree uses the collation type and
> > the data
> >> value
> >> > factory to setup its template row array correctly.
> > Something like
> >> > for each dvd in row array
> >> > if (dvd instanceof StringDataValue)
> >> > dvd = dvd.getValue(dvf.getCharacterCollator
> > (type));
> >>
> >> Note that the store issue is not just a recovery time
> > issue, templates
> >> are required during normal runtime. Creation of these
> > templates used
> >> to show up (a long time ago) in performance analysis and
> > work was done
> >> to optimize the performance. So I am interested in making
> > these
> >> template creations as efficient as possible.
> >>
> >> Your proposal above does not look right to me - it could
> > just be I don't
> >> understand where the psuedo code is. The code I expect in
> > store would
> >> be something like below - letting the datafactory do
> > whatever is right
> >> based on the format id and the collation, if store is going
> > to "own"
> >> knowing
> >> the collation of a given column then I would expect
> > something like:
> >>
> >> for each format id in row array
> >> dvd = datavaluefactory.getObject(format id,
> > character_collator_type)
> >>
> >> note this means extra overhead for every object creation in
> > the
> >> template.
> >>
> >> To me it seems unfortunate to pass in this info per column,
> > when at
> >> least in 10.3 the current code it is one per database. I
> > saw the
> >> direction as:
> >>
> >> o 10.3 only needs one collation per database so hide the
> > info in the
> >> datafactory, basically there is one DEFAULT collation per
> > database.
> >> Thus no need for second argument to
> > datavaluefactory.getObject ()
> >>
> >> o future release needs to have different collations per
> > conglomerate,
> >> then at that time we can store a collator type per
> > conglomerate - we
> >> have mechanism today to upgrade on the fly. If we want
> > to support
> >> adding a collation to an existing database I would
> > suggest continueing
> >> the DEFAULT collation concept with some magic number
> > representing
> >> DEFAULT db collation in the datavaluefactory.getObject ()
> > call - which
> >> would mean use db wide default rather than specify
> > specific one. For
> >> new databases we would not need default, we could at that
> > time
> >> specify
> >> one per conglomerate.
> >> At this point we either change all the
> > datavaluefactory.getObject()
> >> calls to have 2 args and support DEFAULT_VALUE as second
> > argument, or
> >> maybe support both 1 and 2 arg calls - not sure.
> >>
> >> 0 future future release needs to have different collations
> > per column,
> >> then at that time we can store a collator type per column
> > - we
> >> continue to have mechanism to upgrade on fly as long as we
> > can come up
> >> with a default value for old tables. Same issues as above.
> >>
> >>
> >>
> >> >
> >> > - setting the collation property remains in the data
> > dictionary
> >> >
> >> > - basic database sets the locale for the
> > DataValueFactory after
> >> it boots
> >> > it, using a new method on DVF
> >> > void setLocale(Locale locale);
> >> >
> >> > I think approaching the problem this way will lead to a
> > cleaner
> >> solution
> >> > in the long term and be somewhat easier to implement.
> >> >
> >> > Thanks,
> >> > Dan.
> >> >
> >> >
> >> >
> >> >
> >> >
> >> >
> >>
> >>
> >
> >
> >
>
>
Re: Collation implementation WAS Re: Should COLLATION attribute related
code go in BasicDatabase?
Posted by Mike Matrigali <mi...@sbcglobal.net>.
Mamta Satoor wrote:
> Actually, let me start by asking a store question. Is store going to
> write the collation type column metadata only if the user has requested
> TERRITORY_BASED collation ie can 2 newly created 10.3 databases have
> different column metadata structure(ie with and without collation type
> info) depending on whether the user has requested TERRITORY_BASED or
> UCS_BASIC collation?
What I was leaning toward was that any 10.3 version db would write out
the same metadata, I am not totally sure of the format of that metadata
yet, but logically it can be used to determine the collate id of every
column in every conglomerate - both base tables and indexes.
Databases at a version prior to 10.3 would continue to write out the
same metadata as today. These databases stay at their version unless
they undergo a hard 10.3 upgrade.
When the hard upgrade happens it is not necessary to upgrade the
metadata of every conglomerate at the store level. This metadata all
has a version tag. Not sure what the number is right now, but let's say
it is 10.0. In 10.3 the default code will read and write 10.3 version
metadata. There will also be some code that can read 10.0 version
metadata, and the easiest thing to do is to read it into a 10.3 version
class so that the rest of the code need not know the difference. The
pre-10.3 soft upgrade db's should continue to write out 10.0 version
metadata.
>
> Mamta
>
> On 3/21/07, *Mike Matrigali* <mikem_app@sbcglobal.net
> <ma...@sbcglobal.net>> wrote:
>
>
>
> Mamta Satoor wrote:
> > 2)At the time of upgrade of pre-10.3 database, we should make
> sure that
> > derby.database.collation property with value UCS_BASIC in added to
> > services.properties. This is because we do not plan on supporting
> > collation change for existing databases.
> Is this required? How does the code handle a soft upgrade database
> where this property is not set? Could you say what you plan to do
> in both the hard and soft upgrade cases?
>
> I was assuming that only new databases would be affected and that
> somehow new code would just work on existing databases with no upgrade
> changes at all. So something like no collation property at all
> would be interpreted as UCS_BASIC. And of course old format SYSCOLUMN
> entries would be valid as well as old format conglomerate store
> metadata.
> >
> >
> > On 3/20/07, *Mamta Satoor* <msatoor@gmail.com
> <ma...@gmail.com>
> > <mailto: msatoor@gmail.com <ma...@gmail.com>>> wrote:
> >
> > Thanks, Mike and Dan for your responses. Based on this and
> following
> > from Dan's first mail in this thread
> > ******start of part of Dan's first mail in this thread*******
> > - basic database sets the locale for the DataValueFactory
> after it
> > boots it, using a new method on DVF
> > void setLocale(Locale locale);
> > ******end of part of Dan's first mail in this thread*******
> I may have missed this, is locale information already available from
> from services.properties ? For the store boot issue store will provide
> format id and collation id, but I believe you need locale information
> to determine the RuleBasedCollator and it can't depend on anything in
> the property conglomerate.
>
> > we donot need the collation attribute information at the DVF boot
> > time. It is sufficient to have locale info set on DVF at the
> boot
> > time using setLocale method by basic database. If store code
> calls
> > DVF to give proper DVD using formatid and collation type, DVF can
> > determine the correct RuleBasedCollator using the locale if the
> > collation type is territory based. So, DVF has everything it
> needs
> > to find the correct RuleBasedCollator for given collation type.
> >
> > I will go ahead and remove the following requirement from
> > Outstanding items under
> >
> http://wiki.apache.org/db-derby/BuiltInLanguageBasedOrderingDERBY-1478
> <http://wiki.apache.org/db-derby/BuiltInLanguageBasedOrderingDERBY-1478>
> >
> <http://wiki.apache.org/db-derby/BuiltInLanguageBasedOrderingDERBY-1478
> <http://wiki.apache.org/db-derby/BuiltInLanguageBasedOrderingDERBY-1478>>
> > 1)Add jdbc url attribute COLLATION into services.properties as
> > derby.database.collation property. If no COLLATION is
> specified at
> > database create time, then have UCS_BASIC as the value for
> > derby.database.collation We need the property in the
> > services.properties rather than properties conglomerate because
> > DataValueFactory <
> http://wiki.apache.org/db-derby/DataValueFactory>
> > needs this property before store has been booted completely.
> >
> > In addition, I will add an entry as follows under Implemented
> Items
> > on
> >
> http://wiki.apache.org/db-derby/BuiltInLanguageBasedOrderingDERBY-1478
> <http://wiki.apache.org/db-derby/BuiltInLanguageBasedOrderingDERBY-1478>
> > <
> http://wiki.apache.org/db-derby/BuiltInLanguageBasedOrderingDERBY-1478
> <http://wiki.apache.org/db-derby/BuiltInLanguageBasedOrderingDERBY-1478>>
> > At the time of database create time, optional JDBC url attribute
> > COLLATION is validated by the boot code in data dictionary
> and the
> > validated value of COLLATION(if none specified by user, then
> it will
> > default to UCS_BASIC which is also the only collation
> available on
> > pre-10.3 databases) attribute is saved as
> derby.database.collation
> > property in the properties conglomerate. This work was done by
> > revision 511283
> >
> > As always, any feedback is welcomed,
> > Mamta
> >
> > On 3/20/07, *Mike Matrigali* < mikem_app@sbcglobal.net
> <ma...@sbcglobal.net>
> > <mailto:mikem_app@sbcglobal.net
> <ma...@sbcglobal.net>>> wrote:
> >
> >
> >
> > Mamta Satoor wrote:
> >> Mike, I am not sure if your question, about how in store DVD with
> >> correction collation type is loaded, was answered or not. In
> > other
> >> words, you had question about following piece of pseudo code
> > from Dan
> >> if (dvd instanceof StringDataValue)
> >> dvd = dvd.getValue(dvf.getCharacterCollator(type));
> >>
> >> Let me attempt to answer it. It will help clear up things in
> > my mind too
> >> and make sure that I am understanding this correctly.
> >>
> >> Currently,
> >>
> >
> derby.impl.dtore.access.conglomerate.OpenConglomerateScratchSpace
> > has
> >> get_row_for_export which first gets a class template row using
> >> RowUtil.newClassInfoTemplate This method in RowUtil calls
> >> Monitor.classFromIdentifier to get the InstanceGetter for each
> > of the
> >> format ids identified by store. Once
> >> OpenConglomerateScratchSpace.get_row_for_export has the class
> > template
> >> row, it will call RowUtil.newRowFromClassInfoTemplate . This is the
> >> method, Dan is proposing to modify, ie store should pass an
> > additional
> >> array of int to RowUtil.newRowFromClassInfoTemplate which
> > will have the
> >> collation type associated with the formatids of the template row.
> >> RowUtil.newRowFromClassInfoTemplate will first get the DVD as
> > it does
> >> today using following
> >> columns[column_index] =
> >> (DataValueDescriptor)
> > classinfo_template[column_index].getNewInstance();
> >> In addition, it will need to do something like following
> >> if (columns[column_index] instanceof StringDataValue)
> >> dvd =
> >>
> > columns[column_index].getValue(
> dvf.getCharacterCollator(collationTypesForTemplateRows[column_index]));
> >
> > My opinion is that this work should be done in the datavalue
> > factory and
> > not outside. Dan suggested at one point that some of the
> work of
> > generating classes/instances should move from Monitor to
> > datavalue factory.
> >
> > So I was assuming something like RowUtil.newClassInfoTemplate
> > instead
> > of calling Monitor.classFromIdentifier(format_ids[i]) get an
> > array of
> > InstanceGetter's, it would call something like
> > datavaluefactory.classFromIdentifier(format_ids[i],
> > collator_ids[i]) -
> > then every InstanceGetter would produce the right type with
> > collator set
> > from then on.
> >
> >
> > Internal to dvf it can do the work of checking for
> instanceof if it
> > needs to, but because it is inside dvf maybe it can do
> something
> > smarter .
> >>
> >> Dan, let me know if I understood you right. This will help me
> > answer
> >> your question on the Derby wiki page
> >>
> >
> http://wiki.apache.org/db-derby/BuiltInLanguageBasedOrderingDERBY-1478
> > <
> http://wiki.apache.org/db-derby/BuiltInLanguageBasedOrderingDERBY-1478
> <http://wiki.apache.org/db-derby/BuiltInLanguageBasedOrderingDERBY-1478>>
> >> <
> >
> http://wiki.apache.org/db-derby/BuiltInLanguageBasedOrderingDERBY-1478
> > <
> http://wiki.apache.org/db-derby/BuiltInLanguageBasedOrderingDERBY-1478>>
> > I
> >> know that we don't need to get into the implementation code
> > details in
> >> the design phase, but I need to be able to picture this
> > particular case
> >> in my mind to understand where I am going.
> >>
> >> thanks,
> >> Mamta
> >>
> >>
> >> On 3/15/07, *Mike Matrigali* < mikem_app@sbcglobal.net
> <ma...@sbcglobal.net>
> > <mailto:mikem_app@sbcglobal.net
> <ma...@sbcglobal.net>>
> >> <mailto: mikem_app@sbcglobal.net <ma...@sbcglobal.net>
> > <mailto: mikem_app@sbcglobal.net
> <ma...@sbcglobal.net>>>> wrote:
> >>
> >>
> >>
> >> Daniel John Debrunner wrote:
> >> > Mamta Satoor wrote:
> >> >
> >> ...
> >>
> >> >
> >> > - At recovery time the btree uses the collation type and
> > the data
> >> value
> >> > factory to setup its template row array correctly.
> > Something like
> >> > for each dvd in row array
> >> > if (dvd instanceof StringDataValue)
> >> > dvd = dvd.getValue(dvf.getCharacterCollator
> > (type));
> >>
> >> Note that the store issue is not just a recovery time
> > issue, templates
> >> are required during normal runtime. Creation of these
> > templates used
> >> to show up (a long time ago) in performance analysis and
> > work was done
> >> to optimize the performance. So I am interested in making
> > these
> >> template creations as efficient as possible.
> >>
> >> Your proposal above does not look right to me - it could
> > just be I don't
> >> understand where the psuedo code is. The code I expect in
> > store would
> >> be something like below - letting the datafactory do
> > whatever is right
> >> based on the format id and the collation, if store is going
> > to "own"
> >> knowing
> >> the collation of a given column then I would expect
> > something like:
> >>
> >> for each format id in row array
> >> dvd = datavaluefactory.getObject(format id,
> > character_collator_type)
> >>
> >> note this means extra overhead for every object creation in
> > the
> >> template.
> >>
> >> To me it seems unfortunate to pass in this info per column,
> > when at
> >> least in 10.3 the current code it is one per database. I
> > saw the
> >> direction as:
> >>
> >> o 10.3 only needs one collation per database so hide the
> > info in the
> >> datafactory, basically there is one DEFAULT collation per
> > database.
> >> Thus no need for second argument to
> > datavaluefactory.getObject ()
> >>
> >> o future release needs to have different collations per
> > conglomerate,
> >> then at that time we can store a collator type per
> > conglomerate - we
> >> have mechanism today to upgrade on the fly. If we want
> > to support
> >> adding a collation to an existing database I would
> > suggest continueing
> >> the DEFAULT collation concept with some magic number
> > representing
> >> DEFAULT db collation in the datavaluefactory.getObject ()
> > call - which
> >> would mean use db wide default rather than specify
> > specific one. For
> >> new databases we would not need default, we could at that
> > time
> >> specify
> >> one per conglomerate.
> >> At this point we either change all the
> > datavaluefactory.getObject()
> >> calls to have 2 args and support DEFAULT_VALUE as second
> > argument, or
> >> maybe support both 1 and 2 arg calls - not sure.
> >>
> >> 0 future future release needs to have different collations
> > per column,
> >> then at that time we can store a collator type per column
> > - we
> >> continue to have mechanism to upgrade on fly as long as we
> > can come up
> >> with a default value for old tables. Same issues as above.
> >>
> >>
> >>
> >> >
> >> > - setting the collation property remains in the data
> > dictionary
> >> >
> >> > - basic database sets the locale for the
> > DataValueFactory after
> >> it boots
> >> > it, using a new method on DVF
> >> > void setLocale(Locale locale);
> >> >
> >> > I think approaching the problem this way will lead to a
> > cleaner
> >> solution
> >> > in the long term and be somewhat easier to implement.
> >> >
> >> > Thanks,
> >> > Dan.
> >> >
> >> >
> >> >
> >> >
> >> >
> >> >
> >>
> >>
> >
> >
> >
>
>
Re: Collation implementation WAS Re: Should COLLATION attribute related code go in BasicDatabase?
Posted by Mamta Satoor <ms...@gmail.com>.
Actually, let me start by asking a store question. Is store going to write
the collation type column metadata only if the user has requested
TERRITORY_BASED collation ie can 2 newly created 10.3 databases have
different column metadata structure(ie with and without collation type
info) depending on whether the user has requested TERRITORY_BASED or
UCS_BASIC collation?
Mamta
On 3/21/07, Mike Matrigali <mi...@sbcglobal.net> wrote:
>
>
>
> Mamta Satoor wrote:
> > 2)At the time of upgrade of pre-10.3 database, we should make sure that
> > derby.database.collation property with value UCS_BASIC in added to
> > services.properties. This is because we do not plan on supporting
> > collation change for existing databases.
> Is this required? How does the code handle a soft upgrade database
> where this property is not set? Could you say what you plan to do
> in both the hard and soft upgrade cases?
>
> I was assuming that only new databases would be affected and that
> somehow new code would just work on existing databases with no upgrade
> changes at all. So something like no collation property at all
> would be interpreted as UCS_BASIC. And of course old format SYSCOLUMN
> entries would be valid as well as old format conglomerate store metadata.
> >
> >
> > On 3/20/07, *Mamta Satoor* <msatoor@gmail.com
> > <ma...@gmail.com>> wrote:
> >
> > Thanks, Mike and Dan for your responses. Based on this and following
>
> > from Dan's first mail in this thread
> > ******start of part of Dan's first mail in this thread*******
> > - basic database sets the locale for the DataValueFactory after it
> > boots it, using a new method on DVF
> > void setLocale(Locale locale);
> > ******end of part of Dan's first mail in this thread*******
> I may have missed this, is locale information already available from
> from services.properties ? For the store boot issue store will provide
> format id and collation id, but I believe you need locale information
> to determine the RuleBasedCollator and it can't depend on anything in
> the property conglomerate.
>
> > we donot need the collation attribute information at the DVF boot
> > time. It is sufficient to have locale info set on DVF at the boot
> > time using setLocale method by basic database. If store code calls
> > DVF to give proper DVD using formatid and collation type, DVF can
> > determine the correct RuleBasedCollator using the locale if the
> > collation type is territory based. So, DVF has everything it needs
> > to find the correct RuleBasedCollator for given collation type.
> >
> > I will go ahead and remove the following requirement from
> > Outstanding items under
> >
> http://wiki.apache.org/db-derby/BuiltInLanguageBasedOrderingDERBY-1478
> > <http://wiki.apache.org/db-derby/BuiltInLanguageBasedOrderingDERBY-1478
> >
> > 1)Add jdbc url attribute COLLATION into services.properties as
> > derby.database.collation property. If no COLLATION is specified at
> > database create time, then have UCS_BASIC as the value for
> > derby.database.collation We need the property in the
> > services.properties rather than properties conglomerate because
> > DataValueFactory < http://wiki.apache.org/db-derby/DataValueFactory>
> > needs this property before store has been booted completely.
> >
> > In addition, I will add an entry as follows under Implemented Items
> > on
> >
> http://wiki.apache.org/db-derby/BuiltInLanguageBasedOrderingDERBY-1478
> > <http://wiki.apache.org/db-derby/BuiltInLanguageBasedOrderingDERBY-1478
> >
> > At the time of database create time, optional JDBC url attribute
> > COLLATION is validated by the boot code in data dictionary and the
> > validated value of COLLATION(if none specified by user, then it will
> > default to UCS_BASIC which is also the only collation available on
> > pre-10.3 databases) attribute is saved as derby.database.collation
> > property in the properties conglomerate. This work was done by
> > revision 511283
> >
> > As always, any feedback is welcomed,
> > Mamta
> >
> > On 3/20/07, *Mike Matrigali* < mikem_app@sbcglobal.net
> > <ma...@sbcglobal.net>> wrote:
> >
> >
> >
> > Mamta Satoor wrote:
> >> Mike, I am not sure if your question, about how in store DVD with
> >> correction collation type is loaded, was answered or not. In
> > other
> >> words, you had question about following piece of pseudo code
> > from Dan
> >> if (dvd instanceof StringDataValue)
> >> dvd = dvd.getValue(dvf.getCharacterCollator(type));
> >>
> >> Let me attempt to answer it. It will help clear up things in
> > my mind too
> >> and make sure that I am understanding this correctly.
> >>
> >> Currently,
> >>
> >
> derby.impl.dtore.access.conglomerate.OpenConglomerateScratchSpace
> > has
> >> get_row_for_export which first gets a class template row using
> >> RowUtil.newClassInfoTemplate This method in RowUtil calls
> >> Monitor.classFromIdentifier to get the InstanceGetter for each
> > of the
> >> format ids identified by store. Once
> >> OpenConglomerateScratchSpace.get_row_for_export has the class
> > template
> >> row, it will call RowUtil.newRowFromClassInfoTemplate . This is the
> >> method, Dan is proposing to modify, ie store should pass an
> > additional
> >> array of int to RowUtil.newRowFromClassInfoTemplate which
> > will have the
> >> collation type associated with the formatids of the template row.
> >> RowUtil.newRowFromClassInfoTemplate will first get the DVD as
> > it does
> >> today using following
> >> columns[column_index] =
> >> (DataValueDescriptor)
> > classinfo_template[column_index].getNewInstance();
> >> In addition, it will need to do something like following
> >> if (columns[column_index] instanceof StringDataValue)
> >> dvd =
> >>
> > columns[column_index].getValue(dvf.getCharacterCollator
> (collationTypesForTemplateRows[column_index]));
> >
> > My opinion is that this work should be done in the datavalue
> > factory and
> > not outside. Dan suggested at one point that some of the work
> of
> > generating classes/instances should move from Monitor to
> > datavalue factory.
> >
> > So I was assuming something like RowUtil.newClassInfoTemplate
> > instead
> > of calling Monitor.classFromIdentifier(format_ids[i]) get an
> > array of
> > InstanceGetter's, it would call something like
> > datavaluefactory.classFromIdentifier(format_ids[i],
> > collator_ids[i]) -
> > then every InstanceGetter would produce the right type with
> > collator set
> > from then on.
> >
> >
> > Internal to dvf it can do the work of checking for instanceof if
> it
> > needs to, but because it is inside dvf maybe it can do something
> > smarter .
> >>
> >> Dan, let me know if I understood you right. This will help me
> > answer
> >> your question on the Derby wiki page
> >>
> >
> http://wiki.apache.org/db-derby/BuiltInLanguageBasedOrderingDERBY-1478
> > <http://wiki.apache.org/db-derby/BuiltInLanguageBasedOrderingDERBY-1478
> >
> >> <
> >
> http://wiki.apache.org/db-derby/BuiltInLanguageBasedOrderingDERBY-1478
> > <http://wiki.apache.org/db-derby/BuiltInLanguageBasedOrderingDERBY-1478
> >>
> > I
> >> know that we don't need to get into the implementation code
> > details in
> >> the design phase, but I need to be able to picture this
> > particular case
> >> in my mind to understand where I am going.
> >>
> >> thanks,
> >> Mamta
> >>
> >>
> >> On 3/15/07, *Mike Matrigali* < mikem_app@sbcglobal.net
> > <ma...@sbcglobal.net>
> >> <mailto:mikem_app@sbcglobal.net
> > <ma...@sbcglobal.net>>> wrote:
> >>
> >>
> >>
> >> Daniel John Debrunner wrote:
> >> > Mamta Satoor wrote:
> >> >
> >> ...
> >>
> >> >
> >> > - At recovery time the btree uses the collation type and
> > the data
> >> value
> >> > factory to setup its template row array correctly.
> > Something like
> >> > for each dvd in row array
> >> > if (dvd instanceof StringDataValue)
> >> > dvd = dvd.getValue(dvf.getCharacterCollator
> > (type));
> >>
> >> Note that the store issue is not just a recovery time
> > issue, templates
> >> are required during normal runtime. Creation of these
> > templates used
> >> to show up (a long time ago) in performance analysis and
> > work was done
> >> to optimize the performance. So I am interested in making
> > these
> >> template creations as efficient as possible.
> >>
> >> Your proposal above does not look right to me - it could
> > just be I don't
> >> understand where the psuedo code is. The code I expect in
> > store would
> >> be something like below - letting the datafactory do
> > whatever is right
> >> based on the format id and the collation, if store is going
> > to "own"
> >> knowing
> >> the collation of a given column then I would expect
> > something like:
> >>
> >> for each format id in row array
> >> dvd = datavaluefactory.getObject(format id,
> > character_collator_type)
> >>
> >> note this means extra overhead for every object creation in
> > the
> >> template.
> >>
> >> To me it seems unfortunate to pass in this info per column,
> > when at
> >> least in 10.3 the current code it is one per database. I
> > saw the
> >> direction as:
> >>
> >> o 10.3 only needs one collation per database so hide the
> > info in the
> >> datafactory, basically there is one DEFAULT collation per
> > database.
> >> Thus no need for second argument to
> > datavaluefactory.getObject ()
> >>
> >> o future release needs to have different collations per
> > conglomerate,
> >> then at that time we can store a collator type per
> > conglomerate - we
> >> have mechanism today to upgrade on the fly. If we want
> > to support
> >> adding a collation to an existing database I would
> > suggest continueing
> >> the DEFAULT collation concept with some magic number
> > representing
> >> DEFAULT db collation in the datavaluefactory.getObject ()
> > call - which
> >> would mean use db wide default rather than specify
> > specific one. For
> >> new databases we would not need default, we could at that
> > time
> >> specify
> >> one per conglomerate.
> >> At this point we either change all the
> > datavaluefactory.getObject()
> >> calls to have 2 args and support DEFAULT_VALUE as second
> > argument, or
> >> maybe support both 1 and 2 arg calls - not sure.
> >>
> >> 0 future future release needs to have different collations
> > per column,
> >> then at that time we can store a collator type per column
> > - we
> >> continue to have mechanism to upgrade on fly as long as we
> > can come up
> >> with a default value for old tables. Same issues as above.
> >>
> >>
> >>
> >> >
> >> > - setting the collation property remains in the data
> > dictionary
> >> >
> >> > - basic database sets the locale for the
> > DataValueFactory after
> >> it boots
> >> > it, using a new method on DVF
> >> > void setLocale(Locale locale);
> >> >
> >> > I think approaching the problem this way will lead to a
> > cleaner
> >> solution
> >> > in the long term and be somewhat easier to implement.
> >> >
> >> > Thanks,
> >> > Dan.
> >> >
> >> >
> >> >
> >> >
> >> >
> >> >
> >>
> >>
> >
> >
> >
>
>
Re: Collation implementation WAS Re: Should COLLATION attribute related
code go in BasicDatabase?
Posted by Mike Matrigali <mi...@sbcglobal.net>.
Mamta Satoor wrote:
> 2)At the time of upgrade of pre-10.3 database, we should make sure that
> derby.database.collation property with value UCS_BASIC in added to
> services.properties. This is because we do not plan on supporting
> collation change for existing databases.
Is this required? How does the code handle a soft upgrade database
where this property is not set? Could you say what you plan to do
in both the hard and soft upgrade cases?
I was assuming that only new databases would be affected and that
somehow new code would just work on existing databases with no upgrade
changes at all. So something like no collation property at all
would be interpreted as UCS_BASIC. And of course old format SYSCOLUMN
entries would be valid as well as old format conglomerate store metadata.
>
>
> On 3/20/07, *Mamta Satoor* <msatoor@gmail.com
> <ma...@gmail.com>> wrote:
>
> Thanks, Mike and Dan for your responses. Based on this and following
> from Dan's first mail in this thread
> ******start of part of Dan's first mail in this thread*******
> - basic database sets the locale for the DataValueFactory after it
> boots it, using a new method on DVF
> void setLocale(Locale locale);
> ******end of part of Dan's first mail in this thread*******
I may have missed this, is locale information already available from
from services.properties? For the store boot issue store will provide
format id and collation id, but I believe you need locale information
to determine the RuleBasedCollator and it can't depend on anything in
the property conglomerate.
> we donot need the collation attribute information at the DVF boot
> time. It is sufficient to have locale info set on DVF at the boot
> time using setLocale method by basic database. If store code calls
> DVF to give proper DVD using formatid and collation type, DVF can
> determine the correct RuleBasedCollator using the locale if the
> collation type is territory based. So, DVF has everything it needs
> to find the correct RuleBasedCollator for given collation type.
>
> I will go ahead and remove the following requirement from
> Outstanding items under
> http://wiki.apache.org/db-derby/BuiltInLanguageBasedOrderingDERBY-1478
> <http://wiki.apache.org/db-derby/BuiltInLanguageBasedOrderingDERBY-1478>
> 1)Add jdbc url attribute COLLATION into services.properties as
> derby.database.collation property. If no COLLATION is specified at
> database create time, then have UCS_BASIC as the value for
> derby.database.collation We need the property in the
> services.properties rather than properties conglomerate because
> DataValueFactory <http://wiki.apache.org/db-derby/DataValueFactory>
> needs this property before store has been booted completely.
>
> In addition, I will add an entry as follows under Implemented Items
> on
> http://wiki.apache.org/db-derby/BuiltInLanguageBasedOrderingDERBY-1478
> <http://wiki.apache.org/db-derby/BuiltInLanguageBasedOrderingDERBY-1478>
> At the time of database create time, optional JDBC url attribute
> COLLATION is validated by the boot code in data dictionary and the
> validated value of COLLATION(if none specified by user, then it will
> default to UCS_BASIC which is also the only collation available on
> pre-10.3 databases) attribute is saved as derby.database.collation
> property in the properties conglomerate. This work was done by
> revision 511283
>
> As always, any feedback is welcomed,
> Mamta
>
> On 3/20/07, *Mike Matrigali* <mikem_app@sbcglobal.net
> <ma...@sbcglobal.net>> wrote:
>
>
>
> Mamta Satoor wrote:
>> Mike, I am not sure if your question, about how in store DVD with
>> correction collation type is loaded, was answered or not. In
> other
>> words, you had question about following piece of pseudo code
> from Dan
>> if (dvd instanceof StringDataValue)
>> dvd = dvd.getValue(dvf.getCharacterCollator(type));
>>
>> Let me attempt to answer it. It will help clear up things in
> my mind too
>> and make sure that I am understanding this correctly.
>>
>> Currently,
>>
> derby.impl.dtore.access.conglomerate.OpenConglomerateScratchSpace
> has
>> get_row_for_export which first gets a class template row using
>> RowUtil.newClassInfoTemplate This method in RowUtil calls
>> Monitor.classFromIdentifier to get the InstanceGetter for each
> of the
>> format ids identified by store. Once
>> OpenConglomerateScratchSpace.get_row_for_export has the class
> template
>> row, it will call RowUtil.newRowFromClassInfoTemplate. This is the
>> method, Dan is proposing to modify, ie store should pass an
> additional
>> array of int to RowUtil.newRowFromClassInfoTemplate which
> will have the
>> collation type associated with the formatids of the template row.
>> RowUtil.newRowFromClassInfoTemplate will first get the DVD as
> it does
>> today using following
>> columns[column_index] =
>> (DataValueDescriptor)
> classinfo_template[column_index].getNewInstance();
>> In addition, it will need to do something like following
>> if (columns[column_index] instanceof StringDataValue)
>> dvd =
>>
> columns[column_index].getValue(dvf.getCharacterCollator(collationTypesForTemplateRows[column_index]));
>
> My opinion is that this work should be done in the datavalue
> factory and
> not outside. Dan suggested at one point that some of the work of
> generating classes/instances should move from Monitor to
> datavalue factory.
>
> So I was assuming something like RowUtil.newClassInfoTemplate
> instead
> of calling Monitor.classFromIdentifier(format_ids[i]) get an
> array of
> InstanceGetter's, it would call something like
> datavaluefactory.classFromIdentifier(format_ids[i],
> collator_ids[i]) -
> then every InstanceGetter would produce the right type with
> collator set
> from then on.
>
>
> Internal to dvf it can do the work of checking for instanceof if it
> needs to, but because it is inside dvf maybe it can do something
> smarter .
>>
>> Dan, let me know if I understood you right. This will help me
> answer
>> your question on the Derby wiki page
>>
> http://wiki.apache.org/db-derby/BuiltInLanguageBasedOrderingDERBY-1478
> <http://wiki.apache.org/db-derby/BuiltInLanguageBasedOrderingDERBY-1478>
>> <
> http://wiki.apache.org/db-derby/BuiltInLanguageBasedOrderingDERBY-1478
> <http://wiki.apache.org/db-derby/BuiltInLanguageBasedOrderingDERBY-1478>>
> I
>> know that we don't need to get into the implementation code
> details in
>> the design phase, but I need to be able to picture this
> particular case
>> in my mind to understand where I am going.
>>
>> thanks,
>> Mamta
>>
>>
>> On 3/15/07, *Mike Matrigali* < mikem_app@sbcglobal.net
> <ma...@sbcglobal.net>
>> <mailto:mikem_app@sbcglobal.net
> <ma...@sbcglobal.net>>> wrote:
>>
>>
>>
>> Daniel John Debrunner wrote:
>> > Mamta Satoor wrote:
>> >
>> ...
>>
>> >
>> > - At recovery time the btree uses the collation type and
> the data
>> value
>> > factory to setup its template row array correctly.
> Something like
>> > for each dvd in row array
>> > if (dvd instanceof StringDataValue)
>> > dvd = dvd.getValue(dvf.getCharacterCollator
> (type));
>>
>> Note that the store issue is not just a recovery time
> issue, templates
>> are required during normal runtime. Creation of these
> templates used
>> to show up (a long time ago) in performance analysis and
> work was done
>> to optimize the performance. So I am interested in making
> these
>> template creations as efficient as possible.
>>
>> Your proposal above does not look right to me - it could
> just be I don't
>> understand where the psuedo code is. The code I expect in
> store would
>> be something like below - letting the datafactory do
> whatever is right
>> based on the format id and the collation, if store is going
> to "own"
>> knowing
>> the collation of a given column then I would expect
> something like:
>>
>> for each format id in row array
>> dvd = datavaluefactory.getObject(format id,
> character_collator_type)
>>
>> note this means extra overhead for every object creation in
> the
>> template.
>>
>> To me it seems unfortunate to pass in this info per column,
> when at
>> least in 10.3 the current code it is one per database. I
> saw the
>> direction as:
>>
>> o 10.3 only needs one collation per database so hide the
> info in the
>> datafactory, basically there is one DEFAULT collation per
> database.
>> Thus no need for second argument to
> datavaluefactory.getObject ()
>>
>> o future release needs to have different collations per
> conglomerate,
>> then at that time we can store a collator type per
> conglomerate - we
>> have mechanism today to upgrade on the fly. If we want
> to support
>> adding a collation to an existing database I would
> suggest continueing
>> the DEFAULT collation concept with some magic number
> representing
>> DEFAULT db collation in the datavaluefactory.getObject ()
> call - which
>> would mean use db wide default rather than specify
> specific one. For
>> new databases we would not need default, we could at that
> time
>> specify
>> one per conglomerate.
>> At this point we either change all the
> datavaluefactory.getObject()
>> calls to have 2 args and support DEFAULT_VALUE as second
> argument, or
>> maybe support both 1 and 2 arg calls - not sure.
>>
>> 0 future future release needs to have different collations
> per column,
>> then at that time we can store a collator type per column
> - we
>> continue to have mechanism to upgrade on fly as long as we
> can come up
>> with a default value for old tables. Same issues as above.
>>
>>
>>
>> >
>> > - setting the collation property remains in the data
> dictionary
>> >
>> > - basic database sets the locale for the
> DataValueFactory after
>> it boots
>> > it, using a new method on DVF
>> > void setLocale(Locale locale);
>> >
>> > I think approaching the problem this way will lead to a
> cleaner
>> solution
>> > in the long term and be somewhat easier to implement.
>> >
>> > Thanks,
>> > Dan.
>> >
>> >
>> >
>> >
>> >
>> >
>>
>>
>
>
>
Re: Collation implementation WAS Re: Should COLLATION attribute related code go in BasicDatabase?
Posted by Mamta Satoor <ms...@gmail.com>.
Also, I will fix the following outstanding item on
http://wiki.apache.org/db-derby/BuiltInLanguageBasedOrderingDERBY-1478
to say that the collation property should be added to properties
conglomerate and not services.properties.
2)At the time of upgrade of pre-10.3 database, we should make sure that
derby.database.collation property with value UCS_BASIC in added to
services.properties. This is because we do not plan on supporting collation
change for existing databases.
On 3/20/07, Mamta Satoor <ms...@gmail.com> wrote:
>
> Thanks, Mike and Dan for your responses. Based on this and following from
> Dan's first mail in this thread
> ******start of part of Dan's first mail in this thread*******
> - basic database sets the locale for the DataValueFactory after it boots
> it, using a new method on DVF
> void setLocale(Locale locale);
> ******end of part of Dan's first mail in this thread*******
> we donot need the collation attribute information at the DVF boot time. It
> is sufficient to have locale info set on DVF at the boot time using
> setLocale method by basic database. If store code calls DVF to give proper
> DVD using formatid and collation type, DVF can determine the correct
> RuleBasedCollator using the locale if the collation type is territory based.
> So, DVF has everything it needs to find the correct RuleBasedCollator for
> given collation type.
>
> I will go ahead and remove the following requirement from Outstanding
> items under http://wiki.apache.org/db-derby/BuiltInLanguageBasedOrderingDERBY-1478
>
> 1)Add jdbc url attribute COLLATION into services.properties as
> derby.database.collation property. If no COLLATION is specified at
> database create time, then have UCS_BASIC as the value for
> derby.database.collation We need the property in the services.propertiesrather than properties conglomerate because
> DataValueFactory <http://wiki.apache.org/db-derby/DataValueFactory> needs
> this property before store has been booted completely.
>
> In addition, I will add an entry as follows under Implemented Items on http://wiki.apache.org/db-derby/BuiltInLanguageBasedOrderingDERBY-1478
>
> At the time of database create time, optional JDBC url attribute
> COLLATION is validated by the boot code in data dictionary and the validated
> value of COLLATION(if none specified by user, then it will default to
> UCS_BASIC which is also the only collation available on pre-10.3databases) attribute is saved as
> derby.database.collation property in the properties conglomerate. This
> work was done by revision 511283
>
> As always, any feedback is welcomed,
> Mamta
>
> On 3/20/07, Mike Matrigali <mikem_app@sbcglobal.net > wrote:
> >
> >
> >
> > Mamta Satoor wrote:
> > > Mike, I am not sure if your question, about how in store DVD with
> > > correction collation type is loaded, was answered or not. In other
> > > words, you had question about following piece of pseudo code from Dan
> > > if (dvd instanceof StringDataValue)
> > > dvd = dvd.getValue(dvf.getCharacterCollator(type));
> > >
> > > Let me attempt to answer it. It will help clear up things in my mind
> > too
> > > and make sure that I am understanding this correctly.
> > >
> > > Currently,
> > > derby.impl.dtore.access.conglomerate.OpenConglomerateScratchSpace has
> > > get_row_for_export which first gets a class template row using
> > > RowUtil.newClassInfoTemplate This method in RowUtil calls
> > > Monitor.classFromIdentifier to get the InstanceGetter for each of the
> > > format ids identified by store. Once
> > > OpenConglomerateScratchSpace.get_row_for_export has the class template
> > > row, it will call RowUtil.newRowFromClassInfoTemplate. This is the
> > > method, Dan is proposing to modify, ie store should pass an additional
> > > array of int to RowUtil.newRowFromClassInfoTemplate which will have
> > the
> > > collation type associated with the formatids of the template row.
> > > RowUtil.newRowFromClassInfoTemplate will first get the DVD as it does
> > > today using following
> > > columns[column_index] =
> > > (DataValueDescriptor)
> > classinfo_template[column_index].getNewInstance();
> > > In addition, it will need to do something like following
> > > if (columns[column_index] instanceof StringDataValue)
> > > dvd =
> > > columns[column_index].getValue(dvf.getCharacterCollator
> > (collationTypesForTemplateRows[column_index]));
> >
> > My opinion is that this work should be done in the datavalue factory and
> > not outside. Dan suggested at one point that some of the work of
> > generating classes/instances should move from Monitor to datavalue
> > factory.
> >
> > So I was assuming something like RowUtil.newClassInfoTemplate instead
> > of calling Monitor.classFromIdentifier(format_ids[i]) get an array of
> > InstanceGetter's, it would call something like
> > datavaluefactory.classFromIdentifier(format_ids[i], collator_ids[i]) -
> > then every InstanceGetter would produce the right type with collator set
> > from then on.
> >
> >
> > Internal to dvf it can do the work of checking for instanceof if it
> > needs to, but because it is inside dvf maybe it can do something smarter
> > .
> > >
> > > Dan, let me know if I understood you right. This will help me answer
> > > your question on the Derby wiki page
> > > http://wiki.apache.org/db-derby/BuiltInLanguageBasedOrderingDERBY-1478
> >
> > > < http://wiki.apache.org/db-derby/BuiltInLanguageBasedOrderingDERBY-1478
> > > I
> > > know that we don't need to get into the implementation code details in
> >
> > > the design phase, but I need to be able to picture this particular
> > case
> > > in my mind to understand where I am going.
> > >
> > > thanks,
> > > Mamta
> > >
> > >
> > > On 3/15/07, *Mike Matrigali* < mikem_app@sbcglobal.net
> > > <ma...@sbcglobal.net>> wrote:
> > >
> > >
> > >
> > > Daniel John Debrunner wrote:
> > > > Mamta Satoor wrote:
> > > >
> > > ...
> > >
> > > >
> > > > - At recovery time the btree uses the collation type and the
> > data
> > > value
> > > > factory to setup its template row array correctly. Something
> > like
> > > > for each dvd in row array
> > > > if (dvd instanceof StringDataValue)
> > > > dvd = dvd.getValue(dvf.getCharacterCollator(type));
> > >
> > > Note that the store issue is not just a recovery time issue,
> > templates
> > > are required during normal runtime. Creation of these templates
> > used
> > > to show up (a long time ago) in performance analysis and work was
> > done
> > > to optimize the performance. So I am interested in making these
> > > template creations as efficient as possible.
> > >
> > > Your proposal above does not look right to me - it could just be I
> > don't
> > > understand where the psuedo code is. The code I expect in store
> > would
> > > be something like below - letting the datafactory do whatever is
> > right
> > > based on the format id and the collation, if store is going to
> > "own"
> > > knowing
> > > the collation of a given column then I would expect something
> > like:
> > >
> > > for each format id in row array
> > > dvd = datavaluefactory.getObject(format id,
> > character_collator_type)
> > >
> > > note this means extra overhead for every object creation in the
> > > template.
> > >
> > > To me it seems unfortunate to pass in this info per column, when
> > at
> > > least in 10.3 the current code it is one per database. I saw the
> > > direction as:
> > >
> > > o 10.3 only needs one collation per database so hide the info in
> > the
> > > datafactory, basically there is one DEFAULT collation per
> > database.
> > > Thus no need for second argument to datavaluefactory.getObject()
> > >
> > > o future release needs to have different collations per
> > conglomerate,
> > > then at that time we can store a collator type per conglomerate
> > - we
> > > have mechanism today to upgrade on the fly. If we want to
> > support
> > > adding a collation to an existing database I would suggest
> > continueing
> > > the DEFAULT collation concept with some magic number
> > representing
> > > DEFAULT db collation in the datavaluefactory.getObject () call -
> > which
> > > would mean use db wide default rather than specify specific one.
> > For
> > > new databases we would not need default, we could at that time
> > > specify
> > > one per conglomerate.
> > > At this point we either change all the
> > datavaluefactory.getObject()
> > > calls to have 2 args and support DEFAULT_VALUE as second
> > argument, or
> > > maybe support both 1 and 2 arg calls - not sure.
> > >
> > > 0 future future release needs to have different collations per
> > column,
> > > then at that time we can store a collator type per column - we
> > > continue to have mechanism to upgrade on fly as long as we can
> > come up
> > > with a default value for old tables. Same issues as above.
> > >
> > >
> > >
> > > >
> > > > - setting the collation property remains in the data dictionary
> > > >
> > > > - basic database sets the locale for the DataValueFactory after
> >
> > > it boots
> > > > it, using a new method on DVF
> > > > void setLocale(Locale locale);
> > > >
> > > > I think approaching the problem this way will lead to a cleaner
> >
> > > solution
> > > > in the long term and be somewhat easier to implement.
> > > >
> > > > Thanks,
> > > > Dan.
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > >
> > >
> >
> >
>
Re: Collation implementation WAS Re: Should COLLATION attribute related code go in BasicDatabase?
Posted by Mamta Satoor <ms...@gmail.com>.
Thanks, Mike and Dan for your responses. Based on this and following from
Dan's first mail in this thread
******start of part of Dan's first mail in this thread*******
- basic database sets the locale for the DataValueFactory after it boots it,
using a new method on DVF
void setLocale(Locale locale);
******end of part of Dan's first mail in this thread*******
we donot need the collation attribute information at the DVF boot time. It
is sufficient to have locale info set on DVF at the boot time using
setLocale method by basic database. If store code calls DVF to give proper
DVD using formatid and collation type, DVF can determine the correct
RuleBasedCollator using the locale if the collation type is territory based.
So, DVF has everything it needs to find the correct RuleBasedCollator for
given collation type.
I will go ahead and remove the following requirement from Outstanding items
under http://wiki.apache.org/db-derby/BuiltInLanguageBasedOrderingDERBY-1478
1)Add jdbc url attribute COLLATION into services.properties as
derby.database.collation property. If no COLLATION is specified at database
create time, then have UCS_BASIC as the value for
derby.database.collationWe need the property in the
services.properties rather than properties conglomerate because
DataValueFactory <http://wiki.apache.org/db-derby/DataValueFactory> needs
this property before store has been booted completely.
In addition, I will add an entry as follows under Implemented Items on
http://wiki.apache.org/db-derby/BuiltInLanguageBasedOrderingDERBY-1478
At the time of database create time, optional JDBC url attribute
COLLATION is validated by the boot code in data dictionary and the validated
value of COLLATION(if none specified by user, then it will default to
UCS_BASIC which is also the only collation available on pre-10.3 databases)
attribute is saved as derby.database.collation property in the properties
conglomerate. This work was done by revision 511283
As always, any feedback is welcomed,
Mamta
On 3/20/07, Mike Matrigali <mikem_app@sbcglobal.net > wrote:
>
>
>
> Mamta Satoor wrote:
> > Mike, I am not sure if your question, about how in store DVD with
> > correction collation type is loaded, was answered or not. In other
> > words, you had question about following piece of pseudo code from Dan
> > if (dvd instanceof StringDataValue)
> > dvd = dvd.getValue(dvf.getCharacterCollator(type));
> >
> > Let me attempt to answer it. It will help clear up things in my mind too
>
> > and make sure that I am understanding this correctly.
> >
> > Currently,
> > derby.impl.dtore.access.conglomerate.OpenConglomerateScratchSpace has
> > get_row_for_export which first gets a class template row using
> > RowUtil.newClassInfoTemplate This method in RowUtil calls
> > Monitor.classFromIdentifier to get the InstanceGetter for each of the
> > format ids identified by store. Once
> > OpenConglomerateScratchSpace.get_row_for_export has the class template
> > row, it will call RowUtil.newRowFromClassInfoTemplate. This is the
> > method, Dan is proposing to modify, ie store should pass an additional
> > array of int to RowUtil.newRowFromClassInfoTemplate which will have the
> > collation type associated with the formatids of the template row.
> > RowUtil.newRowFromClassInfoTemplate will first get the DVD as it does
> > today using following
> > columns[column_index] =
> > (DataValueDescriptor) classinfo_template[column_index].getNewInstance();
> > In addition, it will need to do something like following
> > if (columns[column_index] instanceof StringDataValue)
> > dvd =
> > columns[column_index].getValue(dvf.getCharacterCollator
> (collationTypesForTemplateRows[column_index]));
>
> My opinion is that this work should be done in the datavalue factory and
> not outside. Dan suggested at one point that some of the work of
> generating classes/instances should move from Monitor to datavalue
> factory.
>
> So I was assuming something like RowUtil.newClassInfoTemplate instead
> of calling Monitor.classFromIdentifier(format_ids[i]) get an array of
> InstanceGetter's, it would call something like
> datavaluefactory.classFromIdentifier(format_ids[i], collator_ids[i]) -
> then every InstanceGetter would produce the right type with collator set
> from then on.
>
>
> Internal to dvf it can do the work of checking for instanceof if it
> needs to, but because it is inside dvf maybe it can do something smarter .
> >
> > Dan, let me know if I understood you right. This will help me answer
> > your question on the Derby wiki page
> > http://wiki.apache.org/db-derby/BuiltInLanguageBasedOrderingDERBY-1478
> > < http://wiki.apache.org/db-derby/BuiltInLanguageBasedOrderingDERBY-1478
> > I
> > know that we don't need to get into the implementation code details in
> > the design phase, but I need to be able to picture this particular case
> > in my mind to understand where I am going.
> >
> > thanks,
> > Mamta
> >
> >
> > On 3/15/07, *Mike Matrigali* < mikem_app@sbcglobal.net
> > <ma...@sbcglobal.net>> wrote:
> >
> >
> >
> > Daniel John Debrunner wrote:
> > > Mamta Satoor wrote:
> > >
> > ...
> >
> > >
> > > - At recovery time the btree uses the collation type and the data
> > value
> > > factory to setup its template row array correctly. Something like
>
> > > for each dvd in row array
> > > if (dvd instanceof StringDataValue)
> > > dvd = dvd.getValue(dvf.getCharacterCollator (type));
> >
> > Note that the store issue is not just a recovery time issue,
> templates
> > are required during normal runtime. Creation of these templates
> used
> > to show up (a long time ago) in performance analysis and work was
> done
> > to optimize the performance. So I am interested in making these
> > template creations as efficient as possible.
> >
> > Your proposal above does not look right to me - it could just be I
> don't
> > understand where the psuedo code is. The code I expect in store
> would
> > be something like below - letting the datafactory do whatever is
> right
> > based on the format id and the collation, if store is going to "own"
> > knowing
> > the collation of a given column then I would expect something like:
> >
> > for each format id in row array
> > dvd = datavaluefactory.getObject(format id,
> character_collator_type)
> >
> > note this means extra overhead for every object creation in the
> > template.
> >
> > To me it seems unfortunate to pass in this info per column, when at
> > least in 10.3 the current code it is one per database. I saw the
> > direction as:
> >
> > o 10.3 only needs one collation per database so hide the info in the
> > datafactory, basically there is one DEFAULT collation per
> database.
> > Thus no need for second argument to datavaluefactory.getObject ()
> >
> > o future release needs to have different collations per
> conglomerate,
> > then at that time we can store a collator type per conglomerate -
> we
> > have mechanism today to upgrade on the fly. If we want to support
>
> > adding a collation to an existing database I would suggest
> continueing
> > the DEFAULT collation concept with some magic number representing
> > DEFAULT db collation in the datavaluefactory.getObject () call -
> which
> > would mean use db wide default rather than specify specific one.
> For
> > new databases we would not need default, we could at that time
> > specify
> > one per conglomerate.
> > At this point we either change all the datavaluefactory.getObject
> ()
> > calls to have 2 args and support DEFAULT_VALUE as second argument,
> or
> > maybe support both 1 and 2 arg calls - not sure.
> >
> > 0 future future release needs to have different collations per
> column,
> > then at that time we can store a collator type per column - we
> > continue to have mechanism to upgrade on fly as long as we can come
> up
> > with a default value for old tables. Same issues as above.
> >
> >
> >
> > >
> > > - setting the collation property remains in the data dictionary
> > >
> > > - basic database sets the locale for the DataValueFactory after
> > it boots
> > > it, using a new method on DVF
> > > void setLocale(Locale locale);
> > >
> > > I think approaching the problem this way will lead to a cleaner
> > solution
> > > in the long term and be somewhat easier to implement.
> > >
> > > Thanks,
> > > Dan.
> > >
> > >
> > >
> > >
> > >
> > >
> >
> >
>
>
Re: Collation implementation WAS Re: Should COLLATION attribute related
code go in BasicDatabase?
Posted by Daniel John Debrunner <dj...@apache.org>.
Mike Matrigali wrote:
> My opinion is that this work should be done in the datavalue factory and
> not outside. Dan suggested at one point that some of the work of
> generating classes/instances should move from Monitor to datavalue factory.
>
> So I was assuming something like RowUtil.newClassInfoTemplate instead
> of calling Monitor.classFromIdentifier(format_ids[i]) get an array of
> InstanceGetter's, it would call something like
> datavaluefactory.classFromIdentifier(format_ids[i], collator_ids[i]) -
> then every InstanceGetter would produce the right type with collator set
> from then on.
+1
Dan.
Re: Collation implementation WAS Re: Should COLLATION attribute related
code go in BasicDatabase?
Posted by Mike Matrigali <mi...@sbcglobal.net>.
Mamta Satoor wrote:
> Mike, I am not sure if your question, about how in store DVD with
> correction collation type is loaded, was answered or not. In other
> words, you had question about following piece of pseudo code from Dan
> if (dvd instanceof StringDataValue)
> dvd = dvd.getValue(dvf.getCharacterCollator(type));
>
> Let me attempt to answer it. It will help clear up things in my mind too
> and make sure that I am understanding this correctly.
>
> Currently,
> derby.impl.dtore.access.conglomerate.OpenConglomerateScratchSpace has
> get_row_for_export which first gets a class template row using
> RowUtil.newClassInfoTemplate This method in RowUtil calls
> Monitor.classFromIdentifier to get the InstanceGetter for each of the
> format ids identified by store. Once
> OpenConglomerateScratchSpace.get_row_for_export has the class template
> row, it will call RowUtil.newRowFromClassInfoTemplate. This is the
> method, Dan is proposing to modify, ie store should pass an additional
> array of int to RowUtil.newRowFromClassInfoTemplate which will have the
> collation type associated with the formatids of the template row.
> RowUtil.newRowFromClassInfoTemplate will first get the DVD as it does
> today using following
> columns[column_index] =
> (DataValueDescriptor) classinfo_template[column_index].getNewInstance();
> In addition, it will need to do something like following
> if (columns[column_index] instanceof StringDataValue)
> dvd =
> columns[column_index].getValue(dvf.getCharacterCollator(collationTypesForTemplateRows[column_index]));
My opinion is that this work should be done in the datavalue factory and
not outside. Dan suggested at one point that some of the work of
generating classes/instances should move from Monitor to datavalue factory.
So I was assuming something like RowUtil.newClassInfoTemplate instead
of calling Monitor.classFromIdentifier(format_ids[i]) get an array of
InstanceGetter's, it would call something like
datavaluefactory.classFromIdentifier(format_ids[i], collator_ids[i]) -
then every InstanceGetter would produce the right type with collator set
from then on.
Internal to dvf it can do the work of checking for instanceof if it
needs to, but because it is inside dvf maybe it can do something smarter .
>
> Dan, let me know if I understood you right. This will help me answer
> your question on the Derby wiki page
> http://wiki.apache.org/db-derby/BuiltInLanguageBasedOrderingDERBY-1478
> <http://wiki.apache.org/db-derby/BuiltInLanguageBasedOrderingDERBY-1478> I
> know that we don't need to get into the implementation code details in
> the design phase, but I need to be able to picture this particular case
> in my mind to understand where I am going.
>
> thanks,
> Mamta
>
>
> On 3/15/07, *Mike Matrigali* <mikem_app@sbcglobal.net
> <ma...@sbcglobal.net>> wrote:
>
>
>
> Daniel John Debrunner wrote:
> > Mamta Satoor wrote:
> >
> ...
>
> >
> > - At recovery time the btree uses the collation type and the data
> value
> > factory to setup its template row array correctly. Something like
> > for each dvd in row array
> > if (dvd instanceof StringDataValue)
> > dvd = dvd.getValue(dvf.getCharacterCollator (type));
>
> Note that the store issue is not just a recovery time issue, templates
> are required during normal runtime. Creation of these templates used
> to show up (a long time ago) in performance analysis and work was done
> to optimize the performance. So I am interested in making these
> template creations as efficient as possible.
>
> Your proposal above does not look right to me - it could just be I don't
> understand where the psuedo code is. The code I expect in store would
> be something like below - letting the datafactory do whatever is right
> based on the format id and the collation, if store is going to "own"
> knowing
> the collation of a given column then I would expect something like:
>
> for each format id in row array
> dvd = datavaluefactory.getObject(format id, character_collator_type)
>
> note this means extra overhead for every object creation in the
> template.
>
> To me it seems unfortunate to pass in this info per column, when at
> least in 10.3 the current code it is one per database. I saw the
> direction as:
>
> o 10.3 only needs one collation per database so hide the info in the
> datafactory, basically there is one DEFAULT collation per database.
> Thus no need for second argument to datavaluefactory.getObject()
>
> o future release needs to have different collations per conglomerate,
> then at that time we can store a collator type per conglomerate - we
> have mechanism today to upgrade on the fly. If we want to support
> adding a collation to an existing database I would suggest continueing
> the DEFAULT collation concept with some magic number representing
> DEFAULT db collation in the datavaluefactory.getObject() call - which
> would mean use db wide default rather than specify specific one. For
> new databases we would not need default, we could at that time
> specify
> one per conglomerate.
> At this point we either change all the datavaluefactory.getObject()
> calls to have 2 args and support DEFAULT_VALUE as second argument, or
> maybe support both 1 and 2 arg calls - not sure.
>
> 0 future future release needs to have different collations per column,
> then at that time we can store a collator type per column - we
> continue to have mechanism to upgrade on fly as long as we can come up
> with a default value for old tables. Same issues as above.
>
>
>
> >
> > - setting the collation property remains in the data dictionary
> >
> > - basic database sets the locale for the DataValueFactory after
> it boots
> > it, using a new method on DVF
> > void setLocale(Locale locale);
> >
> > I think approaching the problem this way will lead to a cleaner
> solution
> > in the long term and be somewhat easier to implement.
> >
> > Thanks,
> > Dan.
> >
> >
> >
> >
> >
> >
>
>
Re: Collation implementation WAS Re: Should COLLATION attribute related code go in BasicDatabase?
Posted by Mamta Satoor <ms...@gmail.com>.
Mike, I am not sure if your question, about how in store DVD with correction
collation type is loaded, was answered or not. In other words, you had
question about following piece of pseudo code from Dan
if (dvd instanceof StringDataValue)
dvd = dvd.getValue(dvf.getCharacterCollator(type));
Let me attempt to answer it. It will help clear up things in my mind too and
make sure that I am understanding this correctly.
Currently, derby.impl.dtore.access.conglomerate.OpenConglomerateScratchSpacehas
get_row_for_export which first gets a class template row using
RowUtil.newClassInfoTemplate This method in RowUtil calls
Monitor.classFromIdentifier to get the InstanceGetter for each of the format
ids identified by store. Once
OpenConglomerateScratchSpace.get_row_for_export has the class template row,
it will call RowUtil.newRowFromClassInfoTemplate. This is the method, Dan is
proposing to modify, ie store should pass an additional array of int to
RowUtil.newRowFromClassInfoTemplate which will have the collation type
associated with the formatids of the template row.
RowUtil.newRowFromClassInfoTemplate will first get the DVD as it does today
using following
columns[column_index] =
(DataValueDescriptor) classinfo_template[column_index].getNewInstance();
In addition, it will need to do something like following
if (columns[column_index] instanceof StringDataValue)
dvd = columns[column_index].getValue(dvf.getCharacterCollator
(collationTypesForTemplateRows[column_index]));
Dan, let me know if I understood you right. This will help me answer your
question on the Derby wiki page
http://wiki.apache.org/db-derby/BuiltInLanguageBasedOrderingDERBY-1478 I
know that we don't need to get into the implementation code details in the
design phase, but I need to be able to picture this particular case in my
mind to understand where I am going.
thanks,
Mamta
On 3/15/07, Mike Matrigali <mi...@sbcglobal.net> wrote:
>
>
>
> Daniel John Debrunner wrote:
> > Mamta Satoor wrote:
> >
> ...
>
> >
> > - At recovery time the btree uses the collation type and the data value
> > factory to setup its template row array correctly. Something like
> > for each dvd in row array
> > if (dvd instanceof StringDataValue)
> > dvd = dvd.getValue(dvf.getCharacterCollator(type));
>
> Note that the store issue is not just a recovery time issue, templates
> are required during normal runtime. Creation of these templates used
> to show up (a long time ago) in performance analysis and work was done
> to optimize the performance. So I am interested in making these
> template creations as efficient as possible.
>
> Your proposal above does not look right to me - it could just be I don't
> understand where the psuedo code is. The code I expect in store would
> be something like below - letting the datafactory do whatever is right
> based on the format id and the collation, if store is going to "own"
> knowing
> the collation of a given column then I would expect something like:
>
> for each format id in row array
> dvd = datavaluefactory.getObject(format id, character_collator_type)
>
> note this means extra overhead for every object creation in the template.
>
> To me it seems unfortunate to pass in this info per column, when at
> least in 10.3 the current code it is one per database. I saw the
> direction as:
>
> o 10.3 only needs one collation per database so hide the info in the
> datafactory, basically there is one DEFAULT collation per database.
> Thus no need for second argument to datavaluefactory.getObject()
>
> o future release needs to have different collations per conglomerate,
> then at that time we can store a collator type per conglomerate - we
> have mechanism today to upgrade on the fly. If we want to support
> adding a collation to an existing database I would suggest continueing
> the DEFAULT collation concept with some magic number representing
> DEFAULT db collation in the datavaluefactory.getObject() call - which
> would mean use db wide default rather than specify specific one. For
> new databases we would not need default, we could at that time specify
> one per conglomerate.
> At this point we either change all the datavaluefactory.getObject()
> calls to have 2 args and support DEFAULT_VALUE as second argument, or
> maybe support both 1 and 2 arg calls - not sure.
>
> 0 future future release needs to have different collations per column,
> then at that time we can store a collator type per column - we
> continue to have mechanism to upgrade on fly as long as we can come up
> with a default value for old tables. Same issues as above.
>
>
>
> >
> > - setting the collation property remains in the data dictionary
> >
> > - basic database sets the locale for the DataValueFactory after it boots
> > it, using a new method on DVF
> > void setLocale(Locale locale);
> >
> > I think approaching the problem this way will lead to a cleaner solution
> > in the long term and be somewhat easier to implement.
> >
> > Thanks,
> > Dan.
> >
> >
> >
> >
> >
> >
>
>
Re: Collation implementation WAS Re: Should COLLATION attribute related
code go in BasicDatabase?
Posted by Mike Matrigali <mi...@sbcglobal.net>.
Daniel John Debrunner wrote:
> Mamta Satoor wrote:
>
...
>
> - At recovery time the btree uses the collation type and the data value
> factory to setup its template row array correctly. Something like
> for each dvd in row array
> if (dvd instanceof StringDataValue)
> dvd = dvd.getValue(dvf.getCharacterCollator(type));
Note that the store issue is not just a recovery time issue, templates
are required during normal runtime. Creation of these templates used
to show up (a long time ago) in performance analysis and work was done
to optimize the performance. So I am interested in making these
template creations as efficient as possible.
Your proposal above does not look right to me - it could just be I don't
understand where the psuedo code is. The code I expect in store would
be something like below - letting the datafactory do whatever is right
based on the format id and the collation, if store is going to "own" knowing
the collation of a given column then I would expect something like:
for each format id in row array
dvd = datavaluefactory.getObject(format id, character_collator_type)
note this means extra overhead for every object creation in the template.
To me it seems unfortunate to pass in this info per column, when at
least in 10.3 the current code it is one per database. I saw the
direction as:
o 10.3 only needs one collation per database so hide the info in the
datafactory, basically there is one DEFAULT collation per database.
Thus no need for second argument to datavaluefactory.getObject()
o future release needs to have different collations per conglomerate,
then at that time we can store a collator type per conglomerate - we
have mechanism today to upgrade on the fly. If we want to support
adding a collation to an existing database I would suggest continueing
the DEFAULT collation concept with some magic number representing
DEFAULT db collation in the datavaluefactory.getObject() call - which
would mean use db wide default rather than specify specific one. For
new databases we would not need default, we could at that time specify
one per conglomerate.
At this point we either change all the datavaluefactory.getObject()
calls to have 2 args and support DEFAULT_VALUE as second argument, or
maybe support both 1 and 2 arg calls - not sure.
0 future future release needs to have different collations per column,
then at that time we can store a collator type per column - we
continue to have mechanism to upgrade on fly as long as we can come up
with a default value for old tables. Same issues as above.
>
> - setting the collation property remains in the data dictionary
>
> - basic database sets the locale for the DataValueFactory after it boots
> it, using a new method on DVF
> void setLocale(Locale locale);
>
> I think approaching the problem this way will lead to a cleaner solution
> in the long term and be somewhat easier to implement.
>
> Thanks,
> Dan.
>
>
>
>
>
>
Re: Collation implementation WAS Re: Should COLLATION attribute related
code go in BasicDatabase?
Posted by Mike Matrigali <mi...@sbcglobal.net>.
Daniel John Debrunner wrote:
> - The collation type (the integer) is written into the meta-data for an
> index just as ascending/descending is today (including the btree control
> row, thus making the information available for recovery). Collation type
> applies to all character columns in the index.
With this proposal is there new language level metadata, ie. a
syscolumns upgrade?
Re: Collation implementation WAS Re: Should COLLATION attribute related
code go in BasicDatabase?
Posted by Mike Matrigali <mi...@sbcglobal.net>.
Mike Matrigali wrote:
>
>
> Daniel John Debrunner wrote:
> ...
>
>>
>> My second concern is that many places get characters and the change
>> must ensure they get the correct datatype, apart from potentially
>> being a lot of work, the chance of missing some or picking the wrong
>> character types seems high.
>
> What is the plan for system catalogs? I just realized that if system
> catalog char's are going to be non-collation based then I guess 10.3
> would really already be supporting 2 different collations per database.
>
>
I think this is why I expected new type id's. I didn't expect the type
id's to represent a specific collation, just that it had a non-default
collation. Thus system catalogs would always have default collation.
So it seems like we need to choose:
1) system catalogs share locale based collation with rest of db
2) add new type ids as previously proposed
3) support per conglomerate collation
note that we need to support proper recovery of system catalogs so we
can't solve the problem though some magic runtime manipulation of system
catalog queries.
>
Re: Collation implementation WAS Re: Should COLLATION attribute related
code go in BasicDatabase?
Posted by Mike Matrigali <mi...@sbcglobal.net>.
Daniel John Debrunner wrote:
...
>
> My second concern is that many places get characters and the change must
> ensure they get the correct datatype, apart from potentially being a lot
> of work, the chance of missing some or picking the wrong character types
> seems high.
What is the plan for system catalogs? I just realized that if system
catalog char's are going to be non-collation based then I guess 10.3
would really already be supporting 2 different collations per database.
Re: Collation implementation WAS Re: Should COLLATION attribute related
code go in BasicDatabase?
Posted by Daniel John Debrunner <dj...@apache.org>.
Mamta Satoor wrote:
> Dan, what is CollateSQLChar in the following prototype code?
Typos :-)
Should be CollatorSQLChar as in
org.apache.derby.iapi.types.CollatorSQLChar
Sorry,
Dan.
Re: Collation implementation WAS Re: Should COLLATION attribute related code go in BasicDatabase?
Posted by Mamta Satoor <ms...@gmail.com>.
Dan, what is CollateSQLChar in the following prototype code?
Dan wrote:
> A method on StringDataValue
> StringDataValue getValue(RuleBasedCollator collator)
>
> For SQLChar:
> getValue(null) would return itself
> getValue(non-null) would return a new CollateSQLChar() with the
value of the SQLChar and the collator set.
>
> For CollatorSQLChar
> getValue(null) would return a new SQLChar() with the value of
the CollateSQLChar
> getValue(non-null) would return itself with the collator set
correctly.
Mamta
On 3/15/07, Daniel John Debrunner <dj...@apache.org> wrote:
>
> Mamta Satoor wrote:
> > In the following snippet of Dan's comments, what does it mean to return
> > SQLChar with the value of CollateSQLChar? I am definitely not clear on
> > the new getValue method on StringDataValue and how it will function for
> > SQLChar and CollatorSQLChar. Dan, can you please elaborate more on it?
> >
> > For CollatorSQLChar
> > getValue(null) would return a new SQLChar() with the value of
> > the CollateSQLChar
>
> Example code for CollatorSQLChar
>
> StringDataValue getValue(RuleBasedCollator collation)
> {
> if (collation == null)
> {
> // Just need UCS_BASIC collation
> SQLChar s = new SQLChar();
> s.setValue(this);
> return s;
> }
>
> setCollator(collation);
> return this;
> }
>
> I'm assuming that this call is made once when an Activation is
> initialized and not for every compared value.
>
> Dan.
>
>
Re: Collation implementation WAS Re: Should COLLATION attribute related code go in BasicDatabase?
Posted by Mamta Satoor <ms...@gmail.com>.
Great. That's exactly what I was looking for, ie to make sure that I
understand correctly that it won't get called with today's design.
thanks again,
Dan
On 3/21/07, Daniel John Debrunner <dj...@apache.org> wrote:
>
> Mamta Satoor wrote:
> > I understand point 2. My question was an attempt to understand point 1,
> > ie why and when will we need to change the collate from TERRITORY_BASED
> > to UCS_BASIC? I know that we will need this support in future when we
> > will support the SQL's COLLATE clause. For instance, on a CAST, SQL spec
> > allows you to specify COLLATE clause. In a case like that, when we do
> > start supporting COLLATE clause, we might need to go from
> > TERRITORY_BASED to UCS_BASIC. When you mention 1) in the mail below, is
> > that the use case you were thinking of this method in CollatorSQLChar?
> > Or is there already a need today with the current design, that we will
> > want to go from TERRITORY_BASED collation to UCS_BASIC collation?
>
> Probably only when having the collate clause.
>
> Not overriding the method would be incorrect, overriding it with the
> correct implementation is good (though it may not be called yet),
> overriding it with a method that does a SanityManager.THROWASSERT() is
> also ok if it's not expected to be called.
>
> Dan.
>
>
Re: Collation implementation WAS Re: Should COLLATION attribute related
code go in BasicDatabase?
Posted by Daniel John Debrunner <dj...@apache.org>.
Mamta Satoor wrote:
> I understand point 2. My question was an attempt to understand point 1,
> ie why and when will we need to change the collate from TERRITORY_BASED
> to UCS_BASIC? I know that we will need this support in future when we
> will support the SQL's COLLATE clause. For instance, on a CAST, SQL spec
> allows you to specify COLLATE clause. In a case like that, when we do
> start supporting COLLATE clause, we might need to go from
> TERRITORY_BASED to UCS_BASIC. When you mention 1) in the mail below, is
> that the use case you were thinking of this method in CollatorSQLChar?
> Or is there already a need today with the current design, that we will
> want to go from TERRITORY_BASED collation to UCS_BASIC collation?
Probably only when having the collate clause.
Not overriding the method would be incorrect, overriding it with the
correct implementation is good (though it may not be called yet),
overriding it with a method that does a SanityManager.THROWASSERT() is
also ok if it's not expected to be called.
Dan.
Re: Collation implementation WAS Re: Should COLLATION attribute related code go in BasicDatabase?
Posted by Mamta Satoor <ms...@gmail.com>.
I understand point 2. My question was an attempt to understand point 1, ie
why and when will we need to change the collate from TERRITORY_BASED to
UCS_BASIC? I know that we will need this support in future when we will
support the SQL's COLLATE clause. For instance, on a CAST, SQL spec allows
you to specify COLLATE clause. In a case like that, when we do start
supporting COLLATE clause, we might need to go from TERRITORY_BASED to
UCS_BASIC. When you mention 1) in the mail below, is that the use case you
were thinking of this method in CollatorSQLChar? Or is there already a need
today with the current design, that we will want to go from TERRITORY_BASED
collation to UCS_BASIC collation?
thanks,
Mamta
On 3/21/07, Daniel John Debrunner <dj...@apache.org> wrote:
>
> Mamta Satoor wrote:
> > Dan, why would we need to override the StringDataValue
> > getValue(RuleBasedCollator collation) method in CollatorSQLChar? I think
> > it will be sufficient to implement this method in SQLChar with following
> > pseudocode
> > StringDataValue getValue(RuleBasedCollator collation)
> > {
> > if (collation == null)
> > {
> > // Just need UCS_BASIC collation, so just return myself.
> > return this;
> > }
> >
> > CollatorSQLChar s = new CollatorSQLChar();
> > s.setValue(this);
> > s.setCollator(collation);
> > return s;
> > }
> >
> >
> > I see this method being called when store is trying to construct a
> > template row of DVDs based on the format ids and collation type that
> > store is aware of. Since the formatid for character types will always
> > correspond to SQLChar (the base class)(for simplicity, I am only talking
> > in terms of SQL type CHAR. Same logic applies for other SQL
> > character types) , the only thing that store might want is to use the
> > super class CollatorSQLChar as DVD if the collation type is
> > 1(TERRITORY_BASED). When do you see the need for Derby code wanting to
> > go from CollatorSQLChar to SQLChar?
>
> 1) When needing to collate using USC_BASIC.
>
> 2) If CollatorSQLChar does not override that getValue(RuleBasedCollator
> collation) then the class would not be honoring the api contract, which
> will eventually lead to bugs as other new code assumes the class is
> honoring the contract of the api.
>
> Dan.
>
>
>
>
Re: Collation implementation WAS Re: Should COLLATION attribute related
code go in BasicDatabase?
Posted by Daniel John Debrunner <dj...@apache.org>.
Mamta Satoor wrote:
> Dan, why would we need to override the StringDataValue
> getValue(RuleBasedCollator collation) method in CollatorSQLChar? I think
> it will be sufficient to implement this method in SQLChar with following
> pseudocode
> StringDataValue getValue(RuleBasedCollator collation)
> {
> if (collation == null)
> {
> // Just need UCS_BASIC collation, so just return myself.
> return this;
> }
>
> CollatorSQLChar s = new CollatorSQLChar();
> s.setValue(this);
> s.setCollator(collation);
> return s;
> }
>
>
> I see this method being called when store is trying to construct a
> template row of DVDs based on the format ids and collation type that
> store is aware of. Since the formatid for character types will always
> correspond to SQLChar (the base class)(for simplicity, I am only talking
> in terms of SQL type CHAR. Same logic applies for other SQL
> character types) , the only thing that store might want is to use the
> super class CollatorSQLChar as DVD if the collation type is
> 1(TERRITORY_BASED). When do you see the need for Derby code wanting to
> go from CollatorSQLChar to SQLChar?
1) When needing to collate using USC_BASIC.
2) If CollatorSQLChar does not override that getValue(RuleBasedCollator
collation) then the class would not be honoring the api contract, which
will eventually lead to bugs as other new code assumes the class is
honoring the contract of the api.
Dan.
Re: Collation implementation WAS Re: Should COLLATION attribute related code go in BasicDatabase?
Posted by Mamta Satoor <ms...@gmail.com>.
Dan, why would we need to override the StringDataValue
getValue(RuleBasedCollator collation) method in CollatorSQLChar? I think it
will be sufficient to implement this method in SQLChar with following
pseudocode
StringDataValue getValue(RuleBasedCollator collation)
{
if (collation == null)
{
// Just need UCS_BASIC collation, so just return myself.
return this;
}
CollatorSQLChar s = new CollatorSQLChar();
s.setValue(this);
s.setCollator(collation);
return s;
}
I see this method being called when store is trying to construct a template
row of DVDs based on the format ids and collation type that store is aware
of. Since the formatid for character types will always correspond to SQLChar
(the base class)(for simplicity, I am only talking in terms of SQL type
CHAR. Same logic applies for other SQL character types) , the only thing
that store might want is to use the super class CollatorSQLChar as DVD if
the collation type is 1(TERRITORY_BASED). When do you see the need for Derby
code wanting to go from CollatorSQLChar to SQLChar?
thanks,
Mamta
On 3/15/07, Daniel John Debrunner <dj...@apache.org> wrote:
>
> Mamta Satoor wrote:
> > In the following snippet of Dan's comments, what does it mean to return
> > SQLChar with the value of CollateSQLChar? I am definitely not clear on
> > the new getValue method on StringDataValue and how it will function for
> > SQLChar and CollatorSQLChar. Dan, can you please elaborate more on it?
> >
> > For CollatorSQLChar
> > getValue(null) would return a new SQLChar() with the value of
> > the CollateSQLChar
>
> Example code for CollatorSQLChar
>
> StringDataValue getValue(RuleBasedCollator collation)
> {
> if (collation == null)
> {
> // Just need UCS_BASIC collation
> SQLChar s = new SQLChar();
> s.setValue(this);
> return s;
> }
>
> setCollator(collation);
> return this;
> }
>
> I'm assuming that this call is made once when an Activation is
> initialized and not for every compared value.
>
> Dan.
>
>
Re: Collation implementation WAS Re: Should COLLATION attribute related
code go in BasicDatabase?
Posted by Daniel John Debrunner <dj...@apache.org>.
Mamta Satoor wrote:
> In the following snippet of Dan's comments, what does it mean to return
> SQLChar with the value of CollateSQLChar? I am definitely not clear on
> the new getValue method on StringDataValue and how it will function for
> SQLChar and CollatorSQLChar. Dan, can you please elaborate more on it?
>
> For CollatorSQLChar
> getValue(null) would return a new SQLChar() with the value of
> the CollateSQLChar
Example code for CollatorSQLChar
StringDataValue getValue(RuleBasedCollator collation)
{
if (collation == null)
{
// Just need UCS_BASIC collation
SQLChar s = new SQLChar();
s.setValue(this);
return s;
}
setCollator(collation);
return this;
}
I'm assuming that this call is made once when an Activation is
initialized and not for every compared value.
Dan.
Re: Collation implementation WAS Re: Should COLLATION attribute related code go in BasicDatabase?
Posted by Mamta Satoor <ms...@gmail.com>.
In the following snippet of Dan's comments, what does it mean to return
SQLChar with the value of CollateSQLChar? I am definitely not clear on the
new getValue method on StringDataValue and how it will function for SQLChar
and CollatorSQLChar. Dan, can you please elaborate more on it?
For CollatorSQLChar
getValue(null) would return a new SQLChar() with the value of the
CollateSQLChar
thanks,
Mamta
On 3/15/07, Mike Matrigali <mi...@sbcglobal.net> wrote:
>
> I think I am missing/not understanding your direction.
>
> are there still 4 new types?
>
> /mikem
>
> Daniel John Debrunner wrote:
> > Mamta Satoor wrote:
> >
> >> Ok, so I spent some time trying to move COLLATION attribute code from
> >> DataDictionaryImpl.boot to DataValueFactoryImpl.boot. I thought I
> >> could simply put following piece of code in DataValueFactoryImpl.boot
> >> method and the Property.COLLATION will get saved in the properties
> >> conglomerate.
> >
> >
> > I think some of this goes back to the intended implementation.
> >
> > The intended implementation seems to be that there will be variants of
> > the four character datatypes with locale based collation. This is four
> > new (internal) datatypes in Derby that share most code with the existing
> > CHAR, VARCHAR, LONG VARCHHAR and CLOB types.
> >
> > I'm not sure this is the correct approach.
> >
> > My first thought is that this doesn't scale and doesn't seem like an OO
> > solution. To think ahead this means any addition collation style will
> > also add four new datatypes, which means there could easily be sixteen
> > or more datatypes to represent the characters. Each datatype will come
> > with some code cost, classes and/or methods per type.
> >
> > My second concern is that many places get characters and the change must
> > ensure they get the correct datatype, apart from potentially being a lot
> > of work, the chance of missing some or picking the wrong character types
> > seems high.
> >
> > What is really required is 'character type + collation'. I've been
> > thinking that looking at the problem in this way may make it more
> > manageable and easier to contain, with the main idea being only worry
> > about collation type when actually performing a collation. So some
> > initial ideas:
> >
> > - collation is a attribute of DataTypeDescriptor, not valid for non
> > character types, 0 for UCS_BASIC, 1 for UNICODE etc.
> > int getCollationType();
> >
> > - A method on DataValueFactory, returns null if type is UCS_BASIC
> > RuleBasedCollator getCharacterCollator(int type)
> >
> > - A method on StringDataValue
> > StringDataValue getValue(RuleBasedCollator collator)
> >
> > For SQLChar:
> > getValue(null) would return itself
> > getValue(non-null) would return a new CollateSQLChar() with
> > the value of the SQLChar and the collator set.
> >
> > For CollatorSQLChar
> > getValue(null) would return a new SQLChar() with the value of
> > the CollateSQLChar
> > getValue(non-null) would return itself with the collator set
> > correctly.
> >
> > - The collation type (the integer) is written into the meta-data for an
> > index just as ascending/descending is today (including the btree control
> > row, thus making the information available for recovery). Collation type
> > applies to all character columns in the index.
> >
> > - At SQL collation time, the code generation sets up the various types
> > correctly using the new methods.
> >
> > - At recovery time the btree uses the collation type and the data value
> > factory to setup its template row array correctly. Something like
> > for each dvd in row array
> > if (dvd instanceof StringDataValue)
> > dvd = dvd.getValue(dvf.getCharacterCollator(type));
>
>
> >
> > - setting the collation property remains in the data dictionary
> >
> > - basic database sets the locale for the DataValueFactory after it boots
> > it, using a new method on DVF
> > void setLocale(Locale locale);
> >
> > I think approaching the problem this way will lead to a cleaner solution
> > in the long term and be somewhat easier to implement.
> >
> > Thanks,
> > Dan.
> >
> >
> >
> >
> >
> >
>
>
Re: Collation implementation WAS Re: Should COLLATION attribute related
code go in BasicDatabase?
Posted by Mike Matrigali <mi...@sbcglobal.net>.
Daniel John Debrunner wrote:
> Mamta Satoor wrote:
>
>> Dan, I am responding to this without thinking about a whole lot but
>> wanted to put it out. With this scheme of putting collation inside the
>> existing character type, are we going to impact the performance of
>> Derby's default collation which is UCS_BASIC? The goal from the
>> beginning has been to leave current SQLChar implementation as unaware
>> of the new collation requirement as possible. It's possible that your
>> suggestion does take that into account but I thought I would ask the
>> question if this approach is going to impact the performance of
>> existing Pre 10.3 upgraded to 10.3 or new 10.3 databases created with
>> default collation?
>
>
> Not sure what you mean by "putting the collation inside the existing
> character type", but I think there will be no performance impact on
> SQLChar, I'm assuming all the setup is done when the activation is
> initialized. It's just flipping which runtime class does the comparisons.
>
Again I think both mamta and I did not understand that your proposal
still contained 4 new classes which will extend the 4 basic char classes
and allow the flipping at runtime.
> Dan.
>
>
>
Re: Collation implementation WAS Re: Should COLLATION attribute related
code go in BasicDatabase?
Posted by Daniel John Debrunner <dj...@apache.org>.
Mamta Satoor wrote:
> Dan, I am responding to this without thinking about a whole lot but
> wanted to put it out. With this scheme of putting collation inside the
> existing character type, are we going to impact the performance of
> Derby's default collation which is UCS_BASIC? The goal from the
> beginning has been to leave current SQLChar implementation as unaware of
> the new collation requirement as possible. It's possible that your
> suggestion does take that into account but I thought I would ask the
> question if this approach is going to impact the performance of existing
> Pre 10.3 upgraded to 10.3 or new 10.3 databases created with default
> collation?
Not sure what you mean by "putting the collation inside the existing
character type", but I think there will be no performance impact on
SQLChar, I'm assuming all the setup is done when the activation is
initialized. It's just flipping which runtime class does the comparisons.
Dan.
Re: Collation implementation WAS Re: Should COLLATION attribute related code go in BasicDatabase?
Posted by Mamta Satoor <ms...@gmail.com>.
Dan, I am responding to this without thinking about a whole lot but wanted
to put it out. With this scheme of putting collation inside the existing
character type, are we going to impact the performance of Derby's default
collation which is UCS_BASIC? The goal from the beginning has been to leave
current SQLChar implementation as unaware of the new collation requirement
as possible. It's possible that your suggestion does take that into account
but I thought I would ask the question if this approach is going to impact
the performance of existing Pre 10.3 upgraded to 10.3 or new 10.3 databases
created with default collation?
thanks,
Mamta
On 3/15/07, Daniel John Debrunner <dj...@apache.org> wrote:
>
> Mike Matrigali wrote:
> > I think I am missing/not understanding your direction.
> >
> > are there still 4 new types?
>
> No, collation becomes an attribute of the existing character types just
> like length and nullability are.
>
> Dan.
>
>
Re: Collation implementation WAS Re: Should COLLATION attribute related
code go in BasicDatabase?
Posted by Mike Matrigali <mi...@sbcglobal.net>.
Daniel John Debrunner wrote:
> Mike Matrigali wrote:
>
>>
>>
>> Mike Matrigali wrote:
>>
>>>
>>>
>>> Daniel John Debrunner wrote:
>>>
>>>> Mike Matrigali wrote:
>>>>
>>>>> I think I am missing/not understanding your direction.
>>>>>
>>>>> are there still 4 new types?
>>>>
>>>>
>>>>
>>>>
>>>> No, collation becomes an attribute of the existing character types
>>>> just like length and nullability are.
>>
>> What is CollatorSQLChar in your proposal then?
>
>
> Same as in Mamta's current code.
>
> CollatorSQLChar is a DataValueDescriptor, these are holders for values
> of a type, they are not a type themselves. I think that's where the
> confusion is coming in.
>
> A type in Derby is composed of much more. The type definition of a
> column is described by a DataTypeDescriptor, it is this class that would
> hold extra information (an int) to describe the collation type. Also
> some changes for classes involved in type creation at compile time will
> be needed, CharTypeCompiler at least.
>
> A writeup of the roles of the type classes is in the package.html for
> the types package.
>
> http://db.apache.org/derby/javadoc/engine/org/apache/derby/iapi/types/package-summary.html#package_description
>
>
> So there would be four new classes that implement DataValueDescriptor,
> for the Collator based collation of the four existing character types,
> as Mamta has implicitly proposed. But there would not be four new
> internal types and all the overhead it entails.
Thanks, this is what I was missing (I was using type when I meant
class). Overhead of collation will be avoided in the default by at
compile time getting the code to the right CLASS. Current db's will
be directed to SQLChar which will not need know anything about
collations, and collation created db's will get CollatorSQLChar instead
that will override as appropriate.
This seems reasonable to me. As I laid out in a previous message I
still think it appropriate in 10.3 to assume a single Collator for the
database and store it somewhere available at boot time before store
boots, and just let the datafactory somehow have it rather than make
store pass it in on every template object create. I believe if someone
has a future itch to allow for more than one collator per db there is
existing support to allow for the upgrade.
>
> Dan.
>
>
>
Re: Collation implementation WAS Re: Should COLLATION attribute related
code go in BasicDatabase?
Posted by Daniel John Debrunner <dj...@apache.org>.
Mike Matrigali wrote:
>
>
> Mike Matrigali wrote:
>>
>>
>> Daniel John Debrunner wrote:
>>
>>> Mike Matrigali wrote:
>>>
>>>> I think I am missing/not understanding your direction.
>>>>
>>>> are there still 4 new types?
>>>
>>>
>>>
>>> No, collation becomes an attribute of the existing character types
>>> just like length and nullability are.
> What is CollatorSQLChar in your proposal then?
Same as in Mamta's current code.
CollatorSQLChar is a DataValueDescriptor, these are holders for values
of a type, they are not a type themselves. I think that's where the
confusion is coming in.
A type in Derby is composed of much more. The type definition of a
column is described by a DataTypeDescriptor, it is this class that would
hold extra information (an int) to describe the collation type. Also
some changes for classes involved in type creation at compile time will
be needed, CharTypeCompiler at least.
A writeup of the roles of the type classes is in the package.html for
the types package.
http://db.apache.org/derby/javadoc/engine/org/apache/derby/iapi/types/package-summary.html#package_description
So there would be four new classes that implement DataValueDescriptor,
for the Collator based collation of the four existing character types,
as Mamta has implicitly proposed. But there would not be four new
internal types and all the overhead it entails.
Dan.
Re: Collation implementation WAS Re: Should COLLATION attribute related
code go in BasicDatabase?
Posted by Mike Matrigali <mi...@sbcglobal.net>.
Mike Matrigali wrote:
>
>
> Daniel John Debrunner wrote:
>
>> Mike Matrigali wrote:
>>
>>> I think I am missing/not understanding your direction.
>>>
>>> are there still 4 new types?
>>
>>
>>
>> No, collation becomes an attribute of the existing character types
>> just like length and nullability are.
What is CollatorSQLChar in your proposal then?
>
>>
>> Dan.
>>
>>
>>
>
>
>
Re: Collation implementation WAS Re: Should COLLATION attribute related
code go in BasicDatabase?
Posted by Daniel John Debrunner <dj...@apache.org>.
Mike Matrigali wrote:
>
>
> Daniel John Debrunner wrote:
>> Mike Matrigali wrote:
>>
>>> I think I am missing/not understanding your direction.
>>>
>>> are there still 4 new types?
>>
>>
>> No, collation becomes an attribute of the existing character types
>> just like length and nullability are.
> So this means that there will be extra overhead for non locale based
> collation. Is the elimination of this overhead at compile time handled
> some way differently in your proposal?
I'm not sure what overhead you are thinking of?
Dan.
Re: Collation implementation WAS Re: Should COLLATION attribute related
code go in BasicDatabase?
Posted by Mike Matrigali <mi...@sbcglobal.net>.
Daniel John Debrunner wrote:
> Mike Matrigali wrote:
>
>> I think I am missing/not understanding your direction.
>>
>> are there still 4 new types?
>
>
> No, collation becomes an attribute of the existing character types just
> like length and nullability are.
So this means that there will be extra overhead for non locale based
collation. Is the elimination of this overhead at compile time handled
some way differently in your proposal?
>
> Dan.
>
>
>
Re: Collation implementation WAS Re: Should COLLATION attribute related
code go in BasicDatabase?
Posted by Daniel John Debrunner <dj...@apache.org>.
Mike Matrigali wrote:
> I think I am missing/not understanding your direction.
>
> are there still 4 new types?
No, collation becomes an attribute of the existing character types just
like length and nullability are.
Dan.
Re: Collation implementation WAS Re: Should COLLATION attribute related
code go in BasicDatabase?
Posted by Mike Matrigali <mi...@sbcglobal.net>.
I think I am missing/not understanding your direction.
are there still 4 new types?
/mikem
Daniel John Debrunner wrote:
> Mamta Satoor wrote:
>
>> Ok, so I spent some time trying to move COLLATION attribute code from
>> DataDictionaryImpl.boot to DataValueFactoryImpl.boot. I thought I
>> could simply put following piece of code in DataValueFactoryImpl.boot
>> method and the Property.COLLATION will get saved in the properties
>> conglomerate.
>
>
> I think some of this goes back to the intended implementation.
>
> The intended implementation seems to be that there will be variants of
> the four character datatypes with locale based collation. This is four
> new (internal) datatypes in Derby that share most code with the existing
> CHAR, VARCHAR, LONG VARCHHAR and CLOB types.
>
> I'm not sure this is the correct approach.
>
> My first thought is that this doesn't scale and doesn't seem like an OO
> solution. To think ahead this means any addition collation style will
> also add four new datatypes, which means there could easily be sixteen
> or more datatypes to represent the characters. Each datatype will come
> with some code cost, classes and/or methods per type.
>
> My second concern is that many places get characters and the change must
> ensure they get the correct datatype, apart from potentially being a lot
> of work, the chance of missing some or picking the wrong character types
> seems high.
>
> What is really required is 'character type + collation'. I've been
> thinking that looking at the problem in this way may make it more
> manageable and easier to contain, with the main idea being only worry
> about collation type when actually performing a collation. So some
> initial ideas:
>
> - collation is a attribute of DataTypeDescriptor, not valid for non
> character types, 0 for UCS_BASIC, 1 for UNICODE etc.
> int getCollationType();
>
> - A method on DataValueFactory, returns null if type is UCS_BASIC
> RuleBasedCollator getCharacterCollator(int type)
>
> - A method on StringDataValue
> StringDataValue getValue(RuleBasedCollator collator)
>
> For SQLChar:
> getValue(null) would return itself
> getValue(non-null) would return a new CollateSQLChar() with
> the value of the SQLChar and the collator set.
>
> For CollatorSQLChar
> getValue(null) would return a new SQLChar() with the value of
> the CollateSQLChar
> getValue(non-null) would return itself with the collator set
> correctly.
>
> - The collation type (the integer) is written into the meta-data for an
> index just as ascending/descending is today (including the btree control
> row, thus making the information available for recovery). Collation type
> applies to all character columns in the index.
>
> - At SQL collation time, the code generation sets up the various types
> correctly using the new methods.
>
> - At recovery time the btree uses the collation type and the data value
> factory to setup its template row array correctly. Something like
> for each dvd in row array
> if (dvd instanceof StringDataValue)
> dvd = dvd.getValue(dvf.getCharacterCollator(type));
>
> - setting the collation property remains in the data dictionary
>
> - basic database sets the locale for the DataValueFactory after it boots
> it, using a new method on DVF
> void setLocale(Locale locale);
>
> I think approaching the problem this way will lead to a cleaner solution
> in the long term and be somewhat easier to implement.
>
> Thanks,
> Dan.
>
>
>
>
>
>
Re: Collation implementation WAS Re: Should COLLATION attribute related
code go in BasicDatabase?
Posted by Mike Matrigali <mi...@sbcglobal.net>.
Daniel John Debrunner wrote:
>
> What is really required is 'character type + collation'. I've been
> thinking that looking at the problem in this way may make it more
> manageable and easier to contain, with the main idea being only worry
> about collation type when actually performing a collation. So some
> initial ideas:
>
> - collation is a attribute of DataTypeDescriptor, not valid for non
> character types, 0 for UCS_BASIC, 1 for UNICODE etc.
> int getCollationType();
How do we map collations to int's? Is there some existing mechanism?
Re: Collation implementation WAS Re: Should COLLATION attribute related
code go in BasicDatabase?
Posted by Daniel John Debrunner <dj...@apache.org>.
Mamta Satoor wrote:
> Dan, I understand your concern about changes required in many places in
> the code to make sure that we get write instance of character datatype
> ie SQLChar vs CollatorSQLChar.
>
> But I don't understand your following comment
> "My first thought is that this doesn't scale and doesn't seem like an OO
> solution. To think ahead this means any addition collation style will
> also add four new datatypes, which means there could easily be sixteen
> or more datatypes to represent the characters. Each datatype will come
> with some code cost, classes and/or methods per type."
>
> For any additional collation styles, CollatorSQLChar will just need to
> be instantiated with proper RuleBasedCollator object for that collation
> style. We wouldn't need to create 4 new datatype for every new collation
> style introduced in Derby. Can you elaborate more on what you mean by
> your comment above.
A type within Derby is made of up of more that the class that represents
its value. A type compiler, data type object, methods in
DataValueFactory that return that type. All of these would have to setup
so that the new internal types for a specific collation can be handled.
I'm guessing at how you plan to implement this, but assume that a
case-insensitive collation is later added based on lower:
1) need new format identifiers, since current plan is to define
type+collation only by format identifier
2) thus two options at the CollatorSQLChar level
a) have a variable per instance that defines the format id
(additional runtime overhead)
b) new class that extends CollatorSQLChar and returns different
format id (additional footprint)
3) 1 leads to new methods in DataValueFactory to get a
DataValueDescriptor of the correct type, e.g. I assume you are planning
to add getLocaleChar(String val) etc., now need getLowerChar(String val)
etc.
4) More logic and/or classes in the compilation and type system to
handle these new types that I haven't thought in detail about.
Now some of the code could be shared, but this approach would make it so
that adding a new collation has to go create four new internal types and
ensure all code handles them correctly.
HTH,
Dan.
Re: Collation implementation WAS Re: Should COLLATION attribute related code go in BasicDatabase?
Posted by Mamta Satoor <ms...@gmail.com>.
Dan, I understand your concern about changes required in many places in the
code to make sure that we get write instance of character datatype ie
SQLChar vs CollatorSQLChar.
But I don't understand your following comment
"My first thought is that this doesn't scale and doesn't seem like an OO
solution. To think ahead this means any addition collation style will
also add four new datatypes, which means there could easily be sixteen
or more datatypes to represent the characters. Each datatype will come
with some code cost, classes and/or methods per type."
For any additional collation styles, CollatorSQLChar will just need to be
instantiated with proper RuleBasedCollator object for that collation style.
We wouldn't need to create 4 new datatype for every new collation style
introduced in Derby. Can you elaborate more on what you mean by your comment
above.
Mamta
On 3/15/07, Daniel John Debrunner <dj...@apache.org> wrote:
>
> Mamta Satoor wrote:
> > Ok, so I spent some time trying to move COLLATION attribute code from
> > DataDictionaryImpl.boot to DataValueFactoryImpl.boot. I thought I could
> > simply put following piece of code in DataValueFactoryImpl.boot method
> > and the Property.COLLATION will get saved in the properties
> > conglomerate.
>
> I think some of this goes back to the intended implementation.
>
> The intended implementation seems to be that there will be variants of
> the four character datatypes with locale based collation. This is four
> new (internal) datatypes in Derby that share most code with the existing
> CHAR, VARCHAR, LONG VARCHHAR and CLOB types.
>
> I'm not sure this is the correct approach.
>
> My first thought is that this doesn't scale and doesn't seem like an OO
> solution. To think ahead this means any addition collation style will
> also add four new datatypes, which means there could easily be sixteen
> or more datatypes to represent the characters. Each datatype will come
> with some code cost, classes and/or methods per type.
>
> My second concern is that many places get characters and the change must
> ensure they get the correct datatype, apart from potentially being a lot
> of work, the chance of missing some or picking the wrong character types
> seems high.
>
> What is really required is 'character type + collation'. I've been
> thinking that looking at the problem in this way may make it more
> manageable and easier to contain, with the main idea being only worry
> about collation type when actually performing a collation. So some
> initial ideas:
>
> - collation is a attribute of DataTypeDescriptor, not valid for non
> character types, 0 for UCS_BASIC, 1 for UNICODE etc.
> int getCollationType();
>
> - A method on DataValueFactory, returns null if type is UCS_BASIC
> RuleBasedCollator getCharacterCollator(int type)
>
> - A method on StringDataValue
> StringDataValue getValue(RuleBasedCollator collator)
>
> For SQLChar:
> getValue(null) would return itself
> getValue(non-null) would return a new CollateSQLChar() with
> the value of the SQLChar and the collator set.
>
> For CollatorSQLChar
> getValue(null) would return a new SQLChar() with the value
> of the CollateSQLChar
> getValue(non-null) would return itself with the collator set
> correctly.
>
> - The collation type (the integer) is written into the meta-data for an
> index just as ascending/descending is today (including the btree control
> row, thus making the information available for recovery). Collation type
> applies to all character columns in the index.
>
> - At SQL collation time, the code generation sets up the various types
> correctly using the new methods.
>
> - At recovery time the btree uses the collation type and the data value
> factory to setup its template row array correctly. Something like
> for each dvd in row array
> if (dvd instanceof StringDataValue)
> dvd = dvd.getValue(dvf.getCharacterCollator(type));
>
> - setting the collation property remains in the data dictionary
>
> - basic database sets the locale for the DataValueFactory after it boots
> it, using a new method on DVF
> void setLocale(Locale locale);
>
> I think approaching the problem this way will lead to a cleaner solution
> in the long term and be somewhat easier to implement.
>
> Thanks,
> Dan.
>
>
>
>
>