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

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

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

Record.hasField介绍

暂无

代码示例

代码示例来源: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-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-sampling-plugin

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

代码示例来源: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-web-analytics-plugin

private boolean is_refer_under_site_domain(String domain, ProcessContext context, Record record) {
  boolean res = false;
  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;

代码示例来源: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

@Override
  public Collection<Record> process(ProcessContext context, Collection<Record> records) {

    // check if we need initialization
    if (datastoreClientService == null) {
      init(context);
    }

    List<Record> outputRecords = new ArrayList<>(records);
    for (final Map.Entry<String, String> entry : dynamicTagValuesMap.entrySet()) {

      try {
        sandbox.eval(entry.getValue());
        Record cached = (Record) sandbox.get("record_" + entry.getKey());
        if (cached.hasField(FieldDictionary.RECORD_VALUE))
          outputRecords.add(cached);
      } catch (ScriptException e) {
        Record errorRecord = new StandardRecord(RecordDictionary.ERROR)
            .setId(entry.getKey())
            .addError("ScriptException", e.getMessage());
        //  outputRecords.add(errorRecord);
        logger.error(e.toString());
      }
    }

    return outputRecords;
  }
}

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

private void updateRecord(ProcessContext context, Record record, Map<String, String> fieldsNameMapping) {
  String conflictPolicy = context.getPropertyValue(CONFLICT_RESOLUTION_POLICY).asString();
  if ((fieldsNameMapping == null) || (fieldsNameMapping.keySet() == null)) {
    return;
  }
  fieldsNameMapping.keySet().forEach(addedFieldName -> {
    final String defaultValueToAdd = context.getPropertyValue(addedFieldName).evaluate(record).asString();
    // field is already here
    if (record.hasField(addedFieldName)) {
      if (conflictPolicy.equals(OVERWRITE_EXISTING.getValue())) {
        overwriteObsoleteFieldValue(record, addedFieldName, defaultValueToAdd);
      }
    } else {
      record.setStringField(addedFieldName, defaultValueToAdd);
    }
  });
}

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

if (record.hasField(normalizedFieldName)) {
  if (conflictPolicy.equals(KEEP_ONLY_OLD_FIELD.getValue())) {
    for (String obsoleteFieldName : obsoleteFieldNames) {
      if (record.hasField(obsoleteFieldName)) {
        record.removeField(obsoleteFieldName);
    if (record.hasField(obsoleteFieldName)) {
      final Field oldField = record.getField(obsoleteFieldName);
      record.setField(normalizedFieldName, oldField.getType(), oldField.getRawValue());

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

try {
  for (String sourceAttr : fieldsNameMapping.keySet()){
    if (record.hasField(sourceAttr) &&
        (record.getField(sourceAttr).asString() != null) &&
        (! record.getField(sourceAttr).asString().isEmpty())){

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

try {
  for (String sourceAttr : fieldsNameMapping.keySet()){
    if (record.hasField(sourceAttr) &&
        (record.getField(sourceAttr).asString() != null) &&
        (! record.getField(sourceAttr).asString().isEmpty())){

代码示例来源: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

@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());
    }
  }
};

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

if (record.hasField(ipAddrField)) {
  String ipAsString = record.getField(ipAddrField).asString();
  if (ipAsString == null)

代码示例来源:origin: com.hurence.logisland/logisland-elasticsearch_5_4_0-client-service

if (record.hasField(FieldDictionary.RECORD_TIME)) {
  try {
    DateTimeFormatter dateParser = ISODateTimeFormat.dateTimeNoMillis();

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

@Override
protected PutRecord createPut(final ProcessContext context, final Record record, final RecordSerializer serializer) {
  String tableName = context.getPropertyValue(TABLE_NAME_DEFAULT).asString();
  String columnFamily = context.getPropertyValue(COLUMN_FAMILY_DEFAULT).asString();
  String columnQualifier = context.getPropertyValue(COLUMN_QUALIFIER_DEFAULT).asString();
  try {
    if (!record.hasField(context.getPropertyValue(ROW_ID_FIELD).asString()))
      throw new IllegalArgumentException("record has no ROW_ID_FIELD");
    final String row = record.getField(context.getPropertyValue(ROW_ID_FIELD).asString()).asString();
    if (record.hasField(context.getPropertyValue(TABLE_NAME_FIELD).asString()))
      tableName = record.getField(context.getPropertyValue(TABLE_NAME_FIELD).asString()).asString();
    if (record.hasField(context.getPropertyValue(COLUMN_FAMILY_FIELD).asString()))
      columnFamily = record.getField(context.getPropertyValue(COLUMN_FAMILY_FIELD).asString()).asString();
    if (record.hasField(context.getPropertyValue(COLUMN_QUALIFIER_FIELD).asString()))
      columnQualifier = record.getField(context.getPropertyValue(COLUMN_QUALIFIER_FIELD).asString()).asString();
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    serializer.serialize(baos, record);
    final byte[] buffer = baos.toByteArray();
    baos.close();
    final Collection<PutColumn> columns = Collections.singletonList(new PutColumn(
        columnFamily.getBytes(StandardCharsets.UTF_8),
        columnQualifier.getBytes(StandardCharsets.UTF_8),
        buffer));
    byte[] rowKeyBytes = getRow(row, context.getPropertyValue(ROW_ID_ENCODING_STRATEGY).asString());
    return new PutRecord(tableName, rowKeyBytes, columns, record);
  } catch (Exception e) {
    logger.error(e.toString());
  }
  return new PutRecord(tableName, null, Collections.emptyList(), record);
}

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

if (record.hasField(fieldName)) {

代码示例来源: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);
    }
  }
}

相关文章