com.hurence.logisland.record.Record.getField()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(11.4k)|赞(0)|评价(0)|浏览(175)

本文整理了Java中com.hurence.logisland.record.Record.getField方法的一些代码示例,展示了Record.getField的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Record.getField方法的具体详情如下:
包路径:com.hurence.logisland.record.Record
类名称:Record
方法名:getField

Record.getField介绍

暂无

代码示例

代码示例来源:origin: com.hurence.logisland/logisland-common-processors-plugin

@Override
  public void buildId(Record record) {
    StringBuilder stb = new StringBuilder();
    for (String fieldName : fieldsForHash) {
      stb.append(record.getField(fieldName).asString());
    }
    digest.update(stb.toString().getBytes(charset));
    byte[] digested = digest.digest();
    final String hashString = new String(digested, charset);
    final String recordType = record.getField(FieldDictionary.RECORD_TYPE).asString();
    final String recordTime = record.getField(FieldDictionary.RECORD_TIME).asString();
    final String newId = String.format("%s-%s-%s", recordType, recordTime, hashString);
    record.setId(newId);
  }
};

代码示例来源:origin: com.hurence.logisland/logisland-common-processors-plugin

/**
 * Retrieve the record field value
 * @param fieldName The name of the string field
 * @return The value of the field or null if the field is not present in the record
 */
private String getStringField(Record record, String fieldName)
{
  Field field = record.getField(fieldName);
  if (field != null)
  {
    return field.asString();
  }
  else
  {
    return null;
  }
}

代码示例来源:origin: com.hurence.logisland/logisland-common-processors-plugin

@Override
  public void buildId(Record record) {
    StringBuilder stb = new StringBuilder();
    for (String fieldName : fieldsForHash) {
      if (record.hasField(fieldName))
        stb.append(record.getField(fieldName).asString());
    }
    digest.update(stb.toString().getBytes(charset));
    byte[] digested = digest.digest();
    StringBuffer hexString = new StringBuffer();
    for (int i = 0; i < digested.length; i++) {
      hexString.append(Integer.toHexString(0xFF & digested[i]));
    }
    record.setId(hexString.toString());
  }
};

代码示例来源:origin: com.hurence.logisland/logisland-common-processors-plugin

private void extractAndParsePropertiesField(Record outputRecord, String propertiesField) {
  Field field = outputRecord.getField(propertiesField);
  if (field != null) {
    String str = field.getRawValue().toString();
    Matcher matcher = PROPERTIES_SPLITTER_PATTERN.matcher(str);
    while (matcher.find()) {
      if (matcher.groupCount() == 2) {
        String key = matcher.group(1);
        String value = matcher.group(2).trim();
        // logger.debug(String.format("field %s = %s", key, value));
        outputRecord.setField(key, FieldType.STRING, value);
      }
    }
    outputRecord.removeField("properties");
  }
}

代码示例来源:origin: com.hurence.logisland/logisland-sampling-plugin

public Double getRecordValue(Record record){
  if (record.hasField(valueFieldName)) {
    return record.getField(valueFieldName).asDouble();
  }else{
    return null;
  }
}

代码示例来源:origin: com.hurence.logisland/logisland-cache_key_value-service-api

@Override
public void bulkPut(String collectionName, Record record) throws DatastoreClientServiceException {
  set(record.getField(rowKey).asString(), record);
}

代码示例来源:origin: com.hurence.logisland/logisland-cache_key_value-service-api

@Override
public Record get(String collectionName, Record record) throws DatastoreClientServiceException {
  if (record.hasField(rowKey)) {
    return get(record.getField(rowKey).asString());
  } else {
    logger.error("field " + rowKey + " not found in record " + record.toString());
    return null;
  }
}

代码示例来源:origin: com.hurence.logisland/logisland-sampling-plugin

public Long getRecordTime(Record record){
  if (record.hasField(timeFieldName)) {
    return record.getField(timeFieldName).asLong();
  }else{
    return null;
  }
}

代码示例来源:origin: com.hurence.logisland/logisland-cache_key_value-service-api

@Override
public void put(String collectionName, Record record, boolean asynchronous) throws DatastoreClientServiceException {
  set(record.getField(rowKey).asString(), record);
}

代码示例来源:origin: com.hurence.logisland/logisland-common-processors-plugin

@Override
public Collection<Record> process(ProcessContext context, Collection<Record> records) {
  String fieldToFilterOn = context.getPropertyValue(FILTERING_FIELD).asString();
  Collection<Record> outputRecords = records.stream().filter(record -> !record.hasField(fieldToFilterOn)).collect(Collectors.toList());
  try {
    outputRecords.addAll(
        records.stream()
        .filter(distinctByKey(record -> record.getField(fieldToFilterOn)))
        .collect(Collectors.toList()));
  } catch (Exception ex) {
    logger.warn("issue while trying to remove field list {} :  {}",
        context.getPropertyValue(FILTERING_FIELD).asString(),
        ex.toString());
  }
  return outputRecords;
}

代码示例来源:origin: com.hurence.logisland/logisland-common-processors-plugin

@Override
public Collection<Record> process(ProcessContext context, Collection<Record> records) {
  String fieldName = context.getPropertyValue(FIELD_NAME).asString();
  String fieldValue = context.getPropertyValue(FIELD_VALUE).asString();
  return records.stream()
      .filter(record -> record.hasField(fieldName) && record.getField(fieldName).asString().equals(fieldValue))
      .collect(Collectors.toList());
}

代码示例来源:origin: com.hurence.logisland/logisland-common-processors-plugin

private void extractValueFields(String[] valueFields, Record outputRecord, Matcher valueMatcher, ProcessContext context) {
  String conflictPolicy = context.getPropertyValue(CONFLICT_RESOLUTION_POLICY).asString();
  for (int i = 0; i < Math.min(valueMatcher.groupCount() + 1, valueFields.length); i++) {
    String content = valueMatcher.group(i + 1);
    String fieldName = valueFields[i];
    if (content != null) {
      if (outputRecord.hasField(fieldName) &&
          (outputRecord.getField(fieldName).asString() != null) &&
          (! outputRecord.getField(fieldName).asString().isEmpty())) {
        if (conflictPolicy.equals(OVERWRITE_EXISTING.getValue())) {
          outputRecord.setStringField(fieldName, content.replaceAll("\"", ""));
        }
      }
      else {
        outputRecord.setStringField(fieldName, content.replaceAll("\"", ""));
      }
    }
  }
}

代码示例来源:origin: com.hurence.logisland/logisland-common-processors-plugin

private void overwriteObsoleteFieldValue(Record record, String fieldName, String newValue) {
  final Field fieldToUpdate = record.getField(fieldName);
  record.removeField(fieldName);
  record.setField(fieldName, fieldToUpdate.getType(), newValue);
}

代码示例来源:origin: com.hurence.logisland/logisland-web-analytics-plugin

String first_visited_page_field = context.getPropertyValue(FIRST_VISITED_PAGE_FIELD).asString();
if (record.hasField(first_visited_page_field)){
  String first_page = record.getField(first_visited_page_field).asString();
  URL first_page_url = null;
  try {

代码示例来源:origin: com.hurence.logisland/logisland-common-processors-plugin

@Override
public Collection<Record> process(ProcessContext context, Collection<Record> records) {
  List<Record> outputRecords = (List<Record>) super.process(context, records);
  String propertiesField = context.getPropertyValue(PROPERTIES_FIELD).asString();
  for (Record outputRecord : outputRecords) {
    Field field = outputRecord.getField(propertiesField);
    if (field != null) {
      String str = field.getRawValue().toString();
      Matcher matcher = PROPERTIES_SPLITTER_PATTERN.matcher(str);
      while (matcher.find()) {
        if (matcher.groupCount() == 2) {
          String key = matcher.group(1);
          String value = matcher.group(2);
          // logger.debug(String.format("field %s = %s", key, value));
          outputRecord.setField(key, FieldType.STRING, value);
        }
      }
      outputRecord.removeField("properties");
    }
  }
  return outputRecords;
}

代码示例来源:origin: com.hurence.logisland/logisland-sampling-plugin

/**
   * retrun the same record as input by keeping only time and value fields.
   *
   * @param record
   * @return
   */
  public Record getTimeValueRecord(Record record){
    Record tvRecord = new StandardRecord(record.getType());
    Double value = getRecordValue(record);
    if(value != null)
      tvRecord.setField(valueFieldName, record.getField(valueFieldName).getType(), value);

    Long time = getRecordTime(record);
    if(time != null)
      tvRecord.setField(timeFieldName, record.getField(timeFieldName).getType(), time);

    return tvRecord;
  }
}

代码示例来源:origin: com.hurence.logisland/logisland-common-processors-plugin

private void overwriteObsoleteFieldName(Record record, String normalizedFieldName, String obsoleteFieldName) {
  // remove old badly named field
  if (record.hasField(obsoleteFieldName)) {
    final Field fieldToRename = record.getField(obsoleteFieldName);
    record.removeField(obsoleteFieldName);
    record.setField(normalizedFieldName, fieldToRename.getType(), fieldToRename.getRawValue());
  }
}

代码示例来源:origin: com.hurence.logisland/logisland-common-processors-plugin

private void extractValueFields(String valueField, Record outputRecord, String[] values, ProcessContext context) {
  String conflictPolicy = context.getPropertyValue(CONFLICT_RESOLUTION_POLICY).asString();
  String fieldName = valueField;
  if (outputRecord.hasField(fieldName) &&
      (outputRecord.getField(fieldName).asString() != null) &&
      (! outputRecord.getField(fieldName).asString().isEmpty())) {
    if (conflictPolicy.equals(OVERWRITE_EXISTING.getValue())) {
      //outputRecord.setStringField(fieldName, content.replaceAll("\"", ""));
      outputRecord.setField(fieldName, FieldType.ARRAY, values);
      if (this.isEnabledSplitCounter){
        outputRecord.setField(fieldName+this.splitCounterSuffix, FieldType.INT, values.length);
      }
    }
  }
  else {
    outputRecord.setField(fieldName, FieldType.ARRAY, values);
    //outputRecord.setStringField(fieldName, content.replaceAll("\"", ""));
    if (this.isEnabledSplitCounter){
      outputRecord.setField(fieldName+this.splitCounterSuffix, FieldType.INT, values.length);
    }
  }
}

代码示例来源:origin: com.hurence.logisland/logisland-cache_key_value-service-api

@Override
public List<MultiGetResponseRecord> multiGet(List<MultiGetQueryRecord> multiGetQueryRecords) throws DatastoreClientServiceException {
  List<MultiGetResponseRecord> results = new ArrayList<>();
  for (MultiGetQueryRecord mgqr : multiGetQueryRecords) {
    String collectionName = mgqr.getIndexName();
    String typeName = mgqr.getTypeName();
    for (String id : mgqr.getDocumentIds()) {
      Record record = get(collectionName, new StandardRecord().setStringField(rowKey, id));
      Map<String, String> retrievedFields = new HashMap<>();
      if (record != null) {
        if (mgqr.getFieldsToInclude()[0].equals("*")) {
          for (Field field : record.getAllFieldsSorted()) {
            if (!field.getName().equals(FieldDictionary.RECORD_TIME) &&
                !field.getName().equals(FieldDictionary.RECORD_TYPE) &&
                !field.getName().equals(FieldDictionary.RECORD_ID))
              retrievedFields.put(field.getName(), field.asString());
          }
        } else {
          for (String prop : mgqr.getFieldsToInclude()) {
            retrievedFields.put(prop, record.getField(prop).asString());
          }
        }
      } else {
        logger.debug("unable to retrieve record (id=" + id + ") from collection " + collectionName);
      }
      results.add(new MultiGetResponseRecord(collectionName, typeName, id, retrievedFields));
    }
  }
  return results;
}

代码示例来源:origin: com.hurence.logisland/logisland-common-processors-plugin

@Override
  public void buildId(Record record) {
    final Object[] valuesForFormat = new Object[fieldsForFormat.length];
    for (int i = 0; i < valuesForFormat.length; i++) {
      if (!record.hasField(fieldsForFormat[i])) {
        List<String> fieldsName = Lists.newArrayList(fieldsForFormat);
        record.addError(ProcessError.CONFIG_SETTING_ERROR.getName(),
            String.format("could not build id with format : '%s' \nfields: '%s' \n because " +
                "field: '%s' does not exist", format, fieldsName, fieldsForFormat[i]));
        return;
      }
      valuesForFormat[i] = record.getField(fieldsForFormat[i]).getRawValue();
    }
    try {
      record.setId(String.format(local, format, valuesForFormat));
    } catch (IllegalFormatException e) {
      // If a format string contains an illegal syntax, a format specifier that is incompatible with the given arguments,
      // insufficient arguments given the format string, or other illegal conditions.
      // For specification of all possible formatting errors, see the Details section of the formatter class specification.
      record.addError(ProcessError.STRING_FORMAT_ERROR.getName(), e.getMessage());
    } catch (NullPointerException e) {//should not happen
      record.addError(ProcessError.CONFIG_SETTING_ERROR.getName(), e.getMessage());
    }
  }
};

相关文章