MetaValueDaoImpl implements MetaValueDao, Clearable { @Override public void addAttributes(final Meta meta, final AttributeMap attributes) { final Stream<Row> stream = attributes.entrySet() .stream() .map(entry -> metaKeyService.getIdForName(entry.getKey()) .flatMap(keyId -> { try { final Long longValue = Long.valueOf(entry.getValue()); final Row row = new Row(meta.getCreateMs(), meta.getId(), keyId, longValue); return Optional.of(row); } catch (final NumberFormatException e) { LOGGER.debug(e::getMessage, e); return Optional.empty(); } })) .filter(Optional::isPresent) .map(Optional::get); final List<Row> records = stream.collect(Collectors.toList()); if (metaValueConfig.isAddAsync()) { final Optional<List<Row>> optional = add(records, metaValueConfig.getFlushBatchSize()); optional.ifPresent(this::insertRecords); } else { insertRecords(records); } } @Inject  MetaValueDaoImpl(final MetaDbConnProvider metaDbConnProvider,
                     final MetaKeyDao metaKeyService,
                     final MetaValueConfig metaValueConfig,
                     final ClusterLockService clusterLockService); @Override void addAttributes(final Meta meta, final AttributeMap attributes); @Override void flush(); @Override void deleteOldValues(); @Override Map<Long, Map<String, String>> getAttributes(final List<Meta> list); @Override int delete(final List<Long> metaIdList); @Override void clear();  }
@Test void testFind() { final Meta meta = metaService.create(createProperties("FEED1")); metaService.addAttributes(meta, createAttributes()); ExpressionOperator expression = new ExpressionOperator.Builder() .addTerm(MetaFields.ID, Condition.EQUALS, meta.getId()) .addTerm(MetaFields.CREATE_TIME, Condition.EQUALS, DateUtil.createNormalDateTimeString(meta.getCreateMs())) .build(); FindMetaCriteria criteria = new FindMetaCriteria(expression); assertThat(metaService.find(criteria).size()).isEqualTo(1); expression = new ExpressionOperator.Builder() .addTerm(MetaFields.ID, Condition.EQUALS, meta.getId()) .addTerm(MetaFields.CREATE_TIME, Condition.EQUALS, DateUtil.createNormalDateTimeString(0L)) .build(); criteria = new FindMetaCriteria(expression); assertThat(metaService.find(criteria).size()).isEqualTo(0); expression = new ExpressionOperator.Builder() .addTerm(MetaFields.ID, Condition.EQUALS, meta.getId()) .addTerm(MetaFields.FILE_SIZE, Condition.GREATER_THAN, 0) .build(); criteria = new FindMetaCriteria(expression); assertThat(metaService.find(criteria).size()).isEqualTo(1); expression = new ExpressionOperator.Builder() .addTerm(MetaFields.ID, Condition.EQUALS, meta.getId()) .addTerm(MetaFields.FILE_SIZE.getName(), Condition.BETWEEN, "0,1000000") .build(); criteria = new FindMetaCriteria(expression); assertThat(metaService.find(criteria).size()).isEqualTo(1); }