Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -837,7 +837,7 @@ $I }
$I long size${nv} = in.readMapStart();
$I $t m${nv} = ${var}; // Need fresh name due to limitation of macro system
$I if (m${nv} == null) {
$I m${nv} = new java.util.HashMap<${kt},${vt}>((int)size${nv});
$I m${nv} = new java.util.HashMap<${kt},${vt}>((int)(size${nv} * 4)/3 + 1);
$I $var = m${nv};
$I } else m${nv}.clear();
$I for ( ; 0 < size${nv}; size${nv} = in.mapNext()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.util.HashMap;
import java.util.Map;

import org.apache.avro.Schema;
import org.apache.avro.io.Encoder;
Expand Down Expand Up @@ -71,8 +73,9 @@ void withoutSchemaMigration() throws IOException {

@Test
void withSchemaMigration() throws IOException {
Map<CharSequence, CharSequence> map = new HashMap<>();
FullRecordV2 src = new FullRecordV2(true, 731, 87231, 38L, 54.2832F, "Hi there",
ByteBuffer.wrap(Utf8.getBytesFor("Hello, world!")));
ByteBuffer.wrap(Utf8.getBytesFor("Hello, world!")), map);
assertTrue(((SpecificRecordBase) src).hasCustomCoders(), "Test schema must allow for custom coders.");

ByteArrayOutputStream out = new ByteArrayOutputStream(1024);
Expand Down
3 changes: 2 additions & 1 deletion lang/java/compiler/src/test/resources/full_record_v2.avsc
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
}, {
"name" : "h",
"type" : "bytes"
} ]
},
{ "name" : "myMap", "type" : { "type" : "map", "values" : "string" } }]
}