use of com.amazon.ion.IonString in project ion-java by amzn.
the class IonReaderBinaryIncrementalTest method incrementalMultipleValuesLoadFromReader.
@Test
public void incrementalMultipleValuesLoadFromReader() throws Exception {
ResizingPipedInputStream pipe = new ResizingPipedInputStream(128);
final IonReaderBinaryIncremental reader = new IonReaderBinaryIncremental(STANDARD_READER_BUILDER, pipe);
final IonLoader loader = SYSTEM.getLoader();
byte[] bytes = toBinary("value_type::\"StringValueLong\"");
for (byte b : bytes) {
IonDatagram empty = loader.load(reader);
assertTrue(empty.isEmpty());
pipe.receive(b);
}
IonDatagram firstValue = loader.load(reader);
assertEquals(1, firstValue.size());
IonString string = (IonString) firstValue.get(0);
assertEquals("StringValueLong", string.stringValue());
assertEquals(Collections.singletonList("value_type"), Arrays.asList(string.getTypeAnnotations()));
bytes = toBinary("{foobar: \"StringValueLong\"}");
for (byte b : bytes) {
IonDatagram empty = loader.load(reader);
assertTrue(empty.isEmpty());
pipe.receive(b);
}
IonDatagram secondValue = loader.load(reader);
assertEquals(1, secondValue.size());
IonStruct struct = (IonStruct) secondValue.get(0);
string = (IonString) struct.get("foobar");
assertEquals("StringValueLong", string.stringValue());
IonDatagram empty = loader.load(reader);
assertTrue(empty.isEmpty());
reader.close();
}
use of com.amazon.ion.IonString in project ion-java by amzn.
the class MiscStreamingTest method testTreeNullStringValue.
@Test
public void testTreeNullStringValue() {
IonString nullString = system().newNullString();
IonReader reader = system().newReader(nullString);
testNullStringValue(reader);
}
use of com.amazon.ion.IonString in project amazon-qldb-dmv-sample-java by aws-samples.
the class InsertIonTypes method main.
public static void main(final String... args) {
final IonBlob ionBlob = Constants.SYSTEM.newBlob("hello".getBytes());
final IonBool ionBool = Constants.SYSTEM.newBool(true);
final IonClob ionClob = Constants.SYSTEM.newClob("{{'This is a CLOB of text.'}}".getBytes());
final IonDecimal ionDecimal = Constants.SYSTEM.newDecimal(0.1);
final IonFloat ionFloat = Constants.SYSTEM.newFloat(0.2);
final IonInt ionInt = Constants.SYSTEM.newInt(1);
final IonList ionList = Constants.SYSTEM.newList(new int[] { 1, 2 });
final IonNull ionNull = Constants.SYSTEM.newNull();
final IonSexp ionSexp = Constants.SYSTEM.newSexp(new int[] { 2, 3 });
final IonString ionString = Constants.SYSTEM.newString("string");
final IonStruct ionStruct = Constants.SYSTEM.newEmptyStruct();
ionStruct.put("brand", Constants.SYSTEM.newString("ford"));
final IonSymbol ionSymbol = Constants.SYSTEM.newSymbol("abc");
final IonTimestamp ionTimestamp = Constants.SYSTEM.newTimestamp(Timestamp.now());
final IonBlob ionNullBlob = Constants.SYSTEM.newNullBlob();
final IonBool ionNullBool = Constants.SYSTEM.newNullBool();
final IonClob ionNullClob = Constants.SYSTEM.newNullClob();
final IonDecimal ionNullDecimal = Constants.SYSTEM.newNullDecimal();
final IonFloat ionNullFloat = Constants.SYSTEM.newNullFloat();
final IonInt ionNullInt = Constants.SYSTEM.newNullInt();
final IonList ionNullList = Constants.SYSTEM.newNullList();
final IonSexp ionNullSexp = Constants.SYSTEM.newNullSexp();
final IonString ionNullString = Constants.SYSTEM.newNullString();
final IonStruct ionNullStruct = Constants.SYSTEM.newNullStruct();
final IonSymbol ionNullSymbol = Constants.SYSTEM.newNullSymbol();
final IonTimestamp ionNullTimestamp = Constants.SYSTEM.newNullTimestamp();
ConnectToLedger.getDriver().execute(txn -> {
CreateTable.createTable(txn, TABLE_NAME);
final Document document = new Document(Constants.SYSTEM.newString("val"));
InsertDocument.insertDocuments(txn, TABLE_NAME, Collections.singletonList(document));
updateRecordAndVerifyType(txn, ionBlob);
updateRecordAndVerifyType(txn, ionBool);
updateRecordAndVerifyType(txn, ionClob);
updateRecordAndVerifyType(txn, ionDecimal);
updateRecordAndVerifyType(txn, ionFloat);
updateRecordAndVerifyType(txn, ionInt);
updateRecordAndVerifyType(txn, ionList);
updateRecordAndVerifyType(txn, ionNull);
updateRecordAndVerifyType(txn, ionSexp);
updateRecordAndVerifyType(txn, ionString);
updateRecordAndVerifyType(txn, ionStruct);
updateRecordAndVerifyType(txn, ionSymbol);
updateRecordAndVerifyType(txn, ionTimestamp);
updateRecordAndVerifyType(txn, ionNullBlob);
updateRecordAndVerifyType(txn, ionNullBool);
updateRecordAndVerifyType(txn, ionNullClob);
updateRecordAndVerifyType(txn, ionNullDecimal);
updateRecordAndVerifyType(txn, ionNullFloat);
updateRecordAndVerifyType(txn, ionNullInt);
updateRecordAndVerifyType(txn, ionNullList);
updateRecordAndVerifyType(txn, ionNullSexp);
updateRecordAndVerifyType(txn, ionNullString);
updateRecordAndVerifyType(txn, ionNullStruct);
updateRecordAndVerifyType(txn, ionNullSymbol);
updateRecordAndVerifyType(txn, ionNullTimestamp);
deleteTable(txn, TABLE_NAME);
});
}
Aggregations