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

x33g5p2x  于2022-01-19 转载在 其他  
字(14.9k)|赞(0)|评价(0)|浏览(112)

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

Field介绍

[英]Primitive Types

The set of primitive type names is: null: no rawValue boolean: a binary rawValue int: 32-bit signed integer long: 64-bit signed integer float: single precision (32-bit) IEEE 754 floating-point number double: double precision (64-bit) IEEE 754 floating-point number bytes: sequence of 8-bit unsigned bytes string: unicode character sequence
[中]基本类型
基元类型名称集为:null:no rawValue boolean:a binary rawValue int:32位有符号整数long:64位有符号整数float:single-precision(32位)IEEE 754浮点数double:double:double-precision(64位)IEEE 754浮点数字节:8位无符号字节序列字符串:unicode字符序列

代码示例

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

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) &&
        !field.getName().equals(FieldDictionary.RECORD_NAME) &&
        !field.getName().equals(FieldDictionary.RECORD_VALUE) &&
        !field.getName().equals(FieldDictionary.RECORD_ID) &&
        !field.getName().equals(FieldDictionary.RECORD_TYPE)
    .collect(Collectors.toMap(field -> field.getName().replaceAll("\\.", "_"),
        field -> {
          try {
            switch (field.getType()) {
              case STRING:
                return field.asString();
              case INT:
                return field.asInteger();
              case LONG:
                return field.asLong();
              case FLOAT:
                return field.asFloat();
              case DOUBLE:
                return field.asDouble();
              case BOOLEAN:
                return field.asBoolean();
              default:
                return field.getRawValue();
          MetricTimeSeries.Builder builder = new MetricTimeSeries.Builder(metricName, entry.getValue());

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

/**
 * set a field value
 *
 * @param fieldName
 * @param value
 */
@Override
public Record setField(String fieldName, FieldType fieldType, Object value) {
  setField(new Field(fieldName, fieldType, value));
  return this;
}

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

if (field.isSet()) {
  switch (field.getType()) {
    case STRING:
      isValid = field.getRawValue() instanceof String;
      break;
    case INT:
      isValid = field.getRawValue() instanceof Integer;
      break;
    case LONG:
      isValid = field.getRawValue() instanceof Long;
      break;
    case FLOAT:
      isValid = field.getRawValue() instanceof Float;
      break;
    case DOUBLE:
      isValid = field.getRawValue() instanceof Double;
      break;
    case BOOLEAN:
      isValid = field.getRawValue() instanceof Boolean;
      break;
    case ARRAY:
      isValid = field.getRawValue() instanceof Collection;
      break;
    case RECORD:
      isValid = field.getRawValue() instanceof Record;
      break;
    default:
logger.info("field {} is not an instance of type {}", field.getName(), field.getType());

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

public SolrInputDocument toSolrInputDocument(Record record, String uniqueKey) {
  SolrInputDocument document = createNewSolrInputDocument();
  document.addField(uniqueKey, record.getId());
  for (Field field : record.getAllFields()) {
    if (field.isReserved()) {
      continue;
    }
    document.addField(field.getName(), field.getRawValue());
  }
  return document;
}

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

Object fieldValue = field.getRawValue();
FieldType fieldType = field.getType();

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

final InputDocument.Builder docbuilder = InputDocument.builder(record.getId());
for (final String fieldName : record.getAllFieldNames()) {
  if (record.getField(fieldName).getRawValue() != null) {
    switch (record.getField(fieldName).getType()) {
      case STRING:
        docbuilder.addField(fieldName, record.getField(fieldName).asString(), stopAnalyzer);
        break;
      case INT:
        docbuilder.addField(new LegacyDoubleField(fieldName, record.getField(fieldName).asInteger(), Field.Store.YES));
        break;
      case LONG:
        docbuilder.addField(new LegacyDoubleField(fieldName, record.getField(fieldName).asLong(), Field.Store.YES));
        break;
      case FLOAT:
        docbuilder.addField(new LegacyDoubleField(fieldName, record.getField(fieldName).asFloat(), Field.Store.YES));
        break;
      case DOUBLE:
        docbuilder.addField(new LegacyDoubleField(fieldName, record.getField(fieldName).asDouble(), Field.Store.YES));
        break;
      default:
        docbuilder.addField(fieldName, record.getField(fieldName).asString(), keywordAnalyzer);

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

/**
 * retrieve record id
 *
 * @return the record id
 */
@Override
public String getId() {
  return getField(FieldDictionary.RECORD_ID).asString();
}

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

FieldType currentFieldType = currentField.getType();
FieldType newFieldType = fieldTypes.get(fieldName);
      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-elasticsearch-plugin

|| !record.getField(indexFieldName).getType().equals(FieldType.STRING) // index field is not of STRING type
    || record.getField(indexFieldName).getRawValue() == null // index field raw value is null
    || record.getField(indexFieldName).getRawValue().toString().isEmpty() // index field is empty
    ) {
  StandardRecord outputRecord = new StandardRecord(record);
    || !record.getField(idsFieldName).getType().equals(FieldType.STRING)
    || record.getField(idsFieldName).getRawValue() == null
    || record.getField(idsFieldName).getRawValue().toString().isEmpty() ) {
  StandardRecord outputRecord = new StandardRecord(record);
  outputRecord.addError(ProcessError.BAD_RECORD.getName(), "record must have the field " + idsFieldName + " containing the Ids to use in the multiget query. This field must be of STRING type and cannot be empty.");
String index = record.getField(indexFieldName).asString();
    && record.getField(typeFieldName).asString().trim().length() > 0 )  // if the type is empty (whitespaces), consider it is not set (type = null)
    ? record.getField(typeFieldName).asString()
    : null;
String idsString = record.getField(idsFieldName).asString();
List<String> idsList = new ArrayList<>(Arrays.asList(idsString.split("\\s*,\\s*")));
if(record.getField(includesFieldName) != null && record.getField(includesFieldName).getRawValue() != null) {
  String includesString = record.getField(includesFieldName).asString();
  List<String> includesList = new ArrayList<>(Arrays.asList(includesString.split("\\s*,\\s*")));
  includesArray = new String[includesList.size()];
if(record.getField(excludesFieldName) != null && record.getField(excludesFieldName).getRawValue() != null) {
  String excludesString = record.getField(excludesFieldName).asString();
  List<String> excludesList = new ArrayList<>(Arrays.asList(excludesString.split("\\s*,\\s*")));

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

recordValue = (byte[]) record.getField(FieldDictionary.RECORD_VALUE).getRawValue();
if (debug) {
  logger.debug("record=" + Arrays.toString(recordValue));
      .setField(new Field("src_ip4", FieldType.STRING, netflowRecord.get("src_ip4")))
      .setField(new Field("dst_ip4", FieldType.STRING, netflowRecord.get("dst_ip4")))
      .setField(new Field("nexthop", FieldType.STRING, netflowRecord.get("nexthop")))
      .setField(new Field("input", FieldType.INT, netflowRecord.get("input")))
      .setField(new Field("output", FieldType.INT, netflowRecord.get("output")))
      .setField(new Field("dPkts", FieldType.LONG, netflowRecord.get("dPkts")))
      .setField(new Field("dOctets", FieldType.LONG, netflowRecord.get("dOctets")))
      .setField(new Field("first", FieldType.LONG, netflowRecord.get("first")))
      .setField(new Field("last", FieldType.LONG, netflowRecord.get("last")))
      .setField(new Field("src_port", FieldType.INT, netflowRecord.get("src_port")))
      .setField(new Field("dst_port", FieldType.INT, netflowRecord.get("dst_port")))
      .setField(new Field("flags", FieldType.INT, netflowRecord.get("flags")))
      .setField(new Field("nprot", FieldType.INT, netflowRecord.get("nprot")))
      .setField(new Field("tos", FieldType.INT, netflowRecord.get("tos")))
      .setField(new Field("src_as", FieldType.INT, netflowRecord.get("src_as")))
      .setField(new Field("dst_as", FieldType.INT, netflowRecord.get("dst_as")))
      .setField(new Field("src_mask", FieldType.INT, netflowRecord.get("src_mask")))
      .setField(new Field("dst_mask", FieldType.INT, netflowRecord.get("dst_mask")));
    evt.setField(new Field("duration", FieldType.LONG, duration));
    try{
      String ipString = (String) netflowRecord.get("src_ip4");
      String host = ia.getCanonicalHostName();
      if (host.compareTo(ipString) != 0) {

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

@Override
public Date getTime() {
  try {
    return new Date((long) getField(FieldDictionary.RECORD_TIME).getRawValue());
  } catch (Exception ex) {
    return null;
  }
}

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

.filter(field -> field.getType().equals(FieldType.RECORD) &&
      !field.getName().equals(FieldDictionary.RECORD_TYPE) &&
      !field.getName().equals(FieldDictionary.RECORD_ID) &&
      !field.getName().equals(FieldDictionary.RECORD_TIME) &&
      !field.getName().equals(FieldDictionary.RECORD_POSITION))
  .collect(Collectors.toList());
  .filter(field -> !field.getType().equals(FieldType.RECORD))
  .collect(Collectors.toList());
Record flattenRecord = field.asRecord();
    rootFields.forEach(rootField -> {
      String concatFieldName = rootField.getName();
          rootField.getType() == FieldType.STRING &&
          flattenRecord.hasField(concatFieldName) &&
          flattenRecord.getField(concatFieldName).getType() == FieldType.STRING) {
            rootField.asString() + concatSeparator +
                flattenRecord.getField(rootField.getName()).asString());
      }else {
        flattenRecord.setField(rootField);

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

.stream()
.filter(e->(e.getField(sessionid_field)!=null))
.collect(Collectors.groupingBy((Record e )-> e.getField(sessionid_field).asString()));
    .stream()
    .filter(e -> e.getField(timestamp_field) != null)
    .min(Comparator.comparingLong((Record e) -> e.getField(timestamp_field).asLong()))
    .get();
    .stream()
    .filter(e -> e.getField(timestamp_field) != null)
    .max(Comparator.comparingLong((Record e) -> e.getField(timestamp_field).asLong()))
    .get();
    .stream()
    .filter(p -> ((p.getField(userid_field) != null) &&
        (p.getField(userid_field).asString() != null) &&
        (! p.getField(userid_field).asString().isEmpty())))
    .findFirst();
long sessionInactivityDuration = (now - latestRecord.getField(timestamp_field).asLong()) / 1000;
if (sessionInactivityDuration > session_inactivity_timeout)
long sessionDuration = (latestRecord.getField(timestamp_field).asLong() - firstRecord.getField(timestamp_field).asLong()) / 1000;
if (sessionDuration > 0) {
  consolidatedSession.setField(sessionDuration_field, FieldType.LONG, sessionDuration);
Date firstEventDateTime = new Date(firstRecord.getField(timestamp_field).asLong());
Date lastEventDateTime = new Date(latestRecord.getField(timestamp_field).asLong());

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

records.forEach(record -> {
  byte[] pcapRawValue = (byte[]) record.getField(FieldDictionary.RECORD_VALUE).getRawValue();
        final Long pcapTimestampInNanos = 1000000L * record.getField(FieldDictionary.RECORD_TIME).asLong();
        StandardRecord outputRecord = new StandardRecord();
        outputRecord.setField(new Field(FieldDictionary.RECORD_TYPE, FieldType.STRING, "pcap_packet"));
        outputRecord.setField(new Field(FieldDictionary.PROCESSOR_NAME, FieldType.STRING, this.getClass().getSimpleName()));
          if (result.containsKey(field)) {
            outputRecord.setField(new Field(field.getName(), field.getFieldType(), result.get(field)));
    StandardRecord outputRecord = new StandardRecord();
    outputRecord.addError(ProcessError.INVALID_FILE_FORMAT_ERROR.getName(), e.getMessage());
    outputRecord.setField(new Field(FieldDictionary.RECORD_VALUE, FieldType.BYTES, pcapRawValue));
    if (debug) {
      logger.debug("InvalidPCapFileException : error record added successfully.");

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

for (final String fieldName : record.getAllFieldNames()) {
  if (luceneAttrsToQuery.contains(fieldName) &&
      record.getField(fieldName).getRawValue() != null) {
    String ip = record.getField(fieldName).asString();
              (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-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-outlier-detection-plugin

long timestamp = record.getField(timeField).asLong();
double value = record.getField(valueField).asDouble();

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

/**
 * set a field value
 *
 * @param field
 */
@Override
public Record setField(Field field) {
  fields.put(field.getName(), field);
  return this;
}

相关文章