use of com.questdb.store.JournalWriter in project questdb by bluestreak01.
the class GenericBinaryTest method testUnclosedOutputOutput.
@Test
public void testUnclosedOutputOutput() throws Exception {
try (JournalWriter writer = getGenericWriter()) {
List<byte[]> expected = getBytes();
for (int i = 0; i < expected.size(); i++) {
JournalEntryWriter w = writer.entryWriter();
w.putBin(0).write(expected.get(i));
w.append();
}
writer.commit();
assertEquals(expected, readOutputStream());
}
}
use of com.questdb.store.JournalWriter in project questdb by bluestreak01.
the class GenericBinaryTest method testInputOutput.
@Test
public void testInputOutput() throws Exception {
try (JournalWriter writer = getGenericWriter()) {
List<byte[]> expected = getBytes();
writeInputStream(writer, expected);
assertEquals(expected, readOutputStream());
}
}
use of com.questdb.store.JournalWriter in project questdb by bluestreak01.
the class GenericInteropTest method testPartialObjectReader.
@Test
public void testPartialObjectReader() throws Exception {
try (JournalWriter writer = makeGenericWriter()) {
JournalEntryWriter w = writer.entryWriter();
w.putSym(0, "EURUSD");
w.putDate(1, 19999);
w.putDouble(2, 1.24);
w.putDouble(3, 1.25);
w.putInt(4, 10000);
w.putInt(5, 12000);
w.putInt(6, 1);
w.putStr(7, "OK");
w.putStr(8, "system");
w.putStr(9, "EURUSD:GLOBAL");
w.putBool(10, true);
w.putNull(11);
w.putLong(12, 13141516);
w.putShort(13, (short) 25000);
w.append();
writer.commit();
}
try (Journal<Partial> reader = getFactory().reader(Partial.class, "test")) {
String expected = "Partial{sym='EURUSD', created=19999, bid=1.24, ask=1.25, bidSize=10000, askSize=12000}";
StringBuilder builder = new StringBuilder();
for (Partial p : JournalIterators.bufferedIterator(reader)) {
builder.append(p);
}
TestUtils.assertEquals(expected, builder);
}
}
use of com.questdb.store.JournalWriter in project questdb by bluestreak01.
the class GenericInteropTest method testInvalidColumnName.
@Test
public void testInvalidColumnName() throws Exception {
File location = null;
try (JournalWriter w = getFactory().writer(new JournalStructure("test") {
{
$int("id").index();
$str("status?\0x");
}
})) {
location = w.getLocation();
w.entryWriter();
} catch (JournalException ignore) {
// ignore
}
Assert.assertNotNull(location);
Files.deleteOrException(location);
try (JournalWriter w = getFactory().writer(new JournalStructure("test") {
{
$int("id").index();
$str("status");
}
})) {
w.entryWriter();
}
}
use of com.questdb.store.JournalWriter in project questdb by bluestreak01.
the class GenericInteropTest method testGenericStructureMismatch.
@Test
public void testGenericStructureMismatch() throws Exception {
try (JournalWriter writer = makeGenericWriter()) {
JournalEntryWriter w = writer.entryWriter();
w.putSym(0, "EURUSD");
w.putDate(1, 19999);
w.putDouble(2, 1.24);
w.putDouble(3, 1.25);
w.putInt(4, 10000);
w.putInt(5, 12000);
w.putInt(6, 1);
w.putStr(7, "OK");
w.putStr(8, "system");
w.putStr(9, "EURUSD:GLOBAL");
w.putBool(10, true);
w.putNull(11);
w.putLong(12, 13141516);
w.putShort(13, (short) 25000);
w.append();
writer.commit();
writer.close();
}
try {
getFactory().writer(new JournalStructure("test") {
{
$str("sym");
$date("created");
}
});
Assert.fail("Expected exception");
} catch (JournalMetadataException ignore) {
// expected
}
}
Aggregations