本文整理匯總了Java中wherehows.common.schemas.Record類的典型用法代碼示例。如果您正苦於以下問題:Java Record類的具體用法?Java Record怎麽用?Java Record使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Record類屬於wherehows.common.schemas包,在下文中一共展示了Record類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: flush
import wherehows.common.schemas.Record; //導入依賴的package包/類
@Override
public synchronized boolean flush()
throws SQLException {
if (records.size() == 0) {
return false;
}
StringBuilder sb = new StringBuilder();
sb.append("INSERT INTO " + this.tableName + " VALUES ");
for (Record r : this.records) {
sb.append("(" + r.toDatabaseValue() + "),");
}
sb.deleteCharAt(sb.length() - 1);
logger.debug("In databaseWriter : " + sb.toString());
this.jdbcTemplate.execute(sb.toString());
this.records.clear();
return false;
}
示例2: insert
import wherehows.common.schemas.Record; //導入依賴的package包/類
public synchronized boolean insert(String commaDelimitedNames) throws SQLException, DataAccessException {
if (records.size() == 0) {
return false;
}
StringBuilder sb = new StringBuilder();
sb.append("INSERT INTO " + this.tableName + " (" + commaDelimitedNames + ") VALUES ");
for (Record r : this.records) {
sb.append("(" + r.toDatabaseValue() + "),");
}
sb.deleteCharAt(sb.length() - 1);
String statement = sb.toString();
logger.debug("In databaseWriter : " + statement);
this.jdbcTemplate.execute(statement);
this.records.clear();
return true;
}
示例3: process
import wherehows.common.schemas.Record; //導入依賴的package包/類
/**
* Process a Gobblin tracking event audit record
* @param record
* @param topic
* @return null
* @throws Exception
*/
public Record process(GenericData.Record record, String topic)
throws Exception {
if (record != null && record.get("name") != null) {
final String name = record.get("name").toString();
// only handle "DaliLimitedRetentionAuditor","DaliAutoPurgeAuditor" and "DsIgnoreIDPCAuditor"
if (name.equals(DALI_LIMITED_RETENTION_AUDITOR)
|| name.equals(DALI_AUTOPURGED_AUDITOR)
|| name.equals(DS_IGNORE_IDPC_AUDITOR)) {
Long timestamp = (Long) record.get("timestamp");
Map<String, String> metadata = StringUtil.convertObjectMapToStringMap(record.get("metadata"));
String hasError = metadata.get("HasError");
if (!hasError.equalsIgnoreCase("true")) {
String datasetPath = metadata.get("DatasetPath");
String datasetUrn = DATASET_URN_PREFIX + (datasetPath.startsWith("/") ? "" : "/") + datasetPath;
String ownerUrns = metadata.get("OwnerURNs");
DatasetInfoDao.updateKafkaDatasetOwner(datasetUrn, ownerUrns, DATASET_OWNER_SOURCE, timestamp);
}
}
}
return null;
}
示例4: flush
import wherehows.common.schemas.Record; //導入依賴的package包/類
@Override
public synchronized boolean flush()
throws SQLException {
if (records.size() == 0) {
return false;
}
StringBuilder sb = new StringBuilder();
sb.append("INSERT INTO " + this.tableName + " VALUES ");
for (Record r : this.records) {
sb.append("(" + r.toDatabaseValue() + "),");
}
sb.deleteCharAt(sb.length() - 1);
logger.debug("In databaseWriter : " + sb.toString());
try {
this.jdbcTemplate.execute(sb.toString());
} catch (DataAccessException e) {
logger.error("This statement have error : " + sb.toString());
this.records.clear(); // need to recover the records.
}
this.records.clear();
return false;
}
示例5: writeTest
import wherehows.common.schemas.Record; //導入依賴的package包/類
@Test
public void writeTest()
throws IOException, SQLException {
String filePath = "testFile.txt";
Writer w = new FileWriter(filePath);
List<Object> sample = new ArrayList<Object>();
sample.add("aaa");
sample.add("bbb");
sample.add("ccc");
Record record = new SampleDataRecord("/a/b/c", sample);
System.out.println(record.toCsvString());
w.append(record);
w.append(record);
w.close();
BufferedReader bufferedReader = new BufferedReader(new FileReader(filePath));
String line1 = bufferedReader.readLine();
String line2 = bufferedReader.readLine();
Assert.assertEquals(record.toCsvString().trim(), line1);
Assert.assertEquals(record.toCsvString().trim(), line2);
bufferedReader.close();
}
示例6: flush
import wherehows.common.schemas.Record; //導入依賴的package包/類
@Override
public synchronized boolean flush()
throws SQLException {
if (records.size() == 0) {
return false;
}
StringBuilder sb = new StringBuilder();
sb.append("INSERT INTO " + this.tableName + " VALUES ");
for (Record r : this.records) {
sb.append("(" + r.toDatabaseValue() + "),");
}
sb.deleteCharAt(sb.length() - 1);
log.debug("In databaseWriter : " + sb.toString());
try {
this.jdbcTemplate.execute(sb.toString());
} catch (DataAccessException e) {
log.error("This statement have error : " + sb.toString());
this.records.clear(); // need to recover the records.
}
this.records.clear();
return false;
}
示例7: writeTest
import wherehows.common.schemas.Record; //導入依賴的package包/類
@Test
public void writeTest() throws IOException, SQLException {
String filePath = "testFile.txt";
Writer w = new FileWriter(filePath);
List<Object> sample = new ArrayList<>();
sample.add("aaa");
sample.add("bbb");
sample.add("ccc");
Record record = new SampleDataRecord("/a/b/c", sample);
System.out.println(record.toCsvString());
w.append(record);
w.append(record);
w.close();
BufferedReader bufferedReader = new BufferedReader(new FileReader(filePath));
String line1 = bufferedReader.readLine();
String line2 = bufferedReader.readLine();
Assert.assertEquals(record.toCsvString().trim(), line1);
Assert.assertEquals(record.toCsvString().trim(), line2);
bufferedReader.close();
Files.deleteIfExists(Paths.get(filePath));
}
示例8: objectToJsonString
import wherehows.common.schemas.Record; //導入依賴的package包/類
/**
* Convert objects of type Collection, Map, Array and AbstractRecord to Json string
* @param obj
* @return
*/
public static Object objectToJsonString(Object obj) {
if (obj instanceof Collection || obj instanceof Map || obj instanceof Object[] || obj instanceof Record) {
try {
return new ObjectMapper().writeValueAsString(obj);
} catch (JsonProcessingException ex) {
return obj;
}
}
return obj;
}
示例9: flush
import wherehows.common.schemas.Record; //導入依賴的package包/類
@Override
public boolean flush()
throws IOException {
for (Record r : this.records) {
streamWriter.write(r.toCsvString() + "\n");
}
streamWriter.flush();
this.records.clear();
return false;
}
示例10: append
import wherehows.common.schemas.Record; //導入依賴的package包/類
/**
* Write a record to the writer
* @param record
*/
public synchronized void append(Record record)
throws IOException, SQLException {
records.add(record);
// check if the size meet the threhold, flush it
if (AUTO_WRITE && records.size() > MAX_LENGTH) {
flush();
}
}
示例11: process
import wherehows.common.schemas.Record; //導入依賴的package包/類
/**
* Process a JobExecutionLineageEvent record
* @param record GenericData.Record
* @param topic String
* @throws Exception
* @return null
*/
public Record process(GenericData.Record record, String topic)
throws Exception {
if (record != null) {
// Logger.info("Processing Job Execution Lineage Event record. ");
final GenericData.Record auditHeader = (GenericData.Record) record.get("auditHeader");
final JsonNode rootNode = new ObjectMapper().readTree(record.toString());
LineageDao.updateJobExecutionLineage(rootNode);
}
return null;
}
示例12: process
import wherehows.common.schemas.Record; //導入依賴的package包/類
/**
* Process a MetadataInventoryEvent record
* @param record GenericData.Record
* @param topic String
* @throws Exception
* @return null
*/
public Record process(GenericData.Record record, String topic)
throws Exception {
if (record != null) {
// Logger.info("Processing Metadata Inventory Event record. ");
final GenericData.Record auditHeader = (GenericData.Record) record.get("auditHeader");
final JsonNode rootNode = new ObjectMapper().readTree(record.toString());
DatasetInfoDao.updateDatasetInventory(rootNode);
}
return null;
}
示例13: insert
import wherehows.common.schemas.Record; //導入依賴的package包/類
/**
* use JDBC template PreparedStatement to insert records
* require record to have getAllValues() and optional getDbColumnNames() method
* @return boolean if the insert is successful
* @throws SQLException
*/
public boolean insert()
throws SQLException {
if (records.size() == 0 || !(records.get(0) instanceof AbstractRecord)) {
logger.debug("DatabaseWriter no record to insert or unknown record Class.");
return false;
}
final AbstractRecord record0 = (AbstractRecord) records.get(0);
final String[] columnNames = record0.getDbColumnNames();
final String sql =
(columnNames != null) ? PreparedStatementUtil.prepareInsertTemplateWithColumn(tableName, columnNames)
: PreparedStatementUtil.prepareInsertTemplateWithoutColumn(tableName, record0.getAllFields().length);
//logger.debug("DatabaseWriter template for " + record0.getClass() + " : " + sql);
for (final Record record : records) {
try {
jdbcTemplate.update(sql, ((AbstractRecord) record).getAllValuesToString());
/* jdbcTemplate.update(sql, new PreparedStatementSetter() {
@Override
public void setValues(PreparedStatement ps)
throws SQLException {
record.setPreparedStatementValues(ps);
}
}); */
} catch (IllegalAccessException | DataAccessException ae) {
logger.error("DatabaseWriter insert error: " + ae);
}
}
records.clear();
return true;
}
示例14: insert
import wherehows.common.schemas.Record; //導入依賴的package包/類
/**
* use JDBC template PreparedStatement to insert records
* require record to have getAllValues() and optional getDbColumnNames() method
* @return boolean if the insert is successful
* @throws SQLException
*/
public boolean insert()
throws SQLException {
if (records.size() == 0 || !(records.get(0) instanceof AbstractRecord)) {
log.debug("DatabaseWriter no record to insert or unknown record Class.");
return false;
}
final AbstractRecord record0 = (AbstractRecord) records.get(0);
final String[] columnNames = record0.getDbColumnNames();
final String sql =
(columnNames != null) ? PreparedStatementUtil.prepareInsertTemplateWithColumn(tableName, columnNames)
: PreparedStatementUtil.prepareInsertTemplateWithoutColumn(tableName, record0.getAllFields().length);
//logger.debug("DatabaseWriter template for " + record0.getClass() + " : " + sql);
for (final Record record : records) {
try {
jdbcTemplate.update(sql, ((AbstractRecord) record).getAllValuesToString());
/* jdbcTemplate.update(sql, new PreparedStatementSetter() {
@Override
public void setValues(PreparedStatement ps)
throws SQLException {
record.setPreparedStatementValues(ps);
}
}); */
} catch (IllegalAccessException | DataAccessException ae) {
log.error("DatabaseWriter insert error: " + ae);
}
}
records.clear();
return true;
}
示例15: Writer
import wherehows.common.schemas.Record; //導入依賴的package包/類
public Writer() {
records = new ArrayList<Record>();
}