use of com.amazon.ion.IonList in project amazon-qldb-dmv-sample-java by aws-samples.
the class JournalS3ExportReader method getDataFileKeysFromManifest.
/**
* Given the S3Object to the completed manifest file, return the keys
* which are part of this export request.
*
* @param s3Object
* A {@link S3Object}.
* @return a list of data file keys containing the chunk of {@link JournalBlock}.
*/
private static List<String> getDataFileKeysFromManifest(final S3Object s3Object) {
IonReader ionReader = IonReaderBuilder.standard().build(s3Object.getObjectContent());
// Read the data
ionReader.next();
List<String> keys = new ArrayList<>();
IonStruct ionStruct = (IonStruct) SYSTEM.newValue(ionReader);
IonList ionKeysList = (IonList) ionStruct.get("keys");
ionKeysList.forEach(key -> keys.add(((IonString) key).stringValue()));
return keys;
}
use of com.amazon.ion.IonList in project ion-java by amzn.
the class SymbolTableTest method testSymtabImageMaintenance.
@Test
public void testSymtabImageMaintenance() {
IonSystem system = system();
SymbolTable st = ((_Private_ValueFactory) system).getLstFactory().newLocalSymtab(system.getSystemSymbolTable());
st.intern("foo");
IonStruct image = symtabTree(st, system);
st.intern("bar");
image = symtabTree(st, system);
IonList symbols = (IonList) image.get(SYMBOLS);
assertEquals("[\"foo\",\"bar\"]", symbols.toString());
}
use of com.amazon.ion.IonList in project ion-java by amzn.
the class Symtabs method sharedSymtabStruct.
/**
* Constructs the DOM for a shared symtab.
*
* @param syms If null, so symbols list will be added.
*/
public static IonStruct sharedSymtabStruct(ValueFactory factory, String name, int version, String... syms) {
IonStruct s = factory.newEmptyStruct();
s.setTypeAnnotations(SystemSymbols.ION_SHARED_SYMBOL_TABLE);
s.add(SystemSymbols.NAME).newString(name);
s.add(SystemSymbols.VERSION).newInt(version);
if (syms != null) {
IonList l = s.add(SystemSymbols.SYMBOLS).newEmptyList();
for (String sym : syms) {
l.add().newString(sym);
}
}
return s;
}
use of com.amazon.ion.IonList in project ion-java by amzn.
the class TreeReaderTest method testInitialStateForList.
@Test
public void testInitialStateForList() {
IonList list = system().newEmptyList();
in = system().newReader(list);
check().next().type(IonType.LIST);
assertEquals(0, in.getDepth());
in.stepIn();
{
assertEquals(1, in.getDepth());
expectEof();
}
in.stepOut();
expectTopEof();
}
use of com.amazon.ion.IonList in project ion-java by amzn.
the class ValueWriterTest method testWriteValuesWithSymtabIntoContainer.
// TODO more thorough testing that you can't output from DOM w/ bad text
@Test
public void testWriteValuesWithSymtabIntoContainer() throws Exception {
myOutputInList = true;
SymbolTable fredSymtab = Symtabs.register(Symtabs.FRED_NAME, 1, catalog());
SymbolTable gingerSymtab = Symtabs.register(Symtabs.GINGER_NAME, 1, catalog());
String gingerSym = gingerSymtab.findKnownSymbol(1);
// First setup some data to be copied.
IonDatagram dg = system().newDatagram(gingerSymtab);
dg.add().newSymbol(gingerSym);
IonReader r = system().newReader(dg.getBytes());
// Now copy that data into a non-top-level context
iw = makeWriter(fredSymtab);
iw.writeValues(r);
IonDatagram result = reload();
IonList l = (IonList) result.get(0);
assertEquals(1, l.size());
IonSymbol s = (IonSymbol) l.get(0);
// Should've assigned a new SID
checkSymbol(gingerSym, systemMaxId() + Symtabs.FRED_MAX_IDS[1] + 1, s);
}
Aggregations