use of com.amazon.ion.system.SimpleCatalog in project ion-hive-serde by amzn.
the class CatalogConfig method catalogFromReader.
private static IonCatalog catalogFromReader(final IonReader reader) {
final SimpleCatalog catalog = new SimpleCatalog();
while (reader.next() != null) {
@SuppressWarnings("deprecated") final SymbolTable symbolTable = _Private_Utils.newSharedSymtab(reader, true);
catalog.putTable(symbolTable);
}
return catalog;
}
use of com.amazon.ion.system.SimpleCatalog in project ion-java by amzn.
the class CloneTest method testDifferentValueFactoryCloneWithUnknownAnnotationText.
@Test
public void testDifferentValueFactoryCloneWithUnknownAnnotationText() {
IonSystem otherSystem = newSystem(new SimpleCatalog());
SymbolToken tok = newSymbolToken(99);
IonInt original = system().newInt(5);
original.setTypeAnnotationSymbols(tok);
// TODO amzn/ion-java/issues/30 An UnknownSymbolException is expected here, but
// it isn't thrown.
IonInt copy = otherSystem.clone(original);
// If we don't fail we should at least retain the SID.
assertEquals(99, copy.getTypeAnnotationSymbols()[0].getSid());
}
use of com.amazon.ion.system.SimpleCatalog in project ion-java by amzn.
the class CloneTest method testDifferentValueFactoryCloneWithUnknownFieldNameText.
@Test
public void testDifferentValueFactoryCloneWithUnknownFieldNameText() {
IonSystem otherSystem = newSystem(new SimpleCatalog());
SymbolToken tok = newSymbolToken(99);
IonStruct original = system().newEmptyStruct();
IonValue child = system().newNull();
original.add(tok, child);
// This works since the cloned child doesn't retain its field name.
otherSystem.clone(child);
// TODO amzn/ion-java/issues/30 An UnknownSymbolException is expected here, but
// it isn't thrown.
IonStruct copy = otherSystem.clone(original);
// If we don't fail we should at least retain the SID.
assertEquals(99, copy.iterator().next().getFieldNameSymbol().getSid());
}
use of com.amazon.ion.system.SimpleCatalog in project ion-java by amzn.
the class VarIntTest method makeReader.
private IonReaderBinaryUserX makeReader(String hex) throws Exception {
ByteArrayInputStream input = new ByteArrayInputStream(parseHexBinary("E00100EA" + hex));
UnifiedInputStreamX uis = UnifiedInputStreamX.makeStream(input);
uis.skip(4);
return new IonReaderBinaryUserX(new SimpleCatalog(), LocalSymbolTable.DEFAULT_LST_FACTORY, uis, 0);
}
use of com.amazon.ion.system.SimpleCatalog in project ion-java by amzn.
the class SymbolTableTest method testLocalTableWithMissingImport.
@Test
public void testLocalTableWithMissingImport() throws IOException {
// Use a big symtab to get beyond any default allocation within the
// dummy symtab. This was done to trap a bug in LocalSymbolTable.
ArrayList<String> syms = new ArrayList<String>();
int maxId = 50;
for (int i = 1; i <= maxId; i++) {
syms.add("S" + i);
}
SymbolTable table = system().newSharedSymbolTable("T", 1, syms.iterator());
SimpleCatalog catalog = (SimpleCatalog) system().getCatalog();
catalog.putTable(table);
final int import1id = systemMaxId() + 1;
final int import2id = systemMaxId() + 2;
final int local1id = systemMaxId() + maxId + 1;
final int local2id = local1id + 1;
String text = LocalSymbolTablePrefix + "{" + " symbols:[ \"local1\", \"local2\" ]," + " imports:[{name:'''T''', version:1," + " max_id:" + maxId + "}]," + "}\n" + "local1 local2 S1 S2";
byte[] binary = encode(text);
// Remove the imported table before decoding the binary.
assertSame(table, catalog.removeTable("T", 1));
IonDatagram dg = loader().load(binary);
checkSymbol("local1", local1id, dg.get(0));
checkSymbol("local2", local2id, dg.get(1));
checkUnknownSymbol(import1id, dg.get(2));
checkUnknownSymbol(import2id, dg.get(3));
SymbolTable st = dg.get(3).getSymbolTable();
checkLocalTable(st);
checkUnknownSymbol("S1", import1id, st);
checkUnknownSymbol("S2", import2id, st);
assertEquals(local1id - 1, st.getImportedMaxId());
SymbolTable dummy = checkFirstImport("T", 1, new String[maxId], st);
assertTrue(dummy.isSubstitute());
checkUnknownSymbol("S1", import1id, dummy);
checkUnknownSymbol("S2", import2id, dummy);
SymbolTable[] importedTables = st.getImportedTables();
assertEquals(1, importedTables.length);
}
Aggregations