@@ -82,12 +82,13 @@ private static void GenerateArgument(
8282 private static int []
8383 valueMajorTypes = {
8484 0 , 0 , 0 , 0 , 0 , 1 , 1 , 1 , 1 , 1 , 2 , 2 , 2 , 2 , 2 , 3 , 3 , 3 , 3 , 3 , 4 ,
85- 4 , 5 , 6 , 6 , 7 , 7 , 7 , 7 , 7 , 7 ,
85+ 4 , 4 , 4 , 4 , 4 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 6 , 6 , 7 , 7 , 7 , 7 , 7 , 7 ,
8686 };
8787
8888 private static int []
8989 valueMajorTypesHighDepth = {
90- 0 , 1 , 2 , 3 , 4 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 6 , 7 ,
90+ 0 , 1 , 2 , 3 , 4 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 ,
91+ 5 , 5 , 5 , 5 , 5 , 5 , 6 , 7 ,
9192 };
9293
9394 private static int [] valueMajorTypesHighLength = {
@@ -133,6 +134,31 @@ private static void GenerateUtf8(IRandomGenExtended ra, ByteWriter bs, int
133134 }
134135 }
135136
137+ private void GenerateSmall (IRandomGenExtended r , int depth , ByteWriter bs ) {
138+ int v = r .GetInt32 (100 );
139+ if (v < 25 ) {
140+ GenerateArgument (r , 0 , r .GetInt32 (100 ), bs );
141+ } else if (v < 35 ) {
142+ bs .Write (0x41 );
143+ bs .Write (0x20 );
144+ } else if (v < 45 ) {
145+ bs .Write (0x41 );
146+ bs .Write (0x20 );
147+ } else if (v < 50 ) {
148+ bs .Write (0x81 );
149+ this .GenerateSmall (r , depth + 1 , bs );
150+ } else if (v < 53 ) {
151+ bs .Write (0xa2 );
152+ bs .Write (0xf7 );
153+ bs .Write (0xf6 );
154+ this .GenerateSmall (r , depth + 1 , bs );
155+ bs .Write (0xf5 );
156+ } else if (v < 80 ) {
157+ bs .Write (r .GetInt32 (0x40 ));
158+ } else if (v < 100 ) {
159+ bs .Write (r .GetInt32 (0x60 ));
160+ }
161+ }
136162 private void Generate (IRandomGenExtended r , int depth , ByteWriter bs ) {
137163 int majorType = valueMajorTypes [r .GetInt32 (valueMajorTypes .length )];
138164 if (depth > 6 ) {
@@ -148,9 +174,10 @@ private void Generate(IRandomGenExtended r, int depth, ByteWriter bs) {
148174 if (r .GetInt32 (50 ) == 0 && depth < 2 ) {
149175 long v = (long )r .GetInt32 (100000 ) * r .GetInt32 (100000 );
150176 len = (int )(v / 100000 );
151- }
152- if (depth > 6 ) {
177+ } else if (depth > 6 ) {
153178 len = r .GetInt32 (100 ) == 0 ? 1 : 0 ;
179+ } else if (depth > 2 ) {
180+ len = r .GetInt32 (16 );
154181 }
155182 // TODO: Ensure key uniqueness
156183 if (r .GetInt32 (2 ) == 0 ) {
@@ -186,9 +213,13 @@ private void Generate(IRandomGenExtended r, int depth, ByteWriter bs) {
186213 if (r .GetInt32 (50 ) == 0 && depth < 2 ) {
187214 long v = (long )r .GetInt32 (1000 ) * r .GetInt32 (1000 );
188215 len = (int )(v / 1000 );
216+ } else if (depth > 6 ) {
217+ len = r .GetInt32 (100 ) == 0 ? 1 : 0 ;
218+ } else if (depth > 2 ) {
219+ len = r .GetInt32 (3 );
189220 }
190221 if (depth > 6 ) {
191- len = r .GetInt32 (100 ) < 50 ? 1 : 0 ;
222+ len = r .GetInt32 (100 ) < 50 ? 1 : ( r . GetInt32 ( 100 ) < 10 ? 2 : 0 ) ;
192223 }
193224 boolean indefiniteLength = r .GetInt32 (2 ) == 0 ;
194225 if (indefiniteLength ) {
@@ -197,7 +228,11 @@ private void Generate(IRandomGenExtended r, int depth, ByteWriter bs) {
197228 GenerateArgument (r , majorType , len , bs );
198229 }
199230 for (int i = 0 ; i < len ; ++i ) {
200- this .Generate (r , depth + 1 , bs );
231+ if (depth > 6 ) {
232+ this .GenerateSmall (r , depth + 1 , bs );
233+ } else {
234+ this .Generate (r , depth + 1 , bs );
235+ }
201236 if (majorType == 5 ) {
202237 this .Generate (r , depth + 1 , bs );
203238 }
0 commit comments