com.hurence.logisland.record.Record类的使用及代码示例

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

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

Record介绍

暂无

代码示例

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

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[] 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-common-processors-plugin

if (record.hasField(jsonInputField)) {
  DocumentContext documentContext = null;
  try {
    documentContext = validateAndEstablishJsonContext(record.getField(jsonInputField).asString());
  } catch (InvalidJsonException e) {
    logger.error("Record {} did not have valid JSON content.", record);
    record.addError(ERROR_INVALID_JSON_FIELD, "unable to parse content of field : " + jsonInputField);
        String error = String.format("Unable to return a scalar value for the expression %s " +
                "for Record %s. Evaluated value was %s.",
            jsonPathExp.getPath(), record.getId(), result.toString());
        record.addError(ERROR_INVALID_JSON_FIELD, error);
            record.getId(), jsonPathExp.getPath(), jsonPathAttrKey);
        logger.error(error);
        record.addError(ERROR_INVALID_JSON_FIELD, error);
      record.setField(jsonPathAttrKey, resultType, resultHolder.get());
    else
      record.setField(jsonPathAttrKey, resultType,getResultRepresentation(resultHolder.get(), nullDefaultValue));
  String error = String.format("Record %s has no field %s.", record.getId(), jsonInputField);
  logger.error(error);
  record.addError(ERROR_INVALID_JSON_FIELD, error);

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

List<Field> leafFields = rootRecord.getAllFields().stream()
    .filter(field -> field.getType().equals(FieldType.RECORD) &&
        !field.getName().equals(FieldDictionary.RECORD_TYPE) &&
List<Field> rootFields = rootRecord.getAllFields().stream()
    .filter(field -> !field.getType().equals(FieldType.RECORD))
    .collect(Collectors.toList());
    flattenRecord.setType(leafRecordType);
            flattenRecord.hasField(concatFieldName) &&
            flattenRecord.getField(concatFieldName).getType() == FieldType.STRING) {
          flattenRecord.setStringField(concatFieldName,
              rootField.asString() + concatSeparator +
                  flattenRecord.getField(rootField.getName()).asString());
        }else {
          flattenRecord.setField(rootField);
    if(includePosition && rootRecord.hasPosition()){
      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())

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

Field uaField = record.getField(userAgentField);
if (uaField == null) {
  logger.info("Skipping record. Field '" + userAgentField + "' does not exists in record");
    String value = agent.getValue(field);
    if (value != null && !value.isEmpty()) {
      record.setStringField(field, value);
      record.setField(new Field(field + ".confidence", FieldType.LONG, agent.getConfidence(field)));
    record.setField(new Field("ambiguity", FieldType.INT, agent.getAmbiguityCount()));
  record.setStringField(FieldDictionary.RECORD_ERRORS, "Failure in User-agent decoding");
  logger.error("Cannot parse User-Agent content: " + record);
  continue;
  record.removeField(userAgentField);

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

Record cachedThreshold = datastoreClientService.get(defaultCollection, new StandardRecord().setId(key));
if (cachedThreshold != null) {
  Long duration = System.currentTimeMillis() - cachedThreshold.getTime().getTime();
  if (duration > recordTTL) {
    datastoreClientService.remove(defaultCollection, cachedThreshold, false);
          cachedThreshold.getField(FieldDictionary.RECORD_LAST_UPDATE_TIME).asLong();
      if (durationBeetwenLastUpdateInMs > context.getPropertyValue(MIN_UPDATE_TIME_MS).asLong()) {
      Long count = cachedThreshold.getField(FieldDictionary.RECORD_COUNT).asLong();
      Date firstThresholdTime = cachedThreshold.getTime();
      cachedThreshold.setField(FieldDictionary.RECORD_COUNT, FieldType.LONG, count + 1)
          .setTime(firstThresholdTime)
          .setField(FieldDictionary.RECORD_LAST_UPDATE_TIME, FieldType.LONG, System.currentTimeMillis());
      Record threshold = new StandardRecord(outputRecordType)
          .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);
  Record errorRecord = new StandardRecord(RecordDictionary.ERROR)
      .setId(entry.getKey())
      .addError("ScriptException", e.getMessage());

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

long timestamp = record.getField(timeField).asLong();
double value = record.getField(valueField).asDouble();
DataPoint dp = new DataPoint(timestamp, value, new HashMap<>(), record.getType());
        .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);
list.add(new StandardRecord(OUTLIER_PROCESSING_EXCEPTION_TYPE)
    .setStringField(FieldDictionary.RECORD_ERRORS, ProcessError.RUNTIME_ERROR.toString())
    .setStringField(FieldDictionary.RECORD_VALUE, e.getMessage())
    .setStringField(FieldDictionary.PROCESSOR_NAME, DetectOutliers.class.getName())
);

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

final FieldType fieldType = bucket.get(0).getField(valueFieldName).getType();
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-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-querymatcher-plugin

com.hurence.logisland.record.Field queryField = null;
Record outRecord = this.outRecords.get(record.getId());
      .setType(
          (recordTypeUpdatePolicy == MatchQuery.RecordTypeUpdatePolicy.overwrite) ?
              context.getPropertyValue(MatchQuery.OUTPUT_RECORD_TYPE).asString() : record.getType()
      );
  this.outRecords.put(record.getId(), outRecord);
  String[] names = (String[])outRecord.getField(ALERT_MATCH_NAME).getRawValue();
  names = Arrays.copyOf(names, names.length+1);
  names[names.length-1] = matchingRule.getName();
  nameField = new com.hurence.logisland.record.Field(ALERT_MATCH_NAME, FieldType.ARRAY, names);
  String[] queries = (String[])outRecord.getField(ALERT_MATCH_QUERY).getRawValue();
  queries = Arrays.copyOf(queries, queries.length+1);
  queries[names.length-1] = matchingRule.getLegacyQuery();
outRecord.setField(nameField);
outRecord.setField(queryField);

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

final String key = record.getField(FieldDictionary.RECORD_KEY).asString();
buffer += record.getField(FieldDictionary.RECORD_VALUE).asString();
String content = matcher.group(i);
if (content != null) {
  record.setStringField(fields[i], matcher.group(i).replaceAll("\"", ""));

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

final long firstTS = records.get(0).getTime().getTime();
long tmp = records.get(records.size() - 1).getTime().getTime();
final long lastTS = tmp == firstTS ? firstTS + 1 : firstTS;
String metricName = first.getField(FieldDictionary.RECORD_NAME).asString();
Map<String, Object> attributes = first.getAllFieldsSorted().stream()
    .filter(field -> !fieldToMetricTypeMapping.containsKey(field.getName()))
    .filter(field -> !field.getName().equals(FieldDictionary.RECORD_TIME) &&
          MetricTimeSeries.Builder builder = new MetricTimeSeries.Builder(metricName, entry.getValue());
          List<Map.Entry<Long, Double>> points = records.stream()
              .filter(record -> record.hasField(entry.getKey()) && record.getField(entry.getKey()).isSet())
              .map(record ->
                  new AbstractMap.SimpleEntry<>(record.getTime().getTime(),
                      record.getField(entry.getKey()).asDouble())
              ).collect(Collectors.toList());
          if (points.isEmpty()) {

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

final Map<String, Record> inputRecords = new HashMap<>();
for (final Record record : records) {
  final InputDocument.Builder docbuilder = InputDocument.builder(record.getId());
  for (final String fieldName : record.getAllFieldNames()) {
    if (luceneAttrsToQuery.contains(fieldName) &&
        record.getField(fieldName).getRawValue() != null) {
      String ip = record.getField(fieldName).asString();
  inputRecords.put(record.getId(), record);
            if (inputRecords.get(k).hasField(ipAttrName) &&
                (inputRecords.get(k).getField(ipAttrName).getRawValue() != null)) {
              HashSet<Pair<String, Pattern>> ipRegexHashset = ipRegexps.get(ipAttrName);
              ipRegexHashset.forEach(p -> {
                String ruleName = p.getLeft();
                Pattern ipRegexPattern = p.getRight();
                String attrValueToMatch = inputRecords.get(k).getField(ipAttrName).asString();
                Matcher ipMatcher = ipRegexPattern.matcher(attrValueToMatch);
                if (ipMatcher.lookingAt()){

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

if (record.hasField(context.getPropertyValue(TABLE_NAME_FIELD).asString()))
  tableName = record.getField(context.getPropertyValue(TABLE_NAME_FIELD).asString()).asString();
  record.addError(
      ProcessError.BAD_RECORD.toString(),
      getLogger(),
final String rowId = record.getField(context.getPropertyValue(ROW_ID_FIELD).asString()).asString();
if (StringUtils.isBlank(rowId)) {
  record.addError(
      ProcessError.BAD_RECORD.toString(),
      getLogger(),
if (record.hasField(context.getPropertyValue(COLUMNS_FIELD).asString()))
  columns = getColumns(record.getField(context.getPropertyValue(COLUMNS_FIELD).asString()).asString());
  clientService.scan(tableName, rowIdBytes, rowIdBytes, columns, handler);
} catch (Exception e) {
  record.addError(
      ProcessError.BAD_RECORD.toString(),
      getLogger(),
  record.addError(
      ProcessError.BAD_RECORD.toString(),
      getLogger(),
record.addError(ProcessError.RUNTIME_ERROR.toString(),
    getLogger(),
    "Unable to fetch row {}",

相关文章