Debian Codegraph @

current/fileIO/ByteStreamWriter.java

raw symbols SCIP
1 package fileIO;
2
3 import java.io.File;
4 import java.io.IOException;
5 import java.io.OutputStream;
6 import java.util.HashMap;
7 import java.util.concurrent.ArrayBlockingQueue;
8
9 import assemble.Contig;
10 import dna.AminoAcid;
11 import dna.Data;
12 import kmer.AbstractKmerTable;
13 import shared.KillSwitch;
14 import shared.Shared;
15 import shared.Timer;
16 import shared.Tools;
17 import stream.Read;
18 import structures.ByteBuilder;
19 import ukmer.AbstractKmerTableU;
20
21
22
23 /**
24 * @author Brian Bushnell
25 * @date Oct 21, 2014
26 *
27 */
28 public class ByteStreamWriter extends Thread {
29
30 /*--------------------------------------------------------------*/
31 /*---------------- Initialization ----------------*/
32 /*--------------------------------------------------------------*/
33
34 public static void main(String[] args){
35 Timer t=new Timer();
36 final int alen=1000;
37 byte[] array=new byte[alen];
38 for(int i=0; i<array.length; i++){
39 array[i]=AminoAcid.numberToBase[i&3];
40 }
41 array[array.length-1]='\n';
42 long iters=Long.parseLong(args[1]);
43 String fname=args[0];
44 ByteStreamWriter bsw=new ByteStreamWriter(fname, true, false, true);
45 bsw.start();
46 for(long i=0; i<iters; i++){
47 bsw.print(array);
48 }
49 bsw.poisonAndWait();
50 t.stop();
51 System.err.println("MB/s: \t"+Tools.format("%.2f", ((alen*iters)/(t.elapsed/1000.0))));
52 System.err.println("Time: \t"+t);
53 }
54
55 /** @See primary constructor */
56 public ByteStreamWriter(String fname_, boolean overwrite_, boolean append_, boolean allowSubprocess_){
57 this(fname_, overwrite_, append_, allowSubprocess_, 0);
58 }
59
60 /** @See primary constructor */
61 public ByteStreamWriter(String fname_, boolean overwrite_, boolean append_, boolean allowSubprocess_, int format){
62 this(FileFormat.testOutput(fname_, FileFormat.TEXT, format, 0, allowSubprocess_, overwrite_, append_, false));
63 }
64
65 /**
66 * Create a ByteStreamWriter for this FileFormat.
67 * @param ff Contains information about the file name, output format, etc.
68 */
69 public ByteStreamWriter(FileFormat ff){
70 FASTQ=ff.fastq() || ff.text();
71 FASTA=ff.fasta();
72 BREAD=ff.bread();
73 SAM=ff.samOrBam();
74 BAM=ff.bam();
75 SITES=ff.sites();
76 INFO=ff.attachment();
77 OTHER=(!FASTQ && !FASTA && !BREAD && !SAM && !BAM && !SITES && !INFO);
78
79
80 fname=ff.name();
81 overwrite=ff.overwrite();
82 append=ff.append();
83 allowSubprocess=ff.allowSubprocess();
84 ordered=ff.ordered();
85 assert(!(overwrite&append));
86 assert(ff.canWrite()) : "File "+fname+" exists "+(new File(ff.name()).canWrite() ?
87 ("and overwrite="+overwrite+".\nPlease add the flag ow to overwrite the file.\n") :
88 "and is read-only.");
89 if(append && !(ff.raw() || ff.gzip())){throw new RuntimeException("Can't append to compressed files.");}
90
91 if(!BAM || !(Data.SAMTOOLS() /*|| Data.SAMBAMBA()*/) /*|| !Data.SH()*/){
92 outstream=ReadWrite.getOutputStream(fname, append, true, allowSubprocess);
93 }else{
94 if(Data.SAMTOOLS()){
95 outstream=ReadWrite.getOutputStreamFromProcess(fname, "samtools view -S -b -h - ", true, append, true, true);
96 }else{
97 outstream=ReadWrite.getOutputStreamFromProcess(fname, "sambamba view -S -f bam -h ", true, append, true, true); //Sambamba does not support stdin
98 }
99 }
100
101 queue=new ArrayBlockingQueue<ByteBuilder>(5);
102 if(ordered){
103 buffer=null;
104 map=new HashMap<Long, ByteBuilder>(MAX_CAPACITY);
105 }else{
106 buffer=new ByteBuilder(initialLen);
107 map=null;
108 }
109 }
110
111 /** Creates and starts a ByteStreamWriter unless fname is null */
112 public static ByteStreamWriter makeBSW(String fname, boolean ow, boolean append, boolean allowSub){
113 FileFormat ff=FileFormat.testOutput(fname, FileFormat.TEXT, 0, 0, allowSub, ow, append, false);
114 return makeBSW(ff);
115 }
116
117 /** Creates and starts a ByteStreamWriter unless ff is null */
118 public static ByteStreamWriter makeBSW(FileFormat ff){
119 if(ff==null){return null;}
120 ByteStreamWriter bsw=new ByteStreamWriter(ff);
121 bsw.start();
122 return bsw;
123 }
124
125 /*--------------------------------------------------------------*/
126 /*---------------- Primary Method ----------------*/
127 /*--------------------------------------------------------------*/
128
129
130 @Override
131 public void run() {
132 if(verbose){System.err.println("running");}
133 assert(open) : fname;
134
135 synchronized(this){
136 started=true;
137 this.notify();
138 }
139
140 if(verbose){System.err.println("waiting for jobs");}
141
142 processJobs();
143
144 if(verbose){System.err.println("null/poison job");}
145 // assert(false);
146 open=false;
147 ReadWrite.finishWriting(null, outstream, fname, allowSubprocess);
148 if(verbose){System.err.println("finish writing");}
149 synchronized(this){notifyAll();}
150 if(verbose){System.err.println("done");}
151 }
152
153 public void processJobs() {
154
155 ByteBuilder job=null;
156 while(job==null){
157 try {
158 job=queue.take();
159 // job.list=queue.take();
160 } catch (InterruptedException e) {
161 // TODO Auto-generated catch block
162 e.printStackTrace();
163 }
164 }
165
166 if(verbose){System.err.println("processing jobs");}
167 while(job!=null && job!=POISON2){
168 if(job.length()>0){
169 for(int i=0; job!=null && i<100; i++) {
170 try {
171 outstream.write(job.array, 0, job.length());
172 job=null;
173 } catch (IOException e) {
174 //Safest option is to exit here to avoid corrupt files.
175 if(true) {
176 System.err.println("Program is exiting due to a failed write.");
177 KillSwitch.exceptionKill(e);
178 }
179 e.printStackTrace();
180
181 System.err.println("Retrying...");
182 }
183 }
184 }
185
186 job=null;
187 while(job==null){
188 try {
189 job=queue.take();
190 } catch (InterruptedException e) {
191 // TODO Auto-generated catch block
192 e.printStackTrace();
193 }
194 }
195 }
196 }
197
198 /*--------------------------------------------------------------*/
199 /*---------------- Control and Helpers ----------------*/
200 /*--------------------------------------------------------------*/
201
202
203 @Override
204 public synchronized void start(){
205 super.start();
206 if(verbose){System.err.println(this.getState());}
207 synchronized(this){
208 while(!started){
209 try {
210 this.wait(20);
211 } catch (InterruptedException e) {
212 // TODO Auto-generated catch block
213 e.printStackTrace();
214 }
215 }
216 }
217 }
218
219
220 public synchronized void poison(){
221 //Don't allow thread to shut down before it has started
222 while(!started || this.getState()==Thread.State.NEW){
223 try {
224 this.wait(20);
225 } catch (InterruptedException e) {
226 // TODO Auto-generated catch block
227 e.printStackTrace();
228 }
229 }
230
231 if(!open){return;}
232
233 if(ordered){
234 addOrdered(POISON2, maxJobID+1);
235 }else{
236 if(buffer!=null){addJob(buffer);}
237 }
238 buffer=null;
239 // System.err.println("Poisoned!");
240 // assert(false);
241
242 // assert(false) : open+", "+this.getState()+", "+started;
243 open=false;
244 addJob(POISON2);
245 }
246
247 /**
248 * Wait for this object's thread to terminate.
249 * Should be poisoned first.
250 */
251 public void waitForFinish(){
252 while(this.getState()!=Thread.State.TERMINATED){
253 try {
254 this.join(1000);
255 } catch (InterruptedException e) {
256 e.printStackTrace();
257 }
258 }
259 }
260
261 /**
262 * Poison the thread, and wait for it to terminate.
263 * @return true if there was an error, false otherwise
264 */
265 public boolean poisonAndWait(){
266 poison();
267 waitForFinish();
268 return errorState;
269 }
270
271 //TODO Why is this synchronized?
272 public synchronized void addJob(ByteBuilder bb){
273 // System.err.println("Got job "+(j.list==null ? "null" : j.list.size()));
274
275 assert(started) : "Wait for start() to return before using the writer.";
276 // while(!started || this.getState()==Thread.State.NEW){
277 // try {
278 // this.wait(20);
279 // } catch (InterruptedException e) {
280 // // TODO Auto-generated catch block
281 // e.printStackTrace();
282 // }
283 // }
284
285 boolean success=false;
286 while(!success){
287 try {
288 queue.put(bb);
289 success=true;
290 } catch (InterruptedException e) {
291 // TODO Auto-generated catch block
292 e.printStackTrace();
293 assert(!queue.contains(bb)); //Hopefully it was not added.
294 }
295 }
296 }
297
298 public final void forceFlushBuffer(){
299 flushBuffer(true);
300 }
301
302 /** Called after every write to the buffer */
303 public final void flushBuffer(boolean force){
304 final int x=buffer.length();
305 if(x>=maxLen || (force && x>0)){
306 addJob(buffer);
307 buffer=new ByteBuilder(initialLen);
308 }
309 }
310
311
312 /*--------------------------------------------------------------*/
313 /*---------------- Ordering ----------------*/
314 /*--------------------------------------------------------------*/
315
316 public synchronized void add(ByteBuilder job, long jobID){
317
318 if(ordered){
319 int size=map.size();
320 // System.err.print(size+", ");
321 // System.err.println("A.Adding job "+jobID+"; next="+nextJobID+"; max="+maxJobID+", map="+map.keySet());
322 final boolean flag=(size>=HALF_LIMIT);
323 if(jobID>nextJobID && size>=ADD_LIMIT){
324 // if(printBufferNotification){
325 // System.err.println("Output buffer became full; key "+jobID+" waiting on "+nextJobID+".");
326 // printBufferNotification=false;
327 // }
328 while(jobID>nextJobID && size>=HALF_LIMIT){
329 try {
330 this.wait(2000);
331 } catch (InterruptedException e) {
332 e.printStackTrace();
333 }
334 size=map.size();
335 }
336 // if(printBufferNotification){
337 // System.err.println("Output buffer became clear for key "+jobID+"; next="+nextJobID+", size="+size);
338 // }
339 }
340 // System.err.println("B.Adding ordered job "+jobID+"; next="+nextJobID+"; max="+maxJobID);
341 addOrdered(job, jobID);
342 assert(jobID!=nextJobID);
343 if(flag && jobID<nextJobID){this.notifyAll();}
344 }else{
345 addDisordered(job);
346 }
347 }
348
349 private synchronized void addOrdered(ByteBuilder job, long jobID){
350 // System.err.println("addOrdered "+jobID+"; nextJobID="+nextJobID);
351 // assert(false);
352 assert(ordered);
353 assert(job!=null) : jobID;
354 assert(jobID>=nextJobID) : jobID+", "+nextJobID;
355 maxJobID=Tools.max(maxJobID, jobID);
356 ByteBuilder old=map.put(jobID, job);
357 assert(old==null);
358 // System.err.println("C.Adding ordered job "+jobID+"; next="+nextJobID+"; max="+maxJobID+", map="+map.keySet());
359
360 if(jobID==nextJobID){
361 do{
362 ByteBuilder value=map.remove(nextJobID);
363 // System.err.println("Removing and queueing "+nextJobID+": "+value.toString());
364 addJob(value);
365 nextJobID++;
366 // System.err.println("D.nextJobID="+nextJobID);
367 }while(map.containsKey(nextJobID));
368
369 if(map.isEmpty()){notifyAll();}
370 }else{
371 assert(!map.containsKey(nextJobID));
372 }
373 }
374
375 private synchronized void addDisordered(ByteBuilder job){
376 assert(!ordered);
377 assert(buffer==null || buffer.isEmpty());
378 addJob(job);
379 }
380
381 /*--------------------------------------------------------------*/
382 /*---------------- Print ----------------*/
383 /*--------------------------------------------------------------*/
384
385 /**
386 * Skip the buffers and print directly.
387 * Mainly for headers with ordered streams.
388 * @param s String to print.
389 */
390 public void forcePrint(String s){
391 forcePrint(s.getBytes());
392 }
393
394 /**
395 * Skip the buffers and print directly.
396 * Mainly for headers with ordered streams.
397 * @param b Data to print.
398 */
399 public void forcePrint(byte[] b){
400 try {
401 outstream.write(b, 0, b.length);
402 } catch (IOException e) {
403 // TODO Auto-generated catch block
404 e.printStackTrace();
405 }
406 }
407
408
409 public ByteBuilder getBuffer() {
410 assert(open);
411 assert(buffer!=null);
412 return buffer;
413 }
414
415 @Deprecated
416 /** Avoid using this if possible. */
417 public ByteStreamWriter print(CharSequence x){
418 if(verbose){System.err.println("Added line '"+x+"'");}
419 assert(open) : x;
420 buffer.append(x);
421 flushBuffer(false);
422 return this;
423 }
424
425 @Deprecated
426 /** Avoid using this if possible. */
427 public ByteStreamWriter print(StringBuilder x){
428 if(verbose){System.err.println("Added line '"+x+"'");}
429 assert(open) : x;
430 buffer.append(x);
431 flushBuffer(false);
432 return this;
433 }
434
435 /** Avoid using this if possible. */
436 public ByteStreamWriter print(String x){
437 if(verbose){System.err.println("Added line '"+x+"'");}
438 assert(open) : x;
439 buffer.append(x);
440 flushBuffer(false);
441 return this;
442 }
443
444 public ByteStreamWriter tab(){return print('\t');}
445 public ByteStreamWriter nl(){return print('\n');}
446
447 public ByteStreamWriter print(boolean x){
448 if(verbose){System.err.println("Added line '"+x+"'");}
449 assert(open) : x;
450 buffer.append(x);
451 flushBuffer(false);
452 return this;
453 }
454
455 public ByteStreamWriter print(int x){
456 if(verbose){System.err.println("Added line '"+(x)+"'");}
457 assert(open) : x;
458 buffer.append(x);
459 flushBuffer(false);
460 return this;
461 }
462
463 public ByteStreamWriter printtab(int x){
464 if(verbose){System.err.println("Added line '"+(x)+"'");}
465 assert(open) : x;
466 buffer.append(x);
467 buffer.append((byte)'\t');
468 flushBuffer(false);
469 return this;
470 }
471
472 public ByteStreamWriter print(long x){
473 if(verbose){System.err.println("Added line '"+(x)+"'");}
474 assert(open) : x;
475 buffer.append(x);
476 flushBuffer(false);
477 return this;
478 }
479
480 public ByteStreamWriter printtab(long x){
481 if(verbose){System.err.println("Added line '"+(x)+"'");}
482 assert(open) : x;
483 buffer.append(x);
484 buffer.append((byte)'\t');
485 flushBuffer(false);
486 return this;
487 }
488
489 // public ByteStreamWriter print(float x){
490 // if(verbose){System.err.println("Added line '"+(x)+"'");}
491 // assert(open) : x;
492 // buffer.appendSlow(x);
493 // flushBuffer(false);
494 // return this;
495 // }
496 //
497 // public ByteStreamWriter print(double x){
498 // if(verbose){System.err.println("Added line '"+(x)+"'");}
499 // assert(open) : x;
500 // buffer.appendSlow(x);
501 // flushBuffer(false);
502 // return this;
503 // }
504
505 public ByteStreamWriter print(float x, int decimals){
506 if(verbose){System.err.println("Added line '"+(x)+"'");}
507 assert(open) : x;
508 buffer.append(x, decimals);
509 flushBuffer(false);
510 return this;
511 }
512
513 public ByteStreamWriter printtab(float x, int decimals){
514 if(verbose){System.err.println("Added line '"+(x)+"'");}
515 assert(open) : x;
516 buffer.append(x, decimals);
517 buffer.append('\t');
518 flushBuffer(false);
519 return this;
520 }
521
522 public ByteStreamWriter print(double x, int decimals){
523 if(verbose){System.err.println("Added line '"+(x)+"'");}
524 assert(open) : x;
525 buffer.append(x, decimals);
526 flushBuffer(false);
527 return this;
528 }
529
530 public ByteStreamWriter printtab(double x, int decimals){
531 if(verbose){System.err.println("Added line '"+(x)+"'");}
532 assert(open) : x;
533 buffer.append(x, decimals);
534 buffer.append('\t');
535 flushBuffer(false);
536 return this;
537 }
538
539 public ByteStreamWriter print(byte x){
540 if(verbose){System.err.println("Added line '"+((char)x)+"'");}
541 assert(open) : ((char)x);
542 buffer.append(x);
543 flushBuffer(false);
544 return this;
545 }
546
547 public ByteStreamWriter print(char x){
548 if(verbose){System.err.println("Added line '"+(x)+"'");}
549 assert(open) : (x);
550 buffer.append(x);
551 flushBuffer(false);
552 return this;
553 }
554
555 public ByteStreamWriter print(byte[] x){
556 if(verbose){System.err.println("Added line '"+new String(x)+"'");}
557 assert(open) : new String(x);
558 buffer.append(x);
559 flushBuffer(false);
560 return this;
561 }
562
563 public ByteStreamWriter println(byte[] x){
564 if(verbose){System.err.println("Added line '"+new String(x)+"'");}
565 assert(open) : new String(x);
566 buffer.append(x).nl();
567 flushBuffer(false);
568 return this;
569 }
570
571 public ByteStreamWriter print(byte[] x, int len){
572 if(verbose){System.err.println("Added line '"+new String(x)+"'");}
573 assert(open) : new String(x);
574 buffer.append(x, len);
575 flushBuffer(false);
576 return this;
577 }
578
579 public ByteStreamWriter print(char[] x){
580 if(verbose){System.err.println("Added line '"+new String(x)+"'");}
581 assert(open) : new String(x);
582 buffer.append(x);
583 flushBuffer(false);
584 return this;
585 }
586
587 public ByteStreamWriter print(ByteBuilder x){
588 if(verbose){System.err.println("Added line '"+x+"'");}
589 assert(open) : x;
590 buffer.append(x);
591 flushBuffer(false);
592 return this;
593 }
594
595 public ByteStreamWriter print(ByteBuilder x, boolean destroy){
596 if(!destroy || buffer.length()>0){print(x);}
597 else{
598 if(verbose){System.err.println("Added line '"+x+"'");}
599 assert(open) : x;
600 addJob(x);
601 }
602 return this;
603 }
604
605 public ByteStreamWriter print(Read r){
606 assert(!OTHER);
607 ByteBuilder x=(FASTQ ? r.toFastq(buffer) : FASTA ? r.toFasta(FASTA_WRAP, buffer) : SAM ? r.toSam(buffer) :
608 SITES ? r.toSites(buffer) : INFO ? r.toInfo(buffer) : r.toText(true, buffer));
609 flushBuffer(false);
610 return this;
611 }
612
613 public ByteStreamWriter print(Contig c){
614 assert(!OTHER);
615 c.toFasta(FASTA_WRAP, buffer);
616 flushBuffer(false);
617 return this;
618 }
619
620 public ByteStreamWriter printKmer(long kmer, long count, int k){
621 AbstractKmerTable.toBytes(kmer, count, k, buffer);
622 flushBuffer(false);
623 return this;
624 }
625
626 public ByteStreamWriter printKmer(long kmer, int[] values, int k){
627 AbstractKmerTable.toBytes(kmer, values, k, buffer);
628 flushBuffer(false);
629 return this;
630 }
631
632 public ByteStreamWriter printKmer(long[] array, long count, int k){
633 AbstractKmerTableU.toBytes(array, count, k, buffer);
634 flushBuffer(false);
635 return this;
636 }
637
638 public ByteStreamWriter printKmer(long[] array, int[] values, int k){
639 AbstractKmerTableU.toBytes(array, values, k, buffer);
640 flushBuffer(false);
641 return this;
642 }
643
644 // public ByteStreamWriter printKmer(long kmer, long[] values, int k){
645 // kmer64.AbstractKmerTable64.toBytes(kmer, values, k, buffer);
646 // flushBuffer(false);
647 // return this;
648 // }
649
650
651 /*--------------------------------------------------------------*/
652 /*---------------- Println ----------------*/
653 /*--------------------------------------------------------------*/
654
655
656 public ByteStreamWriter println(){return print('\n');}
657 public ByteStreamWriter println(CharSequence x){print(x); return print('\n');}
658 public ByteStreamWriter println(String x){print(x); return print('\n');}
659 public ByteStreamWriter println(StringBuilder x){print(x); return print('\n');}
660 public ByteStreamWriter println(int x){print(x); return print('\n');}
661 public ByteStreamWriter println(long x){print(x); return print('\n');}
662 // public void println(float x){print(x); print('\n');}
663 // public void println(double x){print(x); print('\n');}
664 public ByteStreamWriter println(float x, int d){print(x, d); return print('\n');}
665 public ByteStreamWriter println(double x, int d){print(x, d); return print('\n');}
666 public ByteStreamWriter println(byte x){print(x); return print('\n');}
667 public ByteStreamWriter println(char x){print(x); return print('\n');}
668 // public ByteStreamWriter println(byte[] x){print(x); return print('\n');}
669 public ByteStreamWriter println(char[] x){print(x); return print('\n');}
670 public ByteStreamWriter println(ByteBuilder x){print(x); return print('\n');}
671 public ByteStreamWriter println(ByteBuilder x, boolean destroy){
672 if(destroy){return print(x.append('\n'));}else{print(x); return print('\n');}
673 }
674 public ByteStreamWriter printlnKmer(long kmer, int count, int k){printKmer(kmer, count, k); return print('\n');}
675 public ByteStreamWriter printlnKmer(long kmer, int[] values, int k){printKmer(kmer, values, k); return print('\n');}
676 public ByteStreamWriter printlnKmer(long[] array, int count, int k){printKmer(array, count, k); return print('\n');}
677 public ByteStreamWriter printlnKmer(long[] array, int[] values, int k){printKmer(array, values, k); return print('\n');}
678 public ByteStreamWriter println(Read r){print(r); return print('\n');}
679 public ByteStreamWriter println(Contig c){print(c); return print('\n');}
680
681 public ByteStreamWriter printlnKmer(long kmer, long count, int k){printKmer(kmer, count, k); return print('\n');}
682 // public ByteStreamWriter printlnKmer(long kmer, long[] values, int k){printKmer(kmer, values, k); return print('\n');}
683 public ByteStreamWriter printlnKmer(long[] array, long count, int k){printKmer(array, count, k); return print('\n');}
684 // public ByteStreamWriter printlnKmer(long[] array, long[] values, int k){printKmer(array, values, k); return print('\n');}
685
686
687
688 public ByteStreamWriter println(Read r, boolean paired){
689 println(r);
690 if(paired && r.mate!=null){println(r.mate);}
691 return this;
692 }
693
694 /*--------------------------------------------------------------*/
695 /*---------------- Inherited ----------------*/
696 /*--------------------------------------------------------------*/
697
698 @Override
699 public String toString(){
700 return "BSW for "+fname;
701 }
702
703 /*--------------------------------------------------------------*/
704 /*---------------- Fields ----------------*/
705 /*--------------------------------------------------------------*/
706
707 private ByteBuilder buffer;
708
709 public int initialLen=36000;
710 public int maxLen=32768;
711 public final boolean overwrite;
712 public final boolean append;
713 public final boolean allowSubprocess;
714 public final String fname;
715 public final boolean ordered;
716 private final OutputStream outstream;
717 private final ArrayBlockingQueue<ByteBuilder> queue;
718
719 /** For ordered output */
720 private final HashMap<Long, ByteBuilder> map;
721 private long nextJobID=0;
722 private long maxJobID=-1;
723
724 private boolean open=true;
725 private volatile boolean started=false;
726
727 /** TODO */
728 public boolean errorState=false;
729
730 /*--------------------------------------------------------------*/
731
732 private final boolean BAM;
733 private final boolean SAM;
734 private final boolean FASTQ;
735 private final boolean FASTA;
736 private final boolean BREAD;
737 private final boolean SITES;
738 private final boolean INFO;
739 private final boolean OTHER;
740
741 private final int FASTA_WRAP=Shared.FASTA_WRAP;
742
743 /*--------------------------------------------------------------*/
744
745 // private static final ByteBuilder POISON=new ByteBuilder("POISON_ByteStreamWriter");
746 private static final ByteBuilder POISON2=new ByteBuilder(1);
747
748 public static boolean verbose=false;
749 /** Number of lists held before the stream blocks */
750 private final int MAX_CAPACITY=256;
751 private final int ADD_LIMIT=MAX_CAPACITY/2;
752 private final int HALF_LIMIT=ADD_LIMIT/4;
753
754 }