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

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

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

Record.setField介绍

暂无

代码示例

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

public static Record getKeyValueRecord(byte[] key, byte[] value) {
    final Record record = new StandardRecord("kv_record");
    record.setField(FieldDictionary.RECORD_KEY, FieldType.BYTES, key);
    record.setField(FieldDictionary.RECORD_VALUE, FieldType.BYTES, value);
    return record;
  }
}

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

/**
 * Add the provided geo field to the record
 * @param record Record to update
 * @param attributeName Geo field name
 * @param value Geo field value
 */
private void addRecordField(Record record, String attributeName, String geoFieldName, Object value)
{
  FieldType fieldType = supportedGeoFieldNames.get(geoFieldName);
  if (fieldType == null) // Handle subdivision and subdivision_isocode fields (geo_subdivision_0 is not geo_subdivision)
  {
    fieldType = FieldType.STRING;
  }
  record.setField(attributeName, fieldType, value);
}

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

public Record toRecord(SolrDocument document, String uniqueKey) {
  Map<String, Map<String, String>> map = toMap(document, uniqueKey);
  Map.Entry<String,Map<String, String>> entry = map.entrySet().iterator().next();
  Record record = new StandardRecord();
  record.setId(entry.getKey());
  entry.getValue().forEach((key, value) -> {
    // TODO - Discover Type
    record.setField(key, FieldType.STRING, value);
  });
  return record;
}

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

} else if (value instanceof Integer)
  record.setField(new Field(FIELD_VERSION, FieldType.STRING, value.toString()));
  return true;
} else if (value instanceof Long)
  record.setField(new Field(FIELD_VERSION, FieldType.STRING, value.toString()));
  return true;
} else if (value instanceof Float)
  record.setField(new Field(FIELD_VERSION, FieldType.STRING, value.toString()));
  return true;
} else if (value instanceof Double)
  record.setField(new Field(FIELD_VERSION, FieldType.STRING, value.toString()));
  return true;

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

record.setField(fieldName, newFieldType, currentField.asString());
  break;
case INT:
  record.setField(fieldName, newFieldType, currentField.asInteger());
  break;
case LONG:
  record.setField(fieldName, newFieldType, currentField.asLong());
  break;
case FLOAT:
  record.setField(fieldName, newFieldType, currentField.asFloat());
  break;
case DOUBLE:
  record.setField(fieldName, newFieldType, currentField.asDouble());
  break;
case BOOLEAN:
  record.setField(fieldName, newFieldType, currentField.asBoolean());
  break;
default:

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

} else if (value instanceof Integer)
  record.setField(new Field(key, FieldType.INT, value));
} else if (value instanceof Long)
  record.setField(new Field(key, FieldType.LONG, value));
} else if (value instanceof ArrayList)
  record.setField(new Field(key, FieldType.ARRAY, value));
} else if (value instanceof Float)
  record.setField(new Field(key, FieldType.FLOAT, value));
} else if (value instanceof Double)
    Long longEpochMilliSeconds = (long)doubleEpochMilliSeconds;
    value = longEpochMilliSeconds;
    record.setField(new Field(key, FieldType.LONG, value));
  } else {
    record.setField(new Field(key, FieldType.DOUBLE, value));
  record.setField(new Field(key, FieldType.MAP, value));
} else if (value instanceof Boolean)
  record.setField(new Field(key, FieldType.BOOLEAN, value));
} else

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

switch (fieldType) {
  case INT:
    sampleRecord.setField(valueFieldName, fieldType, (int) Math.round(meanValue));
    break;
  case LONG:
    sampleRecord.setField(valueFieldName, fieldType, Math.round(meanValue));
    break;
  case FLOAT:
    sampleRecord.setField(valueFieldName, fieldType, (float) meanValue);
    break;
  case DOUBLE:
    sampleRecord.setField(valueFieldName, fieldType, meanValue);
    break;

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

@Override
public Collection<Record> process(ProcessContext context, Collection<Record> records) {
  SamplingAlgorithm algorithm = SamplingAlgorithm.valueOf(
      context.getPropertyValue(SAMPLING_ALGORITHM).asString().toUpperCase());
  String valueFieldName = context.getPropertyValue(RECORD_VALUE_FIELD).asString();
  String timeFieldName = context.getPropertyValue(RECORD_TIME_FIELD).asString();
  int parameter = context.getPropertyValue(SAMPLING_PARAMETER).asInteger();
  Sampler sampler = SamplerFactory.getSampler(algorithm, valueFieldName, timeFieldName, parameter);
  return sampler.sample(new ArrayList<>(records)).stream()
      .map(r -> {
        return r.setField("is_sampled", FieldType.BOOLEAN, true);
      }).collect(Collectors.toList());
}

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

flattenRecord.getField(rootField.getName()).asString());
  }else {
    flattenRecord.setField(rootField);
Position position = rootRecord.getPosition();
flattenRecord.setField(FieldDictionary.RECORD_POSITION_LATITUDE, FieldType.DOUBLE, position.getLatitude())
    .setField(FieldDictionary.RECORD_POSITION_LONGITUDE, FieldType.DOUBLE, position.getLongitude())
    .setField(FieldDictionary.RECORD_POSITION_ALTITUDE, FieldType.DOUBLE, position.getAltitude())
    .setField(FieldDictionary.RECORD_POSITION_HEADING, FieldType.DOUBLE, position.getHeading())
    .setField(FieldDictionary.RECORD_POSITION_PRECISION, FieldType.DOUBLE, position.getPrecision())
    .setField(FieldDictionary.RECORD_POSITION_SATELLITES, FieldType.INT, position.getSatellites())
    .setField(FieldDictionary.RECORD_POSITION_SPEED, FieldType.DOUBLE, position.getSpeed())
    .setField(FieldDictionary.RECORD_POSITION_STATUS, FieldType.INT, position.getStatus())
    .setField(FieldDictionary.RECORD_POSITION_TIMESTAMP, FieldType.LONG, position.getTimestamp().getTime());

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

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

cachedThreshold.setField(FieldDictionary.RECORD_COUNT, FieldType.LONG, count + 1)
    .setTime(firstThresholdTime)
    .setField(FieldDictionary.RECORD_LAST_UPDATE_TIME, FieldType.LONG, System.currentTimeMillis());
    .setId(key)
    .setStringField(FieldDictionary.RECORD_VALUE, context.getPropertyValue(key).asString())
    .setField(FieldDictionary.RECORD_COUNT, FieldType.LONG, 1L)
    .setField(FieldDictionary.RECORD_LAST_UPDATE_TIME, FieldType.LONG, System.currentTimeMillis());
datastoreClientService.put(defaultCollection, threshold, true);
outputRecords.add(threshold);

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

record.setField(new Field(field + ".confidence", FieldType.LONG, agent.getConfidence(field)));
record.setField(new Field("ambiguity", FieldType.INT, agent.getAmbiguityCount()));

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

.setTime(new Date(timestamp))
    .setStringField("outlier_severity", "severe")
    .setField("outlier_score", FieldType.DOUBLE, outlier.getScore())
    .setField("outlier_num_points", FieldType.INT, outlier.getNumPts());
list.add(evt);

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

outRecord.setField(nameField);
outRecord.setField(queryField);

相关文章