use of com.amazon.ion.IonMutableCatalog in project ion-java by amzn.
the class IonManagedBinaryWriterTestCase method createWriter.
@Override
protected IonWriter createWriter(final OutputStream out) throws IOException {
final IonMutableCatalog catalog = ((IonMutableCatalog) system().getCatalog());
final List<SymbolTable> symbolTables = new ArrayList<SymbolTable>();
int i = 1;
for (final List<String> symbols : SHARED_SYMBOLS) {
final SymbolTable table = system().newSharedSymbolTable("test_" + (i++), 1, symbols.iterator());
symbolTables.add(table);
catalog.putTable(table);
}
final _Private_IonManagedBinaryWriterBuilder builder = _Private_IonManagedBinaryWriterBuilder.create(_Private_IonManagedBinaryWriterBuilder.AllocatorMode.POOLED).withImports(importedSymbolResolverMode, symbolTables).withPreallocationMode(preallocationMode).withFloatBinary32Enabled();
if (lstAppendMode.isEnabled()) {
builder.withLocalSymbolTableAppendEnabled();
} else {
builder.withLocalSymbolTableAppendDisabled();
}
final IonWriter writer = builder.newWriter(out);
final SymbolTable locals = writer.getSymbolTable();
assertEquals(14, locals.getImportedMaxId());
return writer;
}
use of com.amazon.ion.IonMutableCatalog in project ion-java by amzn.
the class SymbolTableTest method testDupLocalSymbolOnDatagram.
@Test
public void testDupLocalSymbolOnDatagram() throws Exception {
final IonSystem ion1 = system();
final SymbolTable st = ion1.newSharedSymbolTable("foobar", 1, Arrays.asList("s1").iterator());
final IonMutableCatalog cat = new SimpleCatalog();
cat.putTable(st);
// amzn/ion-java/issues/46 has the datagram producing something like:
// $ion_1_0 $ion_symbol_table::{imports:[{name: "foobar", version: 1, max_id: 1}], symbols: ["s1", "l1"]} $11 $12
// local table should not have "s1", user values should be $10 $11
IonDatagram dg = ion1.newDatagram(st);
dg.add().newSymbol("s1");
dg.add().newSymbol("l1");
final IonSystem ion2 = newSystem(cat);
dg = ion2.getLoader().load(dg.getBytes());
checkSymbol("s1", 10, dg.get(0));
checkSymbol("l1", 11, dg.get(1));
}
Aggregations