use of java.io.StringBufferInputStream in project vertigo by KleeGroup.
the class FileManagerTest method testCreateTempFileWithNoFile.
@Test
public void testCreateTempFileWithNoFile() {
final String fileName = "monTestFile.txt";
final String typeMime = "monTypeMime";
final Instant lastModified = Instant.now();
final long length = 123;
final InputStreamBuilder inputStreamBuilder = new InputStreamBuilder() {
@Override
public InputStream createInputStream() {
return new StringBufferInputStream("Contenu test");
}
};
final VFile vFile = fileManager.createFile(fileName, typeMime, lastModified, length, inputStreamBuilder);
checkVFile(vFile, fileName, lastModified, typeMime, length);
}
use of java.io.StringBufferInputStream in project vertigo by KleeGroup.
the class FileManagerTest method testCreateTempFileWithNoFileNoMime.
@Test
public void testCreateTempFileWithNoFileNoMime() {
final String fileName = "monTestFile.txt";
final Instant lastModified = Instant.now();
final long length = 123;
final InputStreamBuilder inputStreamBuilder = new InputStreamBuilder() {
@Override
public InputStream createInputStream() {
return new StringBufferInputStream("Contenu test");
}
};
final VFile vFile = fileManager.createFile(fileName, lastModified, length, inputStreamBuilder);
checkVFile(vFile, fileName, lastModified, "text/plain", length);
}
use of java.io.StringBufferInputStream in project groovy-core by groovy.
the class DependencyTest method testDep.
public void testDep() {
cu.addSource("testDep.gtest", new StringBufferInputStream("class C1 {}\n" + "class C2 {}\n" + "class C3 {}\n" + "class A1 {C1 x}\n" + "class A2 extends C2{}\n" + "class A3 {C1 foo(C2 x){new C3()}}\n"));
cu.compile(Phases.CLASS_GENERATION);
assertEquals(cache.get("C1").size(), 1);
assertEquals(cache.get("C2").size(), 1);
assertEquals(cache.get("C3").size(), 1);
Set<String> dep = cache.get("A1");
assertEquals(dep.size(), 2);
assertTrue(dep.contains("C1"));
dep = cache.get("A2");
assertEquals(dep.size(), 2);
assertTrue(dep.contains("C2"));
dep = cache.get("A3");
assertEquals(dep.size(), 4);
assertTrue(dep.contains("C1"));
assertTrue(dep.contains("C2"));
assertTrue(dep.contains("C3"));
}
use of java.io.StringBufferInputStream in project drill by apache.
the class LargeTableGen method generateTableWithIndex.
public void generateTableWithIndex(String tablePath, int recordNumber, String[] indexDef) throws Exception {
// create index
initRandVector(recordNumber);
initDictionary();
DBTests.setTableStatsSendInterval(1);
if (admin.tableExists(tablePath)) {
// admin.deleteTable(tablePath);
}
// create Json String
int batch, i;
int BATCH_SIZE = 2000;
try (Table table = createOrGetTable(tablePath, recordNumber)) {
// create index
createIndex(table, indexDef);
for (batch = 0; batch < recordNumber; batch += BATCH_SIZE) {
int batchStop = Math.min(recordNumber, batch + BATCH_SIZE);
StringBuffer strBuf = new StringBuffer();
for (i = batch; i < batchStop; ++i) {
strBuf.append(String.format("{\"rowid\": \"%d\", \"reverseid\": \"%d\", \"id\": {\"ssn\": \"%s\"}, \"contact\": {\"phone\": \"%s\", \"email\": \"%s\"}," + "\"address\": {\"city\": \"%s\", \"state\": \"%s\"}, \"name\": { \"fname\": \"%s\", \"lname\": \"%s\" }," + "\"personal\": {\"age\" : %s, \"income\": %s, \"birthdate\": {\"$dateDay\": \"%s\"} }," + "\"activity\": {\"irs\" : { \"firstlogin\": \"%s\" } }," + "\"driverlicense\":{\"$numberLong\": %s} } \n", i + 1, recordNumber - i, getSSN(i), getPhone(i), getEmail(i), getAddress(i)[2], getAddress(i)[1], getFirstName(i), getLastName(i), getAge(i), getIncome(i), getBirthdate(i), getFirstLogin(i), getSSN(i)));
}
try (InputStream in = new StringBufferInputStream(strBuf.toString());
DocumentStream stream = Json.newDocumentStream(in)) {
try {
// insert a batch of document in stream
table.insert(stream, "rowid");
} catch (Exception e) {
System.out.println(stream.toString());
throw e;
}
}
}
table.flush();
DBTests.waitForIndexFlush(table.getPath(), INDEX_FLUSH_TIMEOUT);
Thread.sleep(200000);
}
}
Aggregations