use of com.amazon.ion.IonStruct in project ion-java by amzn.
the class SymbolTableTest method writeIonRep.
IonStruct writeIonRep(SymbolTable st) throws IOException {
IonList container = system().newEmptyList();
st.writeTo(system().newTreeWriter(container));
IonStruct stStruct = (IonStruct) container.get(0);
return stStruct;
}
use of com.amazon.ion.IonStruct in project ion-java by amzn.
the class SymbolTableTest method checkFirstImport.
SymbolTable checkFirstImport(String name, int version, String[] expectedSymbols, SymbolTable st) throws IOException {
IonStruct stStruct = writeIonRep(st);
checkFirstImport(name, version, expectedSymbols, stStruct);
SymbolTable importedTable = st.getImportedTables()[0];
checkSharedTable(name, version, expectedSymbols, importedTable);
return importedTable;
}
use of com.amazon.ion.IonStruct in project ion-java by amzn.
the class SymbolTableTest method insert_local_symbol_table.
private void insert_local_symbol_table(IonDatagram data) {
IonStruct local_symbol_table = system().newEmptyStruct();
local_symbol_table.addTypeAnnotation("$ion_symbol_table");
IonList symbols = system().newEmptyList();
symbols.add(system().newString("one"));
symbols.add(system().newString("two"));
local_symbol_table.add("symbols", symbols);
data.add(local_symbol_table);
}
use of com.amazon.ion.IonStruct in project ion-java by amzn.
the class SymbolTableTest method testInjectingMaxIdIntoImport.
@Test
public // TODO implement
void testInjectingMaxIdIntoImport() {
SymbolTable importedTable = registerImportedV1();
String text = LocalSymbolTablePrefix + "{" + " imports:[{name:'''imported''',version:1}],\n" + "}\n" + "null";
IonDatagram dg = loader().load(text);
SymbolTable symbolTable = dg.get(0).getSymbolTable();
checkLocalTable(symbolTable);
SymbolTable[] imported = symbolTable.getImportedTables();
assertEquals(1, imported.length);
assertSame(importedTable, imported[0]);
// Check that the encoded table has max_id on import
byte[] binary = dg.getBytes();
dg = loader().load(binary);
IonStruct symtabStruct = (IonStruct) dg.systemGet(1);
IonList imports = (IonList) symtabStruct.get("imports");
IonStruct importStruct = (IonStruct) imports.get(0);
checkString("imported", importStruct.get("name"));
IonValue maxIdValue = importStruct.get("max_id");
assertNotNull("max_id wasn't injected into import", maxIdValue);
checkInt(IMPORTED_1_MAX_ID, maxIdValue);
}
use of com.amazon.ion.IonStruct in project ion-java by amzn.
the class Symtabs method registerTables.
private static int[] registerTables(String[] serializedTables) {
int[] maxIds = new int[serializedTables.length];
_Private_IonSystem system = (_Private_IonSystem) IonSystemBuilder.standard().withCatalog(CATALOG).build();
for (int i = 1; i < serializedTables.length; i++) {
String serialized = serializedTables[i];
IonStruct st = (IonStruct) system.singleValue(serialized);
SymbolTable shared = system.newSharedSymbolTable(st);
CATALOG.putTable(shared);
maxIds[i] = shared.getMaxId();
}
return maxIds;
}
Aggregations