lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From eksdev <eks...@googlemail.com>
Subject Re: StoredField
Date Sun, 17 Mar 2013 13:58:59 GMT
sure, there is a way to make anything -> byte[] ;)

it looks like this byte[]->type conversion is done deep-down and this visitor user-api
gets already correct types  … 

Maybe an idea would be to delay byte[] -> type conversion to field access time, i do not
know what mines would be on the road to do it. 

use cases that require identity checks, or not locale specific sorting and co would benefit
from having row, serialised representations without type conversion…. anyhow, I could switch
overt to byte[] fields completely to do ii…

Thanks for responding!  




On Mar 17, 2013, at 2:24 PM, Shai Erera <serera@gmail.com> wrote:

> No no, not irony at all. I misunderstood the first time. You wrote "is there any way
to get ByteRef from a field originally stored as String?", so I understand the first thing
that came to mind :).
> 
> But I understand the question now -- you say that since the String field is written as
byte[] in the file, you want to read the byte[] as they are, without translating them to String.
right?
> 
> I don't know if it's possible. I'd try field.binaryValue(), though looking at the impl
it doesn't suggest it will do what you want.
> 
> Shai
> 
> 
> On Sun, Mar 17, 2013 at 3:02 PM, eksdev <eksdev@googlemail.com> wrote:
> Shai,  was that irony or I am missing something big time?
> 
> I would like to spare BytesRef -> String conversion, not to introduce another one
back to BytesRef
> 
> Simply, for sorting, you do not need to do this byte[]->String conversion, byte representation
of the String is perfectly sortable… 
> 
>  
> 
> On Mar 17, 2013, at 1:53 PM, Shai Erera <serera@gmail.com> wrote:
> 
>> You can do new BytesRef(d1.get("fieldName")).
>> 
>> Shai
>> 
>> 
>> On Sun, Mar 17, 2013 at 2:43 PM, eksdev <eksdev@googlemail.com> wrote:
>> is there any way to get ByteRef from a field originally stored as String?
>> 
>> I am playing with Sorter to implement  StoredDocSorter, analogous to NumericDocValuesSorter.
 But  realised I do not need ByteRef - > String conversion just to compare fields  (byte
order would be as good for sorting)
>> 
>> StoredDocument d1 = reader.document(docID1, fieldNamesSet);
>> String value1 = d1.get("fieldName")
>> String value1 = d1.getStringAsBytesValue("fieldName")// would love to have it
>> 
>> I need String type in other places, so indexing as byte[] would be too much hassle.
>> 
>> String is internally stored as byte[], no reason not to expose it for StoredField
(or any other type)? 
>> 
>> 
>> 
> 
> 


Mime
View raw message