当前位置: 首页>>代码示例>>Java>>正文


Java Record.put方法代码示例

本文整理汇总了Java中org.apache.avro.generic.GenericData.Record.put方法的典型用法代码示例。如果您正苦于以下问题:Java Record.put方法的具体用法?Java Record.put怎么用?Java Record.put使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.avro.generic.GenericData.Record的用法示例。


在下文中一共展示了Record.put方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: start

import org.apache.avro.generic.GenericData.Record; //导入方法依赖的package包/类
@Override
public boolean start() throws IOException {
    super.start();

    String localFilePath = properties.localFilePath.getValue();
    String destinationFolderId = properties.destinationFolderAccessMethod.getValue().equals(AccessMethod.Id)
            ? properties.destinationFolder.getValue()
            : utils.getFolderId(properties.destinationFolder.getValue(), false);

    GoogleDrivePutParameters p = new GoogleDrivePutParameters(destinationFolderId, properties.fileName.getValue(),
            properties.overwrite.getValue(), localFilePath);
    sentFile = utils.putResource(p);
    record = new Record(properties.schemaMain.schema.getValue());
    record.put(0, java.nio.file.Files.readAllBytes(Paths.get(localFilePath)));
    record.put(1, sentFile.getParents().get(0));
    record.put(2, sentFile.getId());
    result.totalCount++;
    result.successCount++;

    return true;
}
 
开发者ID:Talend,项目名称:components,代码行数:22,代码来源:GoogleDrivePutReader.java

示例2: start

import org.apache.avro.generic.GenericData.Record; //导入方法依赖的package包/类
@Override
public boolean start() throws IOException {
    super.start();
    //
    String resourceId = properties.fileAccessMethod.getValue().equals(AccessMethod.Id) ? properties.file.getValue()
            : utils.getFileId(properties.file.getValue());
    Map<String, MimeType> mimes = GoogleDriveMimeTypes.newDefaultMimeTypesSupported();
    mimes.put(MIME_TYPE_GOOGLE_DOCUMENT, properties.exportDocument.getValue());
    mimes.put(MIME_TYPE_GOOGLE_DRAWING, properties.exportDrawing.getValue());
    mimes.put(MIME_TYPE_GOOGLE_PRESENTATION, properties.exportPresentation.getValue());
    mimes.put(MIME_TYPE_GOOGLE_SPREADSHEET, properties.exportSpreadsheet.getValue());
    GoogleDriveGetParameters p = new GoogleDriveGetParameters(resourceId, mimes, properties.storeToLocal.getValue(),
            properties.outputFileName.getValue(), properties.setOutputExt.getValue());
    //
    GoogleDriveGetResult r = utils.getResource(p);
    fileId = r.getId();
    byte[] content = r.getContent();
    record = new Record(properties.schemaMain.schema.getValue());
    record.put(0, content);
    result.totalCount++;
    result.successCount++;

    return true;
}
 
开发者ID:Talend,项目名称:components,代码行数:25,代码来源:GoogleDriveGetReader.java

示例3: setUp

import org.apache.avro.generic.GenericData.Record; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception {
    super.setUp();

    props = new TMarketoInputProperties("test");
    props.connection.setupProperties();
    props.setupProperties();
    props.leadKeyValues.setValue("email");
    props.updateSchemaRelated();
    when(sink.getProperties()).thenReturn(props);
    wop = new MarketoWriteOperation(sink);
    writer = new MarketoInputWriter(wop, null);
    writer.properties = props;
    assertTrue(writer instanceof MarketoInputWriter);

    record = new Record(MarketoConstants.getRESTSchemaForGetLeadOrGetMultipleLeads());
    record.put(1, "[email protected]");
}
 
开发者ID:Talend,项目名称:components,代码行数:19,代码来源:MarketoInputWriterTest.java

示例4: customizeFormField

import org.apache.avro.generic.GenericData.Record; //导入方法依赖的package包/类
@Override
protected void customizeFormField(Record fieldType, Field field) {
  if (fieldType.getSchema().getName().equals(ARRAY_FIELD_TYPE)) {
    JsonNode overrideStrategyNode = field.getJsonProp(OVERRIDE_STRATEGY);
    Schema overrideStrategySchema =
        fieldType.getSchema().getField(OVERRIDE_STRATEGY).schema();
    if (overrideStrategyNode != null && overrideStrategyNode.isTextual()) {
      fieldType.put(OVERRIDE_STRATEGY,
          new GenericData.EnumSymbol(
              overrideStrategySchema, overrideStrategyNode.asText().toUpperCase()));
    } else {
      fieldType.put(OVERRIDE_STRATEGY,
          new GenericData.EnumSymbol(
              overrideStrategySchema, OverrideStrategy.REPLACE.name()));
    }
  }
}
 
开发者ID:kaaproject,项目名称:kaa,代码行数:18,代码来源:ConfigurationSchemaFormAvroConverter.java

示例5: extractRecord

import org.apache.avro.generic.GenericData.Record; //导入方法依赖的package包/类
private Record extractRecord(String idPrefix, Schema avroSchema, Status status) {
  User user = status.getUser();
  Record doc = new Record(avroSchema);

  doc.put("id", idPrefix + status.getId());
  doc.put("created_at", formatterTo.format(status.getCreatedAt()));
  doc.put("retweet_count", status.getRetweetCount());
  doc.put("retweeted", status.isRetweet());
  doc.put("in_reply_to_user_id", status.getInReplyToUserId());
  doc.put("in_reply_to_status_id", status.getInReplyToStatusId());

  addString(doc, "source", status.getSource());
  addString(doc, "text", status.getText());

  MediaEntity[] mediaEntities = status.getMediaEntities();
  if (mediaEntities.length > 0) {
    addString(doc, "media_url_https", mediaEntities[0].getMediaURLHttps());
    addString(doc, "expanded_url", mediaEntities[0].getExpandedURL());
  }

  doc.put("user_friends_count", user.getFriendsCount());
  doc.put("user_statuses_count", user.getStatusesCount());
  doc.put("user_followers_count", user.getFollowersCount());
  addString(doc, "user_location", user.getLocation());
  addString(doc, "user_description", user.getDescription());
  addString(doc, "user_screen_name", user.getScreenName());
  addString(doc, "user_name", user.getName());
  return doc;
}
 
开发者ID:moueimei,项目名称:flume-release-1.7.0,代码行数:30,代码来源:TwitterSource.java

示例6: addString

import org.apache.avro.generic.GenericData.Record; //导入方法依赖的package包/类
private void addString(Record doc, String avroField, String val) {
  if (val == null) {
    return;
  }
  doc.put(avroField, val);
  totalTextIndexed += val.length();
}
 
开发者ID:moueimei,项目名称:flume-release-1.7.0,代码行数:8,代码来源:TwitterSource.java

示例7: transform

import org.apache.avro.generic.GenericData.Record; //导入方法依赖的package包/类
@Override
public GenericRecord transform(JetstreamEvent event) {
	Record record = new GenericData.Record(this.getSchema());

	record.put("key1", (String) event.get("key1"));
	record.put("key2", (String) event.get("key2"));
	return record;
}
 
开发者ID:pulsarIO,项目名称:jetstream,代码行数:9,代码来源:TestGenericAvroTransformer.java

示例8: next

import org.apache.avro.generic.GenericData.Record; //导入方法依赖的package包/类
/**
 * Returns and advances to the next record. Throws exception if
 * there are no more records.
 */
@Override
public Record next() throws IOException, RecordServiceException {
  Records.Record rsRecord = records_.next();
  Record record = new Record(avroSchema_);
  for (int i = 0; i < schema_.cols.size(); ++i) {
    if (rsRecord.isNull(i)) {
      record.put(i, null);
      continue;
    }
    switch(schema_.cols.get(i).type.typeId) {
      case BOOLEAN: record.put(i, rsRecord.nextBoolean(i)); break;
      case TINYINT: record.put(i, (int)rsRecord.nextByte(i)); break;
      case SMALLINT: record.put(i, (int)rsRecord.nextShort(i)); break;
      case INT: record.put(i, rsRecord.nextInt(i)); break;
      case BIGINT: record.put(i, rsRecord.nextLong(i)); break;
      case FLOAT: record.put(i, rsRecord.nextFloat(i)); break;
      case DOUBLE: record.put(i, rsRecord.nextDouble(i)); break;
      case STRING:
      case VARCHAR:
      case CHAR:
        record.put(i, rsRecord.nextByteArray(i).toString()); break;
      default:
        throw new RuntimeException(
            "Unsupported type: " + schema_.cols.get(i).type.typeId);
    }
  }
  return record;
}
 
开发者ID:cloudera,项目名称:RecordServiceClient,代码行数:33,代码来源:GenericRecords.java

示例9: getRecord

import org.apache.avro.generic.GenericData.Record; //导入方法依赖的package包/类
public static Record getRecord(int i) {
    Record record = new GenericData.Record(getWriteSchema());
    record.put("PartitionKey", "partition" + (i % 1000));
    record.put("RowKey", "row" + i);
    record.put("stringCol", "stringCol" + i);
    record.put("booleanColTrue", true);
    record.put("booleanColFalse", false);
    record.put("doubleCol", 2.0d);
    record.put("longCol", 3l);
    record.put("integerCol", i);
    record.put("byteCol", "imBytes".getBytes());
    record.put("dateCol", new Date());

    return record;
}
 
开发者ID:Talend,项目名称:components,代码行数:16,代码来源:TableHelper.java

示例10: start

import org.apache.avro.generic.GenericData.Record; //导入方法依赖的package包/类
@Override
public boolean start() throws IOException {
    super.start();

    CopyMode copyMode = properties.copyMode.getValue();
    String source = properties.source.getValue();
    String destinationFolder = properties.destinationFolder.getValue();
    String newName = properties.rename.getValue() ? properties.newName.getValue() : "";
    boolean deleteSourceFile = properties.deleteSourceFile.getValue();

    /* check for destination folder */
    String destinationFolderId = properties.destinationFolderAccessMethod.getValue().equals(AccessMethod.Id)
            ? destinationFolder
            : utils.getFolderId(destinationFolder, false);
    /* work on a fileName */
    if (CopyMode.File.equals(copyMode)) {
        /* check for managed resource */
        sourceId = properties.sourceAccessMethod.getValue().equals(AccessMethod.Id) ? source : utils.getFileId(source);
        destinationId = utils.copyFile(sourceId, destinationFolderId, newName, deleteSourceFile);
    } else {/* work on a folder */
        /* check for managed resource */
        sourceId = properties.sourceAccessMethod.getValue().equals(AccessMethod.Id) ? source
                : utils.getFolderId(source, false);
        if (newName.isEmpty()) {
            List<String> paths = utils.getExplodedPath(source);
            newName = paths.get(paths.size() - 1);
        }
        destinationId = utils.copyFolder(sourceId, destinationFolderId, newName);
    }
    //
    record = new Record(properties.schemaMain.schema.getValue());
    record.put(0, sourceId);
    record.put(1, destinationId);
    result.totalCount++;
    result.successCount++;

    return true;
}
 
开发者ID:Talend,项目名称:components,代码行数:39,代码来源:GoogleDriveCopyReader.java

示例11: writeLine

import org.apache.avro.generic.GenericData.Record; //导入方法依赖的package包/类
public void writeLine(long timestamp, String message) throws IOException {
  long ms = timestamp % 1000l;
  long second = timestamp / 1000l;
  if (logBlock != null && second != (Long) logBlock.get("second")) {
    LOG.debug("Flushing due to new second: old:{}, new:{}",
        (Long) logBlock.get("second"), second);
    writeBlock();
  }

  if (logBlock == null) {
    logBlock = new GenericData.Record(logBlockSchema);
    logBlock.put("second", second);
    logBlock.put("createTime", System.currentTimeMillis());
    logBlock.put("blockNumber", ++blockNumber);
    logBlock.put("logLines", new GenericData.Array<Record>(
        getMaxLinesPerRecord() / 8, messageWithMillisArraySchema));
  }

  @SuppressWarnings("unchecked")
  GenericArray<Record> logLines = (GenericArray<Record>) logBlock
      .get("logLines");
  Record record = new GenericData.Record(messageWithMillisSchema);
  record.put("ms", ms);
  record.put("eventId", 0);
  record.put("message", message);
  logLines.add(record);

  linesInBlock++;

  if (linesInBlock >= getMaxLinesPerRecord()) {
    LOG.debug("Hit max lines, flushing record.");
    writeBlock();
  }

}
 
开发者ID:blackberry,项目名称:BB-BigData-Log-Tools,代码行数:36,代码来源:BoomWriter.java

示例12: writeLine

import org.apache.avro.generic.GenericData.Record; //导入方法依赖的package包/类
public void writeLine(long timestamp, String message, int eventId,
    long createTime, long blockNumber) throws IOException {
  long ms = timestamp % 1000l;
  long second = timestamp / 1000l;

  if (logBlock != null) {
    if (second != (Long) logBlock.get("second")) {
      LOG.debug("Flushing due to change in second. old:{} new:{}",
          logBlock.get("second"), second);
      writeBlock();
    } else if (createTime != (Long) logBlock.get("createTime")) {
      LOG.debug("Flushing due to change in createTime. old:{} new:{}",
          logBlock.get("createTime"), createTime);
      writeBlock();
    } else if (blockNumber != (Long) logBlock.get("blockNumber")) {
      LOG.debug("Flushing due to change in blockNumber. old:{} new:{}",
          logBlock.get("blockNumber"), blockNumber);
      writeBlock();
    }
  }

  if (logBlock == null) {
    logBlock = new GenericData.Record(logBlockSchema);
    logBlock.put("second", second);
    logBlock.put("createTime", createTime);
    logBlock.put("blockNumber", blockNumber);
    logBlock.put("logLines", new GenericData.Array<Record>(
        getMaxLinesPerRecord() / 8, messageWithMillisArraySchema));
  }

  @SuppressWarnings("unchecked")
  GenericArray<Record> logLines = (GenericArray<Record>) logBlock
      .get("logLines");
  Record record = new GenericData.Record(messageWithMillisSchema);
  record.put("ms", ms);
  record.put("eventId", eventId);
  record.put("message", message);
  logLines.add(record);
}
 
开发者ID:blackberry,项目名称:BB-BigData-Log-Tools,代码行数:40,代码来源:ReBoomWriter.java

示例13: putValue

import org.apache.avro.generic.GenericData.Record; //导入方法依赖的package包/类
private void putValue(Record record, String col, byte[] value) {
  if (schema.getField(col).schema().getType().equals(Type.STRING)) {
    record.put(col, Bytes.toString(value));
  } else if (schema.getField(col).schema().getType().equals(Type.INT)) {
    record.put(col, Bytes.toInt(value));
  } else if (schema.getField(col).schema().getType().equals(Type.LONG)) {
    record.put(col, Bytes.toLong(value));
  } else {
    throw new RuntimeException("Unknown datatype: " + schema.getField(col).schema().getType());
  }
}
 
开发者ID:tmalaska,项目名称:HBase-ToHDFS,代码行数:12,代码来源:ExportHBaseTableToAvro.java

示例14: customizeType

import org.apache.avro.generic.GenericData.Record; //导入方法依赖的package包/类
@Override
protected void customizeType(Record record, Schema fieldTypeSchema) {
  if (record != null && record.getSchema().getName().equals(RECORD_FIELD_TYPE)) {
    JsonNode addressableNode = fieldTypeSchema.getJsonProp(ADDRESSABLE);
    if (addressableNode != null && addressableNode.isBoolean()) {
      record.put(ADDRESSABLE, addressableNode.asBoolean());
    } else {
      record.put(ADDRESSABLE, true);
    }
  }
}
 
开发者ID:kaaproject,项目名称:kaa,代码行数:12,代码来源:ConfigurationSchemaFormAvroConverter.java

示例15: customizeType

import org.apache.avro.generic.GenericData.Record; //导入方法依赖的package包/类
@Override
protected void customizeType(Record record, Schema fieldTypeSchema) {
  if (record != null && eventClassTypes.contains(record.getSchema().getName())) {
    JsonNode classTypeNode = fieldTypeSchema.getJsonProp(CLASS_TYPE);
    Schema enumSchema = record.getSchema().getField(CLASS_TYPE).schema();
    if (classTypeNode != null && classTypeNode.isTextual()) {
      record.put(CLASS_TYPE,
          new GenericData.EnumSymbol(enumSchema,
              classTypeNode.asText().toUpperCase()));
    } else {
      record.put(CLASS_TYPE, new GenericData.EnumSymbol(enumSchema, OBJECT));
    }
  }
}
 
开发者ID:kaaproject,项目名称:kaa,代码行数:15,代码来源:EcfSchemaFormAvroConverter.java


注:本文中的org.apache.avro.generic.GenericData.Record.put方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。