harmony-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Andrew Zhang" <zhanghuang...@gmail.com>
Subject Re: [classlib][sql] RI's bug of SerialBlob.position(byte[] pattern, long start)?
Date Wed, 13 Dec 2006 09:24:46 GMT
On 12/12/06, Oleg Khaschansky <oleg.v.khaschansky@gmail.com> wrote:
>
> I experimented a bit with this test. It looks like RI is doing following:
> if all the bytes from the pattern occured in the blob in the same
> sequence as in the pattern (possibly with any other bytes between
> them)


 Is it reasonable?
Should Harmony follow RI's behaviour? Or just find the exact byte array in
blob data?
Could  jdbc/db gurus give some suggestions? Thanks a lot in adavance!

then it returns <the position where it found the last byte from
> the pattern> - (<the pattern length> - 1).E.g. if the blob contents is
> 1,3,9,1,1,3,2,2,4,2,3,9,3,3 and the
> pattern is 1,2,3 then it takes the position of the third occurence of
> 3 (after 1 and 2 occured) and subtracts 2 (the pattern length - 1)
> from it. Then the return value is 9.
>
> This behavior of RI seems to be undocumented and illogical.
>
> On 12/12/06, Andrew Zhang <zhanghuangzhu@gmail.com> wrote:
> > Hi folks,
> >
> > I found that RI's behaviour of SerialBlob.postion(byte[] pattern, long
> > start) looks strange. Consider following code:
> >
> >     private void testPosition_BytePattern()
> >             throws SerialException, SQLException {
> >
> >         byte[] buf = { 1, 2, 3, 4, 5, 6, 7, 8 };
> >         SerialBlob blob = new SerialBlob(buf);
> >
> >
> >         byte[]  pattern = new byte[] { 2, 4 };
> >         long pos = blob.position(pattern, 1);
> >         // FIXME: RI's bug?
> >         assertEquals(-1, pos);
> >
> >     }
> >
> > It tries to find pattern "2,4" from blob with data "1,2,3,4,5,6,7,8". RI
> > returns 3 instead of -1. Spec says the method "returns the position in
> this
> > SerialBlob object where the given pattern of bytes begins, starting the
> > search at the specified position. "and "position numbering for the
> return
> > value starts at 1".
> >
> > Did I misunderstand the spec? Or it's a bug of RI? Thanks!
> > --
> > Best regards,
> > Andrew Zhang
> >
> >
>



-- 
Best regards,
Andrew Zhang

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message