1 21 package com.db4o.test; 22 23 import java.util.*; 24 25 public class PrimitiveArrayFileSize { 26 27 Object arr; 28 29 public void testSimpleLongInObject(){ 30 int call = 0; 31 PrimitiveArrayFileSize pafs = new PrimitiveArrayFileSize(); 32 for (int i = 0; i < 12; i++) { 33 pafs.arr = new long[100]; 34 Test.store(pafs); 35 checkFileSize(call++); 36 Test.commit(); 37 checkFileSize(call++); 38 } 39 } 40 41 public void testLongWrapperInObject(){ 42 int call = 0; 43 PrimitiveArrayFileSize pafs = new PrimitiveArrayFileSize(); 44 for (int i = 0; i < 12; i++) { 45 pafs.arr = longWrapperArray(); 46 Test.store(pafs); 47 checkFileSize(call++); 48 Test.commit(); 49 checkFileSize(call++); 50 } 51 } 52 53 public void testSimpleLongInHashMap(){ 54 HashMap hm = new HashMap(); 55 int call = 0; 56 for (int i = 0; i < 12; i++) { 57 long[] lll = new long[100]; 58 lll[0] = 99999; 59 hm.put("test", lll); 60 Test.store(hm); 61 checkFileSize(call++); 62 Test.commit(); 63 checkFileSize(call++); 64 } 65 } 66 67 public void testLongWrapperInHashMap(){ 68 HashMap hm = new HashMap(); 69 int call = 0; 70 for (int i = 0; i < 12; i++) { 71 hm.put("test", longWrapperArray()); 72 Test.store(hm); 73 checkFileSize(call++); 74 Test.commit(); 75 checkFileSize(call++); 76 } 77 } 78 79 80 private Long [] longWrapperArray(){ 81 Long [] larr = new Long [100]; 82 for (int j = 0; j < larr.length; j++) { 83 larr[j] = new Long (j); 84 } 85 return larr; 86 } 87 88 89 90 private void checkFileSize(int call){ 91 if(Test.canCheckFileSize()){ 92 int newFileLength = Test.fileLength(); 93 94 97 if(call == 6){ 98 jumps = 0; 100 fileLength = newFileLength; 101 }else if(call > 6){ 102 if(newFileLength > fileLength){ 103 if(jumps < 4){ 104 fileLength = newFileLength; 105 jumps ++; 106 }else{ 109 Test.error(); 111 } 112 } 113 } 114 } 115 } 116 117 private static transient int fileLength; 118 private static transient int jumps; 119 120 121 } 122 123 | Popular Tags |