當前位置: 首頁>>代碼示例>>Java>>正文


Java Record類代碼示例

本文整理匯總了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;
}
 
開發者ID:SirAeroWN,項目名稱:premier-wherehows,代碼行數:21,代碼來源:DatabaseWriter.java

示例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;
}
 
開發者ID:SirAeroWN,項目名稱:premier-wherehows,代碼行數:20,代碼來源:DatabaseWriter.java

示例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;
}
 
開發者ID:thomas-young-2013,項目名稱:wherehowsX,代碼行數:31,代碼來源:GobblinTrackingAuditProcessor.java

示例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;
}
 
開發者ID:thomas-young-2013,項目名稱:wherehowsX,代碼行數:26,代碼來源:DatabaseWriter.java

示例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();
}
 
開發者ID:thomas-young-2013,項目名稱:wherehowsX,代碼行數:25,代碼來源:FileWriterTest.java

示例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;
}
 
開發者ID:linkedin,項目名稱:WhereHows,代碼行數:26,代碼來源:DatabaseWriter.java

示例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));
}
 
開發者ID:linkedin,項目名稱:WhereHows,代碼行數:25,代碼來源:FileWriterTest.java

示例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;
}
 
開發者ID:SirAeroWN,項目名稱:premier-wherehows,代碼行數:16,代碼來源:StringUtil.java

示例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;
}
 
開發者ID:SirAeroWN,項目名稱:premier-wherehows,代碼行數:11,代碼來源:FileWriter.java

示例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();
  }
}
 
開發者ID:SirAeroWN,項目名稱:premier-wherehows,代碼行數:13,代碼來源:Writer.java

示例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;
}
 
開發者ID:thomas-young-2013,項目名稱:wherehowsX,代碼行數:20,代碼來源:JobExecutionLineageProcessor.java

示例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;
}
 
開發者ID:thomas-young-2013,項目名稱:wherehowsX,代碼行數:20,代碼來源:MetadataInventoryProcessor.java

示例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;
}
 
開發者ID:thomas-young-2013,項目名稱:wherehowsX,代碼行數:39,代碼來源:DatabaseWriter.java

示例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;
}
 
開發者ID:linkedin,項目名稱:WhereHows,代碼行數:39,代碼來源:DatabaseWriter.java

示例15: Writer

import wherehows.common.schemas.Record; //導入依賴的package包/類
public Writer() {
  records = new ArrayList<Record>();
}
 
開發者ID:SirAeroWN,項目名稱:premier-wherehows,代碼行數:4,代碼來源:Writer.java


注:本文中的wherehows.common.schemas.Record類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。