I am looking for ideas on how I could pass my byte[] to Document.getBinaryValue(String name) in order to avoid allocation of new byte[] for each Field retrieved.
first idea I had was to add something like this in Document: public final byte[] getBinaryValue(String name, byte[] myBuffer) { for (int i=0; i < fields.size(); i++) { Fieldable field = (Fieldable)fields.get(i); if (field.name().equals(name) && (field.isBinary())){ if(field instanceof LazyField){ //HERE return ((LazyField)field).binaryValue(myBuffer); } return field.binaryValue(); return null; } in that case binaryValue(myBuffer) would optionally reallocate my buffer. Here I need length of actually written byte segment (which is available in LazyField). So this approach went wrong... with some tweaking, this could work fine, but is totally dirty imo as it delegates far too many Field internals to the Document class. Probably much better way would be to use tricks from TokenStream: Field Document.getField(String fieldName, Field myField); in this scenario, myField can be null and allocated or will be reused if not null ... (we have similar case in TokenStream now) Can this work somehow? or someone sees some better way to reduce byte[] allocations when fetching binary fields? This all assumes we have LUCENE-1219 in place, as we need length(ad offset) of byte[] ___________________________________________________________ Rise to the challenge for Sport Relief with Yahoo! For Good http://uk.promotions.yahoo.com/forgood/ --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]