Hi Monty, all,
>> What I am wondering about is how you think about defining (or maybe i
>> should say, overloading) operators for user-defined type. I mean, it
>> seems to me that specifying values of a certain type (and eventually,
>> storing them) is one side of the story. THe other is making stuff like
>> +, =, and function calls work. (and I guess as an extra, indexes on
>> custom types)
>
> Well... there's a couple of ways (ok, many, many) to go about this.
>
> If the parser treats binary operators simply as syntactic sugar around a
> defined call, then it's not that tough - you just have to define the
> right methods in your type. So, for instance, if we have:
>
> 2 + 2
>
> 2 and 2 are both ints, so in theory that could churn down into:
>
> int.add(2,2)
>
> Of course, then there's:
>
> 2 + "cow"
>
> Which, if you were crazy enough to think should work in some way, you'd
> need a
>
> int add(int, string)
>
> Or something in your type class. This gets in to many of the parts of
> operator overloading that people both love and hate.
I think this approach makes most sense to me: if you are game enough
to think of your own type, then be man or woman enough to specify how
to deal with operators. But that warps us into the next challenge: if
we have custom data types, then the operators/type-specfic functions
cannot all be part of the type definition, because you would always
need the ability to add new ones to accomodate custom types added by
others.
So, a custom type definition would probably always need definitions
(actually some implentation) of operators to make it work nice with at
least the built-in types.But then still there needs to be some way of
adding operators and functions that allow your custom type to work
nicely with some other custom type added in the future.
>
> On the other hand, if user defined types are merely specializations of
> basic types (int, real, string, bytes) then
>
> myinttype(12) + myinttype(12)
>
> Should (or would need to) work in as much as adding two ints would work.
This notion of types looks like it is close to what is known as
"domains" in standard sql. Essentially this is a synonym for an
existing data type, possibly with additional constraints on the
values.
I think this is a useful feature too, but maybe its best to treat it
as something entirely different. Domains can never add new
functionality, they serve 'merely' to allow you to add more (human
readable) semantics to database schemas. Very useful and certainly a
good feature. But it's IMO not the same as an entirely novel type.
> and (possibly more importantly)
>
> mystring("foo") == mystring("bar") would operate in the same way as
> comparing normal strings. Now, if you store some crazy-ass bytes into a
> string, then you just have to sort of be happy with normal string
> comparison of those bytes being how it's going to operate.
Yes. but for a genuine URL type, I would expect to see something like
'http://host/My%20Site' == 'http://host/My Site'
evaluate to true. (and 'http://host/My%20Site' === 'http://host/My
Site' to false)
>
> BTW - this is mostly me thinking out loud, rather than the result of
> much careful thought.
Me too - thinking out loud. But I think the domain vs type distinction
is a useful one. What do you think?
>
>> What do you think? Is this something you feel should be part of the
>> type definition? If not, how will values of custom types interact with
>> expressions that use them?
>
> That's the whole trick. Defining an IP Address type is all well and
> good, but what happens when you want to compare them.
>
> OTOH, if you can define both UDFs and UDTs, then you could certainly
> write a function to compare objects that you are expecting to be your IP
> Address type.
I am not worried about writing the functions (provided the interface
allows the implementor to discover the declared SQL type of the
arguments and the implied type of the return value - both sorely
missing in the MySQL UDF implementation)
What I am wondering (or worrying) about is that how to allow some
degree of automatic picking of the right functions/operator
overloadings.
I mean, an indexed URL should have some smarts to decide whether
another URL is equal to it and unless the URL 'type' is othing more
than an aliased string type, then there has to be some way to learn
the server to compare URLs to one another.
> Notice how I haven't mentioned specific implementation here. :)
Aye! I did ;)
kind regards,
Roland.
>
>> kind regards,
>>
>> Roland.
>>
>>>> On Oct 10, 2008, at 1:06 AM, Kazuho Oku wrote:
>>>>
>>>>> Hi,
>>>>>
>>>>> We run a web service called Pathtraq (http://pathtraq.com/) which is
>>>>> one of the largest web access stats service in Japan above MySQL, and
>>>>> it relies heavily on varbinary columns.
>>>>>
>>>>> We are storing tens of millions of URLs in compressed form (using a
>>>>> variant of static PPM compression algorithm) in a varbinary column.
>>>>> Since PPM compression preserves the order of original text, we can set
>>>>> indexes on varbinary columns to do a prefix search on URLs without
>>>>> uncompressing them, and it does save a lot of CPU cycles and I/O.
>>>>>
>>>>> You can find more information on the slides I used at YAPC::Asia Tokyo
>>>>> 2008 (around pp.17-27).
>>>>> http://www.slideshare.net/kazuho/yapcasia-2008-tokyo-pathtraq-building-a-computationcentric-web-service
>>>>>
>>>>>
>>>>>
>>>>> 2008/10/10 Brian Aker <[EMAIL PROTECTED]>:
>>>>>> Hi!
>>>>>>
>>>>>> On Oct 9, 2008, at 6:16 PM, Jim Starkey wrote:
>>>>>>
>>>>>>> problematic (a useful term, not strictly synonymous with bullshit).
>>>>>>
>>>>>> That is my take... but I am wondering why it was added. Maybe someone
>>>>>> on the
>>>>>> list has a use-case I've never thought of.
>>>>>>
>>>>>> To me binary objects are unstructured data which to me means "blob".
>>>>>>
>>>>>> Cheers,
>>>>>> -Bria
>>>>>>
>>>>>> --
>>>>>> _______________________________________________________
>>>>>> Brian "Krow" Aker, brian at tangent.org
>>>>>> Seattle, Washington
>>>>>> http://krow.net/ <-- Me
>>>>>> http://tangent.org/ <-- Software
>>>>>> _______________________________________________________
>>>>>> You can't grep a dead tree.
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> _______________________________________________
>>>>>> Mailing list: https://launchpad.net/~drizzle-discuss
>>>>>> Post to : [email protected]
>>>>>> Unsubscribe : https://launchpad.net/~drizzle-discuss
>>>>>> More help : https://help.launchpad.net/ListHelp
>>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> Kazuho Oku
>>>>>
>>>>> _______________________________________________
>>>>> Mailing list: https://launchpad.net/~drizzle-discuss
>>>>> Post to : [email protected]
>>>>> Unsubscribe : https://launchpad.net/~drizzle-discuss
>>>>> More help : https://help.launchpad.net/ListHelp
>>>> --
>>>> _______________________________________________________
>>>> Brian "Krow" Aker, brian at tangent.org
>>>> Seattle, Washington
>>>> http://krow.net/ <-- Me
>>>> http://tangent.org/ <-- Software
>>>> _______________________________________________________
>>>> You can't grep a dead tree.
>>>>
>>>>
>>>>
>>>>
>>>> _______________________________________________
>>>> Mailing list: https://launchpad.net/~drizzle-discuss
>>>> Post to : [email protected]
>>>> Unsubscribe : https://launchpad.net/~drizzle-discuss
>>>> More help : https://help.launchpad.net/ListHelp
>>>>
>>>
>>> _______________________________________________
>>> Mailing list: https://launchpad.net/~drizzle-discuss
>>> Post to : [email protected]
>>> Unsubscribe : https://launchpad.net/~drizzle-discuss
>>> More help : https://help.launchpad.net/ListHelp
>>>
>>
>>
>>
>
>
--
Roland Bouman
http://rpbouman.blogspot.com/
_______________________________________________
Mailing list: https://launchpad.net/~drizzle-discuss
Post to : [email protected]
Unsubscribe : https://launchpad.net/~drizzle-discuss
More help : https://help.launchpad.net/ListHelp