Package org.apache.lucene.facet.taxonomy.writercache.cl2o

Examples of org.apache.lucene.facet.taxonomy.writercache.cl2o.CharBlockArray


*/

public class TestCharBlockArray extends LuceneTestCase {

  @Test public void testArray() throws Exception {
    CharBlockArray array = new CharBlockArray();
    StringBuilder builder = new StringBuilder();

    final int n = 100 * 1000;

    byte[] buffer = new byte[50];

    for (int i = 0; i < n; i++) {
      random.nextBytes(buffer);
      int size = 1 + random.nextInt(50);

      String s = new String(buffer, 0, size);
      array.append(s);
      builder.append(s);
    }

    for (int i = 0; i < n; i++) {
      random.nextBytes(buffer);
      int size = 1 + random.nextInt(50);

      String s = new String(buffer, 0, size);
      array.append((CharSequence)s);
      builder.append(s);
    }

    for (int i = 0; i < n; i++) {
      random.nextBytes(buffer);
      int size = 1 + random.nextInt(50);

      String s = new String(buffer, 0, size);
      for (int j = 0; j < s.length(); j++) {
        array.append(s.charAt(j));
      }
      builder.append(s);
    }

    assertEqualsInternal("GrowingCharArray<->StringBuilder mismatch.", builder, array);

    File f = new File("GrowingCharArrayTest.tmp");
    BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(f));
    array.flush(out);
    out.flush();
    out.close();

    BufferedInputStream in = new BufferedInputStream(new FileInputStream(f));
    array = CharBlockArray.open(in);
View Full Code Here

TOP

Related Classes of org.apache.lucene.facet.taxonomy.writercache.cl2o.CharBlockArray

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.