问:
How can I correctly implement a Spring Data JPA repository method retrieving all the objects related to a list of object? (not to a single one)
I am working on a Spring Boot application using Spring Data JPA and I have the following problem.

I have this EventLog entity class:

```<code>@Entity
@Table(name = "log")
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@JsonIgnoreProperties({"hibernateLazyInitializer", "handler"})
public class EventLog implements Serializable {

    @Id
    @Column(name = "id")
    @GeneratedValue(strategy=GenerationType.IDENTITY)
    private int id;

    @ManyToOne
    @EqualsAndHashCode.Exclude          // Needed by Lombock in "Many To One" relathionship to avoid error
    @JoinColumn(name = "source_user_fk", referencedColumnName = "id")
    //@JsonManagedReference(value = "sourceUser")
    private User sourceUser;

    @ManyToOne
    @EqualsAndHashCode.Exclude          // Needed by Lombock in "Many To One" relathionship to avoid error
    @JoinColumn(name = "destination_user_fk", referencedColumnName = "id")
    private User destinationUser;

    @ManyToOne
    @EqualsAndHashCode.Exclude          // Needed by Lombock in "Many To One" relathionship to avoid error
    @JoinColumn(name = "source_wallet_fk", referencedColumnName = "id")
    private Wallet sourceWallet;

    @ManyToOne
    @EqualsAndHashCode.Exclude          // Needed by Lombock in "Many To One" relathionship to avoid error
    @JoinColumn(name = "destination_wallet_fk", referencedColumnName = "id")
    private Wallet destinationWallet;

    @Column(name = "notes")
    private String notes;

    @Column(name = "timestamp")
    private LocalDateTime timestamp;

    @ManyToOne
    @EqualsAndHashCode.Exclude          // Needed by Lombock in "Many To One" relathionship to avoid error
    @JoinColumn(name = "log_type_fk", referencedColumnName = "id")
    //@Column(name = "log_type_fk")
    private LogType logType;
}
</code>```

As you can see it contains this LogType field:

```<code>@ManyToOne
@EqualsAndHashCode.Exclude          // Needed by Lombock in "Many To One" relathionship to avoid error
@JoinColumn(name = "log_type_fk", referencedColumnName = "id")
private LogType logType;
</code>```

Then I created the following repository interface:

```<code>public interface LogRepository extends JpaRepository<EventLog, Integer>, JpaSpecificationExecutor {

    EventLog findById(String id);

    Page<EventLog> findByLogTypeAndTimestampBetween(LogType logType, LocalDateTime fromDate, LocalDateTime toDate, Pageable pageable);

    // HERE THE PROBLEM !!!
    Page<EventLog> findByLogTypesAndTimestampBetween(List<LogType> logTypesList, LocalDateTime fromDate, LocalDateTime toDate, Pageable pageable);

    Page<EventLog> findByTimestampBetween(LocalDateTime fromDate, LocalDateTime toDate, Pageable pageable);

}
</code>```

Into this repository I have this findByLogTypeAndTimestampBetween() method retrieving a Page specifying a single LogType object as query input parameter (basically it return all the logs related to a specific type of log). It works fine.

Then I tried to create the following findByLogTypesAndTimestampBetween() method that take a lkist of LogType and have to return the logs related to all the log types in the list.

The problem is that adding this second method, running my application I obtain the following error message in my stacktrace:

```<code>Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'logRepository' defined in com.easydefi.users.repository.LogRepository defined in @EnableJpaRepositories declared on JpaRepositoriesRegistrar.EnableJpaRepositoriesConfiguration: Invocation of init method failed; nested exception is org.springframework.data.repository.query.QueryCreationException: Could not create query for public abstract org.springframework.data.domain.Page com.easydefi.users.repository.LogRepository.findByLogTypesAndTimestampBetween(java.util.List,java.time.LocalDateTime,java.time.LocalDateTime,org.springframework.data.domain.Pageable)! Reason: Failed to create query for method public abstract org.springframework.data.domain.Page com.easydefi.users.repository.LogRepository.findByLogTypesAndTimestampBetween(java.util.List,java.time.LocalDateTime,java.time.LocalDateTime,org.springframework.data.domain.Pageable)! No property logTypes found for type EventLog! Did you mean 'logType'?; nested exception is java.lang.IllegalArgumentException: Failed to create query for method public abstract org.springframework.data.domain.Page com.easydefi.users.repository.LogRepository.findByLogTypesAndTimestampBetween(java.util.List,java.time.LocalDateTime,java.time.LocalDateTime,org.springframework.data.domain.Pageable)! No property logTypes found for type EventLog! Did you mean 'logType'?
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1804) ~[spring-beans-5.3.12.jar:5.3.12]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:620) ~[spring-beans-5.3.12.jar:5.3.12]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542) ~[spring-beans-5.3.12.jar:5.3.12]
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) ~[spring-beans-5.3.12.jar:5.3.12]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.3.12.jar:5.3.12]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) ~[spring-beans-5.3.12.jar:5.3.12]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) ~[spring-beans-5.3.12.jar:5.3.12]
    at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:276) ~[spring-beans-5.3.12.jar:5.3.12]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1380) ~[spring-beans-5.3.12.jar:5.3.12]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1300) ~[spring-beans-5.3.12.jar:5.3.12]
    at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:887) ~[spring-beans-5.3.12.jar:5.3.12]
    at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:791) ~[spring-beans-5.3.12.jar:5.3.12]
    ... 101 common frames omitted
Caused by: org.springframework.data.repository.query.QueryCreationException: Could not create query for public abstract org.springframework.data.domain.Page com.easydefi.users.repository.LogRepository.findByLogTypesAndTimestampBetween(java.util.List,java.time.LocalDateTime,java.time.LocalDateTime,org.springframework.data.domain.Pageable)! Reason: Failed to create query for method public abstract org.springframework.data.domain.Page com.easydefi.users.repository.LogRepository.findByLogTypesAndTimestampBetween(java.util.List,java.time.LocalDateTime,java.time.LocalDateTime,org.springframework.data.domain.Pageable)! No property logTypes found for type EventLog! Did you mean 'logType'?; nested exception is java.lang.IllegalArgumentException: Failed to create query for method public abstract org.springframework.data.domain.Page com.easydefi.users.repository.LogRepository.findByLogTypesAndTimestampBetween(java.util.List,java.time.LocalDateTime,java.time.LocalDateTime,org.springframework.data.domain.Pageable)! No property logTypes found for type EventLog! Did you mean 'logType'?
    at org.springframework.data.repository.query.QueryCreationException.create(QueryCreationException.java:101) ~[spring-data-commons-2.5.6.jar:2.5.6]
    at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.lookupQuery(QueryExecutorMethodInterceptor.java:106) ~[spring-data-commons-2.5.6.jar:2.5.6]
    at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.lambda$mapMethodsToQuery$1(QueryExecutorMethodInterceptor.java:94) ~[spring-data-commons-2.5.6.jar:2.5.6]
    at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197) ~[na:na]
    at java.base/java.util.Iterator.forEachRemaining(Iterator.java:133) ~[na:na]
    at java.base/java.util.Collections$UnmodifiableCollection$1.forEachRemaining(Collections.java:1056) ~[na:na]
    at java.base/java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1801) ~[na:na]
    at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484) ~[na:na]
    at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474) ~[na:na]
    at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:913) ~[na:na]
    at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) ~[na:na]
    at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:682) ~[na:na]
    at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.mapMethodsToQuery(QueryExecutorMethodInterceptor.java:96) ~[spring-data-commons-2.5.6.jar:2.5.6]
    at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.lambda$new$0(QueryExecutorMethodInterceptor.java:86) ~[spring-data-commons-2.5.6.jar:2.5.6]
    at java.base/java.util.Optional.map(Optional.java:260) ~[na:na]
    at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.<init>(QueryExecutorMethodInterceptor.java:86) ~[spring-data-commons-2.5.6.jar:2.5.6]
    at org.springframework.data.repository.core.support.RepositoryFactorySupport.getRepository(RepositoryFactorySupport.java:360) ~[spring-data-commons-2.5.6.jar:2.5.6]
    at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.lambda$afterPropertiesSet$5(RepositoryFactoryBeanSupport.java:323) ~[spring-data-commons-2.5.6.jar:2.5.6]
    at org.springframework.data.util.Lazy.getNullable(Lazy.java:230) ~[spring-data-commons-2.5.6.jar:2.5.6]
    at org.springframework.data.util.Lazy.get(Lazy.java:114) ~[spring-data-commons-2.5.6.jar:2.5.6]
    at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.afterPropertiesSet(RepositoryFactoryBeanSupport.java:329) ~[spring-data-commons-2.5.6.jar:2.5.6]
    at org.springframework.data.jpa.repository.support.JpaRepositoryFactoryBean.afterPropertiesSet(JpaRepositoryFactoryBean.java:144) ~[spring-data-jpa-2.5.6.jar:2.5.6]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1863) ~[spring-beans-5.3.12.jar:5.3.12]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1800) ~[spring-beans-5.3.12.jar:5.3.12]
    ... 112 common frames omitted
Caused by: java.lang.IllegalArgumentException: Failed to create query for method public abstract org.springframework.data.domain.Page com.easydefi.users.repository.LogRepository.findByLogTypesAndTimestampBetween(java.util.List,java.time.LocalDateTime,java.time.LocalDateTime,org.springframework.data.domain.Pageable)! No property logTypes found for type EventLog! Did you mean 'logType'?
    at org.springframework.data.jpa.repository.query.PartTreeJpaQuery.<init>(PartTreeJpaQuery.java:96) ~[spring-data-jpa-2.5.6.jar:2.5.6]
    at org.springframework.data.jpa.repository.query.JpaQueryLookupStrategy$CreateQueryLookupStrategy.resolveQuery(JpaQueryLookupStrategy.java:113) ~[spring-data-jpa-2.5.6.jar:2.5.6]
    at org.springframework.data.jpa.repository.query.JpaQueryLookupStrategy$CreateIfNotFoundQueryLookupStrategy.resolveQuery(JpaQueryLookupStrategy.java:254) ~[spring-data-jpa-2.5.6.jar:2.5.6]
    at org.springframework.data.jpa.repository.query.JpaQueryLookupStrategy$AbstractQueryLookupStrategy.resolveQuery(JpaQueryLookupStrategy.java:87) ~[spring-data-jpa-2.5.6.jar:2.5.6]
    at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.lookupQuery(QueryExecutorMethodInterceptor.java:102) ~[spring-data-commons-2.5.6.jar:2.5.6]
    ... 134 common frames omitted
Caused by: org.springframework.data.mapping.PropertyReferenceException: No property logTypes found for type EventLog! Did you mean 'logType'?
    at org.springframework.data.mapping.PropertyPath.<init>(PropertyPath.java:90) ~[spring-data-commons-2.5.6.jar:2.5.6]
    at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:437) ~[spring-data-commons-2.5.6.jar:2.5.6]
    at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:413) ~[spring-data-commons-2.5.6.jar:2.5.6]
    at org.springframework.data.mapping.PropertyPath.lambda$from$0(PropertyPath.java:366) ~[spring-data-commons-2.5.6.jar:2.5.6]
    at java.base/java.util.concurrent.ConcurrentMap.computeIfAbsent(ConcurrentMap.java:330) ~[na:na]
    at org.springframework.data.mapping.PropertyPath.from(PropertyPath.java:348) ~[spring-data-commons-2.5.6.jar:2.5.6]
    at org.springframework.data.mapping.PropertyPath.from(PropertyPath.java:331) ~[spring-data-commons-2.5.6.jar:2.5.6]
    at org.springframework.data.repository.query.parser.Part.<init>(Part.java:81) ~[spring-data-commons-2.5.6.jar:2.5.6]
    at org.springframework.data.repository.query.parser.PartTree$OrPart.lambda$new$0(PartTree.java:249) ~[spring-data-commons-2.5.6.jar:2.5.6]
    at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197) ~[na:na]
    at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:179) ~[na:na]
    at java.base/java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:948) ~[na:na]
    at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484) ~[na:na]
    at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474) ~[na:na]
    at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:913) ~[na:na]
    at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) ~[na:na]
    at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:682) ~[na:na]
    at org.springframework.data.repository.query.parser.PartTree$OrPart.<init>(PartTree.java:250) ~[spring-data-commons-2.5.6.jar:2.5.6]
    at org.springframework.data.repository.query.parser.PartTree$Predicate.lambda$new$0(PartTree.java:383) ~[spring-data-commons-2.5.6.jar:2.5.6]
    at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197) ~[na:na]
    at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:179) ~[na:na]
    at java.base/java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:948) ~[na:na]
    at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484) ~[na:na]
    at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474) ~[na:na]
    at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:913) ~[na:na]
    at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) ~[na:na]
    at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:682) ~[na:na]
    at org.springframework.data.repository.query.parser.PartTree$Predicate.<init>(PartTree.java:384) ~[spring-data-commons-2.5.6.jar:2.5.6]
    at org.springframework.data.repository.query.parser.PartTree.<init>(PartTree.java:95) ~[spring-data-commons-2.5.6.jar:2.5.6]
    at org.springframework.data.jpa.repository.query.PartTreeJpaQuery.<init>(PartTreeJpaQuery.java:89) ~[spring-data-jpa-2.5.6.jar:2.5.6]
    ... 138 common frames omitted
</code>```

What is wrong? What am I missing? How can I correctly define a repository method retrieving all the EventLog objects related to all the object into the List logTypesList parameter?

答:
Read the log:

```<code>No property logTypes found for type EventLog! Did you mean 'logType'?
</code>```

and see your field's variable:

private LogType logType;
```
<p>Change</p>
```Page<EventLog> findByLogTypesAndTimestampBetween(...);
```
<p>to</p>
```Page<EventLog> findByLogTypeAndTimestampBetween(...);
```

Body:
I am working on a Spring Boot application using Spring Data JPA and I have the following problem.

I have this EventLog entity class:

@Entity
@Table(name = "log")
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@JsonIgnoreProperties({"hibernateLazyInitializer", "handler"})
public class EventLog implements Serializable {

    @Id
    @Column(name = "id")
    @GeneratedValue(strategy=GenerationType.IDENTITY)
    private int id;

    @ManyToOne
    @EqualsAndHashCode.Exclude          // Needed by Lombock in "Many To One" relathionship to avoid error
    @JoinColumn(name = "source_user_fk", referencedColumnName = "id")
    //@JsonManagedReference(value = "sourceUser")
    private User sourceUser;

    @ManyToOne
    @EqualsAndHashCode.Exclude          // Needed by Lombock in "Many To One" relathionship to avoid error
    @JoinColumn(name = "destination_user_fk", referencedColumnName = "id")
    private User destinationUser;

    @ManyToOne
    @EqualsAndHashCode.Exclude          // Needed by Lombock in "Many To One" relathionship to avoid error
    @JoinColumn(name = "source_wallet_fk", referencedColumnName = "id")
    private Wallet sourceWallet;

    @ManyToOne
    @EqualsAndHashCode.Exclude          // Needed by Lombock in "Many To One" relathionship to avoid error
    @JoinColumn(name = "destination_wallet_fk", referencedColumnName = "id")
    private Wallet destinationWallet;

    @Column(name = "notes")
    private String notes;

    @Column(name = "timestamp")
    private LocalDateTime timestamp;

    @ManyToOne
    @EqualsAndHashCode.Exclude          // Needed by Lombock in "Many To One" relathionship to avoid error
    @JoinColumn(name = "log_type_fk", referencedColumnName = "id")
    //@Column(name = "log_type_fk")
    private LogType logType;
}

As you can see it contains this LogType field:

@ManyToOne
@EqualsAndHashCode.Exclude          // Needed by Lombock in "Many To One" relathionship to avoid error
@JoinColumn(name = "log_type_fk", referencedColumnName = "id")
private LogType logType;

Then I created the following repository interface:

public interface LogRepository extends JpaRepository<EventLog, Integer>, JpaSpecificationExecutor {

    EventLog findById(String id);

    Page<EventLog> findByLogTypeAndTimestampBetween(LogType logType, LocalDateTime fromDate, LocalDateTime toDate, Pageable pageable);

    // HERE THE PROBLEM !!!
    Page<EventLog> findByLogTypesAndTimestampBetween(List<LogType> logTypesList, LocalDateTime fromDate, LocalDateTime toDate, Pageable pageable);

    Page<EventLog> findByTimestampBetween(LocalDateTime fromDate, LocalDateTime toDate, Pageable pageable);

}

Into this repository I have this findByLogTypeAndTimestampBetween() method retrieving a Page specifying a single LogType object as query input parameter (basically it return all the logs related to a specific type of log). It works fine.

Then I tried to create the following findByLogTypesAndTimestampBetween() method that take a lkist of LogType and have to return the logs related to all the log types in the list.

The problem is that adding this second method, running my application I obtain the following error message in my stacktrace:

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'logRepository' defined in com.easydefi.users.repository.LogRepository defined in @EnableJpaRepositories declared on JpaRepositoriesRegistrar.EnableJpaRepositoriesConfiguration: Invocation of init method failed; nested exception is org.springframework.data.repository.query.QueryCreationException: Could not create query for public abstract org.springframework.data.domain.Page com.easydefi.users.repository.LogRepository.findByLogTypesAndTimestampBetween(java.util.List,java.time.LocalDateTime,java.time.LocalDateTime,org.springframework.data.domain.Pageable)! Reason: Failed to create query for method public abstract org.springframework.data.domain.Page com.easydefi.users.repository.LogRepository.findByLogTypesAndTimestampBetween(java.util.List,java.time.LocalDateTime,java.time.LocalDateTime,org.springframework.data.domain.Pageable)! No property logTypes found for type EventLog! Did you mean 'logType'?; nested exception is java.lang.IllegalArgumentException: Failed to create query for method public abstract org.springframework.data.domain.Page com.easydefi.users.repository.LogRepository.findByLogTypesAndTimestampBetween(java.util.List,java.time.LocalDateTime,java.time.LocalDateTime,org.springframework.data.domain.Pageable)! No property logTypes found for type EventLog! Did you mean 'logType'?
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1804) ~[spring-beans-5.3.12.jar:5.3.12]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:620) ~[spring-beans-5.3.12.jar:5.3.12]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542) ~[spring-beans-5.3.12.jar:5.3.12]
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) ~[spring-beans-5.3.12.jar:5.3.12]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.3.12.jar:5.3.12]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) ~[spring-beans-5.3.12.jar:5.3.12]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) ~[spring-beans-5.3.12.jar:5.3.12]
    at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:276) ~[spring-beans-5.3.12.jar:5.3.12]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1380) ~[spring-beans-5.3.12.jar:5.3.12]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1300) ~[spring-beans-5.3.12.jar:5.3.12]
    at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:887) ~[spring-beans-5.3.12.jar:5.3.12]
    at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:791) ~[spring-beans-5.3.12.jar:5.3.12]
    ... 101 common frames omitted
Caused by: org.springframework.data.repository.query.QueryCreationException: Could not create query for public abstract org.springframework.data.domain.Page com.easydefi.users.repository.LogRepository.findByLogTypesAndTimestampBetween(java.util.List,java.time.LocalDateTime,java.time.LocalDateTime,org.springframework.data.domain.Pageable)! Reason: Failed to create query for method public abstract org.springframework.data.domain.Page com.easydefi.users.repository.LogRepository.findByLogTypesAndTimestampBetween(java.util.List,java.time.LocalDateTime,java.time.LocalDateTime,org.springframework.data.domain.Pageable)! No property logTypes found for type EventLog! Did you mean 'logType'?; nested exception is java.lang.IllegalArgumentException: Failed to create query for method public abstract org.springframework.data.domain.Page com.easydefi.users.repository.LogRepository.findByLogTypesAndTimestampBetween(java.util.List,java.time.LocalDateTime,java.time.LocalDateTime,org.springframework.data.domain.Pageable)! No property logTypes found for type EventLog! Did you mean 'logType'?
    at org.springframework.data.repository.query.QueryCreationException.create(QueryCreationException.java:101) ~[spring-data-commons-2.5.6.jar:2.5.6]
    at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.lookupQuery(QueryExecutorMethodInterceptor.java:106) ~[spring-data-commons-2.5.6.jar:2.5.6]
    at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.lambda$mapMethodsToQuery$1(QueryExecutorMethodInterceptor.java:94) ~[spring-data-commons-2.5.6.jar:2.5.6]
    at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197) ~[na:na]
    at java.base/java.util.Iterator.forEachRemaining(Iterator.java:133) ~[na:na]
    at java.base/java.util.Collections$UnmodifiableCollection$1.forEachRemaining(Collections.java:1056) ~[na:na]
    at java.base/java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1801) ~[na:na]
    at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484) ~[na:na]
    at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474) ~[na:na]
    at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:913) ~[na:na]
    at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) ~[na:na]
    at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:682) ~[na:na]
    at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.mapMethodsToQuery(QueryExecutorMethodInterceptor.java:96) ~[spring-data-commons-2.5.6.jar:2.5.6]
    at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.lambda$new$0(QueryExecutorMethodInterceptor.java:86) ~[spring-data-commons-2.5.6.jar:2.5.6]
    at java.base/java.util.Optional.map(Optional.java:260) ~[na:na]
    at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.<init>(QueryExecutorMethodInterceptor.java:86) ~[spring-data-commons-2.5.6.jar:2.5.6]
    at org.springframework.data.repository.core.support.RepositoryFactorySupport.getRepository(RepositoryFactorySupport.java:360) ~[spring-data-commons-2.5.6.jar:2.5.6]
    at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.lambda$afterPropertiesSet$5(RepositoryFactoryBeanSupport.java:323) ~[spring-data-commons-2.5.6.jar:2.5.6]
    at org.springframework.data.util.Lazy.getNullable(Lazy.java:230) ~[spring-data-commons-2.5.6.jar:2.5.6]
    at org.springframework.data.util.Lazy.get(Lazy.java:114) ~[spring-data-commons-2.5.6.jar:2.5.6]
    at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.afterPropertiesSet(RepositoryFactoryBeanSupport.java:329) ~[spring-data-commons-2.5.6.jar:2.5.6]
    at org.springframework.data.jpa.repository.support.JpaRepositoryFactoryBean.afterPropertiesSet(JpaRepositoryFactoryBean.java:144) ~[spring-data-jpa-2.5.6.jar:2.5.6]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1863) ~[spring-beans-5.3.12.jar:5.3.12]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1800) ~[spring-beans-5.3.12.jar:5.3.12]
    ... 112 common frames omitted
Caused by: java.lang.IllegalArgumentException: Failed to create query for method public abstract org.springframework.data.domain.Page com.easydefi.users.repository.LogRepository.findByLogTypesAndTimestampBetween(java.util.List,java.time.LocalDateTime,java.time.LocalDateTime,org.springframework.data.domain.Pageable)! No property logTypes found for type EventLog! Did you mean 'logType'?
    at org.springframework.data.jpa.repository.query.PartTreeJpaQuery.<init>(PartTreeJpaQuery.java:96) ~[spring-data-jpa-2.5.6.jar:2.5.6]
    at org.springframework.data.jpa.repository.query.JpaQueryLookupStrategy$CreateQueryLookupStrategy.resolveQuery(JpaQueryLookupStrategy.java:113) ~[spring-data-jpa-2.5.6.jar:2.5.6]
    at org.springframework.data.jpa.repository.query.JpaQueryLookupStrategy$CreateIfNotFoundQueryLookupStrategy.resolveQuery(JpaQueryLookupStrategy.java:254) ~[spring-data-jpa-2.5.6.jar:2.5.6]
    at org.springframework.data.jpa.repository.query.JpaQueryLookupStrategy$AbstractQueryLookupStrategy.resolveQuery(JpaQueryLookupStrategy.java:87) ~[spring-data-jpa-2.5.6.jar:2.5.6]
    at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.lookupQuery(QueryExecutorMethodInterceptor.java:102) ~[spring-data-commons-2.5.6.jar:2.5.6]
    ... 134 common frames omitted
Caused by: org.springframework.data.mapping.PropertyReferenceException: No property logTypes found for type EventLog! Did you mean 'logType'?
    at org.springframework.data.mapping.PropertyPath.<init>(PropertyPath.java:90) ~[spring-data-commons-2.5.6.jar:2.5.6]
    at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:437) ~[spring-data-commons-2.5.6.jar:2.5.6]
    at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:413) ~[spring-data-commons-2.5.6.jar:2.5.6]
    at org.springframework.data.mapping.PropertyPath.lambda$from$0(PropertyPath.java:366) ~[spring-data-commons-2.5.6.jar:2.5.6]
    at java.base/java.util.concurrent.ConcurrentMap.computeIfAbsent(ConcurrentMap.java:330) ~[na:na]
    at org.springframework.data.mapping.PropertyPath.from(PropertyPath.java:348) ~[spring-data-commons-2.5.6.jar:2.5.6]
    at org.springframework.data.mapping.PropertyPath.from(PropertyPath.java:331) ~[spring-data-commons-2.5.6.jar:2.5.6]
    at org.springframework.data.repository.query.parser.Part.<init>(Part.java:81) ~[spring-data-commons-2.5.6.jar:2.5.6]
    at org.springframework.data.repository.query.parser.PartTree$OrPart.lambda$new$0(PartTree.java:249) ~[spring-data-commons-2.5.6.jar:2.5.6]
    at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197) ~[na:na]
    at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:179) ~[na:na]
    at java.base/java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:948) ~[na:na]
    at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484) ~[na:na]
    at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474) ~[na:na]
    at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:913) ~[na:na]
    at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) ~[na:na]
    at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:682) ~[na:na]
    at org.springframework.data.repository.query.parser.PartTree$OrPart.<init>(PartTree.java:250) ~[spring-data-commons-2.5.6.jar:2.5.6]
    at org.springframework.data.repository.query.parser.PartTree$Predicate.lambda$new$0(PartTree.java:383) ~[spring-data-commons-2.5.6.jar:2.5.6]
    at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197) ~[na:na]
    at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:179) ~[na:na]
    at java.base/java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:948) ~[na:na]
    at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484) ~[na:na]
    at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474) ~[na:na]
    at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:913) ~[na:na]
    at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) ~[na:na]
    at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:682) ~[na:na]
    at org.springframework.data.repository.query.parser.PartTree$Predicate.<init>(PartTree.java:384) ~[spring-data-commons-2.5.6.jar:2.5.6]
    at org.springframework.data.repository.query.parser.PartTree.<init>(PartTree.java:95) ~[spring-data-commons-2.5.6.jar:2.5.6]
    at org.springframework.data.jpa.repository.query.PartTreeJpaQuery.<init>(PartTreeJpaQuery.java:89) ~[spring-data-jpa-2.5.6.jar:2.5.6]
    ... 138 common frames omitted

What is wrong? What am I missing? How can I correctly define a repository method retrieving all the EventLog objects related to all the object into the List logTypesList parameter?

Body:
Read the log:

No property logTypes found for type EventLog! Did you mean 'logType'?

and see your field's variable:

private LogType logType;

Change

Page<EventLog> findByLogTypesAndTimestampBetween(...);

to

Page<EventLog> findByLogTypeAndTimestampBetween(...);


来源: stackexchange

问:
group an array into subarrays in a project stage
I want to split the following array according to the group-value. I know I can do this using $unwind and $group. Is there any way to this in a single $project-stage?

Input

```<code>{
    "_id": 1,
    "some_field": "some_value",
    "array": [
        {
            "group": "a",
            "subgroup": "aa",
            "value": 1
        },
        {
            "group": "b",
            "subgroup": "bb",
            "value": 2
        },
        {
            "group": "a",
            "subgroup": "ab",
            "value": 2
        }
    ]
}
</code>```

desired output:

```<code>{
    "_id": 1,
    "some_field": "some_value",
    "array": [
        {
            "group": "a",
            "values": [
                {
                    "subgroup": "aa",
                    "value": 1
                },
                {
                    "subgroup": "ab",
                    "value": 2
                }
            ]
        },
        {
            "group": "b",
            "values": [
                {
                    "subgroup": "bb",
                    "value": 2
                }
            ]
        }
    ]
}
</code>```

答:
This is far from a single project stage, but it does produce the desired output from the given input.

db.collection.aggregate([
{'$match': {'_id': 1}},
 {'$unwind': '$array'},
 {'$project': {'array': {'group': '$array.group', 'values': '$array'},
   'some_field': 1,
   'my_id': '$_id'}},
 {'$unset': 'array.values.group'},
 {'$group': {'_id': '$array.group',
   'values': {'$push': '$array.values'},
   'some_field': {'$first': '$some_field'},
   'my_id': {'$first': '$my_id'}}},
 {'$set': {'array': {'group': '$_id', 'values': '$values'}}},
 {'$unset': 'values'},
 {'$group': {'_id': '$my_id',
   'array': {'$push': '$array'},
   'some_field': {'$first': '$some_field'}}}
])
```

Try it on mongoplayground.net.

ContentLicense: CC BY-SA 4.0

Body:
I want to split the following array according to the group-value. I know I can do this using $unwind and $group. Is there any way to this in a single $project-stage?

Input

{
    "_id": 1,
    "some_field": "some_value",
    "array": [
        {
            "group": "a",
            "subgroup": "aa",
            "value": 1
        },
        {
            "group": "b",
            "subgroup": "bb",
            "value": 2
        },
        {
            "group": "a",
            "subgroup": "ab",
            "value": 2
        }
    ]
}

desired output:

{
    "_id": 1,
    "some_field": "some_value",
    "array": [
        {
            "group": "a",
            "values": [
                {
                    "subgroup": "aa",
                    "value": 1
                },
                {
                    "subgroup": "ab",
                    "value": 2
                }
            ]
        },
        {
            "group": "b",
            "values": [
                {
                    "subgroup": "bb",
                    "value": 2
                }
            ]
        }
    ]
}

Body:
This is far from a single project stage, but it does produce the desired output from the given input.

db.collection.aggregate([
{'$match': {'_id': 1}},
 {'$unwind': '$array'},
 {'$project': {'array': {'group': '$array.group', 'values': '$array'},
   'some_field': 1,
   'my_id': '$_id'}},
 {'$unset': 'array.values.group'},
 {'$group': {'_id': '$array.group',
   'values': {'$push': '$array.values'},
   'some_field': {'$first': '$some_field'},
   'my_id': {'$first': '$my_id'}}},
 {'$set': {'array': {'group': '$_id', 'values': '$values'}}},
 {'$unset': 'values'},
 {'$group': {'_id': '$my_id',
   'array': {'$push': '$array'},
   'some_field': {'$first': '$some_field'}}}
])

Try it on mongoplayground.net.


问:
R: How to repeatedly subtract specific columns from different series of columns, and output to a new dataframe?
I have a dataframe in wide format, and I want to subtract specific columns from different series of columns. Ideally I'd like the results to be in a new dataframe.

For example:
From this sample dataframe (dfOld), I would like columns A, B and C to each subtract D,  and columns E, F and G to each subtract column H. In the real dataset, this keeps going and needs to be iterated.

image of dfOld as table

Sample Data:

```<code>dfOld <- data.frame(ID = c(1,2,3,4,5,6,7,8,9,10), A = c(2, 3, 4,5,4,6,7,1,9,12), B = c(3, 4, 5,2,4,5,1,7,0,8), C = c(5, 6, 7,2,4,1,5,4,6,13), D = c(68, 7, 8,2,1,5,7,9,78,7), E = c(2, 3, 42,5,4,6,7,1,9,12), F = c(37, 4, 5,2,48,5,1,7,60,8), G = c(5, 6, 7,2,4,1,5,4,6,13), H = c(35, 7, 8,2,1,5,7,9,78,7))
</code>```

The results would ideally be in a new dataframe, with columns that have values and names for A-D, B-D, C-D, E-H, F-H, G-H, and look like this:

image of dfNew as table

In Excel, the formula would be "=B2-$E2" dragged down the rows, and across 3 columns, and then repeated again for "F2-$I2" etc, using the "$" sign to lock the column

In R, I've only been able to do this manually, kind of like the answer previously posted for a similar question (Subtracting two columns to give a new column in R)

```<code>dfOld$A-D<-(dfOld$A-dfOld$D)
dfOld$B-D<-(dfOld$B-dfOld$D)
dfOld$C-D<-(dfOld$C-dfOld$D)
dfOld$E-H<-(dfOld$E-dfOld$H)
dfOld$F-H<-(dfOld$F-dfOld$H)
dfOld$G-H<-(dfOld$G-dfOld$H)
</code>```

And then separated the new columns out into a new dataset.

However, this obviously isn't scalable for my much larger dataset, and I'd really like to learn how else to do this kind of operation that's so easy in Excel(although still not scalable for large datasets).

Part of the answer may already be here: Subtract a column in a dataframe from many columns in R
But this answer (an several other similar ones) changes the values in the same dataframe, and the columns keep the same names.
I haven't been able to adapt it so that the new values have new columns, with new names (and ideally in a new dataframe)

Another part of the answer may be here:
Iterative function to subtract columns from a specific column in a dataframe and have the values appear in a new column
These answers put the subtracted results in new columns with new names, but every column in this dataframe subtracts values of every other column (A,B,C,D,E,F,G,H each minus C). And I can't seem to adapt it so that it works over specific series of columns (A, B, C each minus D, then E, F, G each minus H, etc.)

Thanks in advance for your help.

答:
First, I create a function to do the simple calculation, where we have the dataframe, then the column names as the inputs. Then, I use purrr map2 to pass the function (which I replicate for the number of times needed, which in this case is 6). Then, I provide the list of parameters to apply that function for each column pair. Then, I use invoke to apply the function and parameter. Now, we are left with a list of dataframes (as the output is an individual column with the ID). Then, I use reduce` to combine them back into one dataframe, then update the column names.

```<code>library(tidyverse)

subtract <- function(x, a, b){
  x %>%
    mutate(!! a  := !!rlang::parse_expr(a) - !!rlang::parse_expr(b)) %>%
    dplyr::select(ID, which(colnames(x)==a))
}

col_names <- c("ID", "A-D", "B-D", "C-D", "E-H", "F-H", "G-H")

map2(
  flatten(list(rep(list(
    subtract
  ), 6))),
  list(
    expression(a = "A", b = "D"),
    expression(a = "B", b = "D"),
    expression(a = "C", b = "D"),
    expression(a = "E", b = "H"),
    expression(a = "F", b = "H"),
    expression(a = "G", b = "H")
  ),
  ~ invoke(.x, c(list(dfOld), as.list(.y)))
) %>%
  reduce(left_join, by = "ID") %>%
  set_names(col_names)
</code>```

Output

```<code>   ID A-D B-D C-D E-H F-H G-H
1   1 -66 -65 -63 -33   2 -30
2   2  -4  -3  -1  -4  -3  -1
3   3  -4  -3  -1  34  -3  -1
4   4   3   0   0   3   0   0
5   5   3   3   3   3  47   3
6   6   1   0  -4   1   0  -4
7   7   0  -6  -2   0  -6  -2
8   8  -8  -2  -5  -8  -2  -5
9   9 -69 -78 -72 -69 -18 -72
10 10   5   1   6   5   1   6
</code>```

Data

```<code>dfOld <- structure(
  list(
    ID = c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10),
    A = c(2,
          3, 4, 5, 4, 6, 7, 1, 9, 12),
    B = c(3, 4, 5, 2, 4, 5, 1, 7, 0,
          8),
    C = c(5, 6, 7, 2, 4, 1, 5, 4, 6, 13),
    D = c(68, 7, 8, 2,
          1, 5, 7, 9, 78, 7),
    E = c(2, 3, 42, 5, 4, 6, 7, 1, 9, 12),
    F = c(37,
          4, 5, 2, 48, 5, 1, 7, 60, 8),
    G = c(5, 6, 7, 2, 4, 1, 5, 4, 6,
          13),
    H = c(35, 7, 8, 2, 1, 5, 7, 9, 78, 7)
  ),
  class = "data.frame",
  row.names = c(NA,-10L)
)
</code>```

Body:
I have a dataframe in wide format, and I want to subtract specific columns from different series of columns. Ideally I'd like the results to be in a new dataframe.

For example:
From this sample dataframe (dfOld), I would like columns A, B and C to each subtract D,  and columns E, F and G to each subtract column H. In the real dataset, this keeps going and needs to be iterated.

image of dfOld as table

Sample Data:

dfOld <- data.frame(ID = c(1,2,3,4,5,6,7,8,9,10), A = c(2, 3, 4,5,4,6,7,1,9,12), B = c(3, 4, 5,2,4,5,1,7,0,8), C = c(5, 6, 7,2,4,1,5,4,6,13), D = c(68, 7, 8,2,1,5,7,9,78,7), E = c(2, 3, 42,5,4,6,7,1,9,12), F = c(37, 4, 5,2,48,5,1,7,60,8), G = c(5, 6, 7,2,4,1,5,4,6,13), H = c(35, 7, 8,2,1,5,7,9,78,7))

The results would ideally be in a new dataframe, with columns that have values and names for A-D, B-D, C-D, E-H, F-H, G-H, and look like this:

image of dfNew as table

In Excel, the formula would be "=B2-$E2" dragged down the rows, and across 3 columns, and then repeated again for "F2-$I2" etc, using the "$" sign to lock the column

In R, I've only been able to do this manually, kind of like the answer previously posted for a similar question (Subtracting two columns to give a new column in R)

dfOld$A-D<-(dfOld$A-dfOld$D)
dfOld$B-D<-(dfOld$B-dfOld$D)
dfOld$C-D<-(dfOld$C-dfOld$D)
dfOld$E-H<-(dfOld$E-dfOld$H)
dfOld$F-H<-(dfOld$F-dfOld$H)
dfOld$G-H<-(dfOld$G-dfOld$H)

And then separated the new columns out into a new dataset.

However, this obviously isn't scalable for my much larger dataset, and I'd really like to learn how else to do this kind of operation that's so easy in Excel(although still not scalable for large datasets).

Part of the answer may already be here: Subtract a column in a dataframe from many columns in R
But this answer (an several other similar ones) changes the values in the same dataframe, and the columns keep the same names.
I haven't been able to adapt it so that the new values have new columns, with new names (and ideally in a new dataframe)

Another part of the answer may be here:
Iterative function to subtract columns from a specific column in a dataframe and have the values appear in a new column
These answers put the subtracted results in new columns with new names, but every column in this dataframe subtracts values of every other column (A,B,C,D,E,F,G,H each minus C). And I can't seem to adapt it so that it works over specific series of columns (A, B, C each minus D, then E, F, G each minus H, etc.)

Thanks in advance for your help.

Body:
First, I create a function to do the simple calculation, where we have the dataframe, then the column names as the inputs. Then, I use purrr map2 to pass the function (which I replicate for the number of times needed, which in this case is 6). Then, I provide the list of parameters to apply that function for each column pair. Then, I use invoke to apply the function and parameter. Now, we are left with a list of dataframes (as the output is an individual column with the ID). Then, I use reduce` to combine them back into one dataframe, then update the column names.

library(tidyverse)

subtract <- function(x, a, b){
  x %>%
    mutate(!! a  := !!rlang::parse_expr(a) - !!rlang::parse_expr(b)) %>%
    dplyr::select(ID, which(colnames(x)==a))
}

col_names <- c("ID", "A-D", "B-D", "C-D", "E-H", "F-H", "G-H")

map2(
  flatten(list(rep(list(
    subtract
  ), 6))),
  list(
    expression(a = "A", b = "D"),
    expression(a = "B", b = "D"),
    expression(a = "C", b = "D"),
    expression(a = "E", b = "H"),
    expression(a = "F", b = "H"),
    expression(a = "G", b = "H")
  ),
  ~ invoke(.x, c(list(dfOld), as.list(.y)))
) %>%
  reduce(left_join, by = "ID") %>%
  set_names(col_names)

Output

   ID A-D B-D C-D E-H F-H G-H
1   1 -66 -65 -63 -33   2 -30
2   2  -4  -3  -1  -4  -3  -1
3   3  -4  -3  -1  34  -3  -1
4   4   3   0   0   3   0   0
5   5   3   3   3   3  47   3
6   6   1   0  -4   1   0  -4
7   7   0  -6  -2   0  -6  -2
8   8  -8  -2  -5  -8  -2  -5
9   9 -69 -78 -72 -69 -18 -72
10 10   5   1   6   5   1   6

Data

dfOld <- structure(
  list(
    ID = c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10),
    A = c(2,
          3, 4, 5, 4, 6, 7, 1, 9, 12),
    B = c(3, 4, 5, 2, 4, 5, 1, 7, 0,
          8),
    C = c(5, 6, 7, 2, 4, 1, 5, 4, 6, 13),
    D = c(68, 7, 8, 2,
          1, 5, 7, 9, 78, 7),
    E = c(2, 3, 42, 5, 4, 6, 7, 1, 9, 12),
    F = c(37,
          4, 5, 2, 48, 5, 1, 7, 60, 8),
    G = c(5, 6, 7, 2, 4, 1, 5, 4, 6,
          13),
    H = c(35, 7, 8, 2, 1, 5, 7, 9, 78, 7)
  ),
  class = "data.frame",
  row.names = c(NA,-10L)
)


问:
Jetpack Compose: Text remains black when the theme is dark despite using approved solution from analogous question
There is an analogous question to mine already on StackOverflow. It has a comprehensive, accepted answer that I thought would help me in what seems like a trivial problem.

I have a composable consisting of a Text composable. It is called PickerLabel as it is a part of a larger picker component:

@Composable
private fun PickerLabel(
    text: String,
    modifier: Modifier
) {
    Text(
        text = text,
        fontSize = 64.sp,
        modifier = modifier
            .pointerInput(Unit) {
                detectTapGestures { }
            }
    )
}
```
<p>It is used like this (it feels like nothing in its <code>modifier</code> can be impacting the text color):</p>
<pre class="lang-kotlin prettyprint-override"><code>PickerLabel(
    text = \* stringText *\,
    modifier = Modifier
        .align(Alignment.Center)
        .alpha(\* stringText *\)
)
</code>```

One last useful thing to see from my code would be the Theme.kt:

```<code>private val LightColorPalette = lightColors(
    primary = Jacarta,
    primaryVariant = BlueZodiac,
    secondary = ButterflyBush,
    secondaryVariant = Victoria,
    onPrimary = White,
    onSecondary = White,
    onSurface = White
)

private val DarkColorPalette = darkColors(
    primary = Jacarta,
    primaryVariant = BlueZodiac,
    secondary = ButterflyBush,
    secondaryVariant = Victoria,
    onPrimary = White,
    onSecondary = White,
    onSurface = White
)

@Composable
fun AppTheme(darkTheme: Boolean = isSystemInDarkTheme(), content: @Composable () -> Unit) {
    CompositionLocalProvider(LocalSpace provides Space()) {
        MaterialTheme(
            colors = if (darkTheme) DarkColorPalette else LightColorPalette,
            typography = Typography,
            shapes = Shapes,
            content = content
        )
    }
}
</code>```

With that setup in dark mode the PickerLabel is composed as such:

while it should look like this (it looks like this only in light mode):

Now, according to the answer to the previously mentioned question, I tried the following:

Adding a Surface as a parent container (the onSurface color was specified as White in Theme.kt):

setContent {
    AppTheme {
        Surface {
            ScreenContent()
        }
    }
}
```
<ol start="2">
<li>Using the <code>color</code> parameter in the <code>Text</code> composable:</li>
</ol>
<pre class="lang-kotlin prettyprint-override"><code>@Composable
private fun PickerLabel(
    text: String,
    modifier: Modifier
) {
    Text(
        text = text,
        color = White,
        fontSize = 64.sp,
        modifier = modifier
            .pointerInput(Unit) {
                detectTapGestures { }
            }
    )
}
</code>```

Using the style parameter in the Text composable:

@Composable
private fun PickerLabel(
    text: String,
    modifier: Modifier
) {
    Text(
        text = text,
        style = LocalTextStyle.current.copy(color = White),
        fontSize = 64.sp,
        modifier = modifier
            .pointerInput(Unit) {
                detectTapGestures { }
            }
    )
}
```
<ol start="4">
<li>Using a custom <code>LocalContentColor</code> to override the default <code>Black</code> color:</li>
</ol>
<pre class="lang-kotlin prettyprint-override"><code>setContent {
    AppTheme {
        CompositionLocalProvider(
            LocalContentColor provides White
        ) {
            ScreenContent()
        }
    }
}
</code>```

NONE of these solutions worked for me - each time I've tried them the Text color remained black no matter what.

Maybe there is a different factor deciding about the Text color that the mentioned answers didn't recognize. Or maybe I've made a mistake that can be spotted here in my code. Either way, if You have the slightest idea about what might be going on, please help.

Edit: changed the Theme.kt to include the check for system theme, to decide which color palette to use.

答:
Maybe this could be a different solution :D Using MaterialTheme

```<code>**Method**
@Composable
private fun PickerLabel(
    text: String,
    modifier: Modifier = Modifier
) {
    Text(
        text = text,
//you can use body1, h5, h4, caption etc for your typography
        style = MaterialTheme.typography.caption.copy(fontSize = 64.sp),
        modifier = modifier.pointerInput(Unit) {
                detectTapGestures { }
        }
    )
}

**Preview**
@Preview(showBackground = true)
@Composable
fun DefaultPreview() {
    AppTheme {
        Surface {
            Column {
                PickerLabel("12:53")
            }
        }
    }
}

@Preview(showBackground = true, uiMode = Configuration.UI_MODE_NIGHT_YES)
@Composable
fun DefaultDarkPreview() {
    AppTheme {
        Surface {
            Column {
                PickerLabel("12:53")
            }
        }
    }
}
</code>```

**Result here :D **
Dark and light mode text

Body:
There is an analogous question to mine already on StackOverflow. It has a comprehensive, accepted answer that I thought would help me in what seems like a trivial problem.

I have a composable consisting of a Text composable. It is called PickerLabel as it is a part of a larger picker component:

@Composable
private fun PickerLabel(
    text: String,
    modifier: Modifier
) {
    Text(
        text = text,
        fontSize = 64.sp,
        modifier = modifier
            .pointerInput(Unit) {
                detectTapGestures { }
            }
    )
}

It is used like this (it feels like nothing in its modifier can be impacting the text color):

PickerLabel(
    text = \* stringText *\,
    modifier = Modifier
        .align(Alignment.Center)
        .alpha(\* stringText *\)
)

One last useful thing to see from my code would be the Theme.kt:

private val LightColorPalette = lightColors(
    primary = Jacarta,
    primaryVariant = BlueZodiac,
    secondary = ButterflyBush,
    secondaryVariant = Victoria,
    onPrimary = White,
    onSecondary = White,
    onSurface = White
)

private val DarkColorPalette = darkColors(
    primary = Jacarta,
    primaryVariant = BlueZodiac,
    secondary = ButterflyBush,
    secondaryVariant = Victoria,
    onPrimary = White,
    onSecondary = White,
    onSurface = White
)

@Composable
fun AppTheme(darkTheme: Boolean = isSystemInDarkTheme(), content: @Composable () -> Unit) {
    CompositionLocalProvider(LocalSpace provides Space()) {
        MaterialTheme(
            colors = if (darkTheme) DarkColorPalette else LightColorPalette,
            typography = Typography,
            shapes = Shapes,
            content = content
        )
    }
}

With that setup in dark mode the PickerLabel is composed as such:

while it should look like this (it looks like this only in light mode):

Now, according to the answer to the previously mentioned question, I tried the following:

Adding a Surface as a parent container (the onSurface color was specified as White in Theme.kt):

setContent {
    AppTheme {
        Surface {
            ScreenContent()
        }
    }
}

Using the color parameter in the Text composable:

@Composable
private fun PickerLabel(
    text: String,
    modifier: Modifier
) {
    Text(
        text = text,
        color = White,
        fontSize = 64.sp,
        modifier = modifier
            .pointerInput(Unit) {
                detectTapGestures { }
            }
    )
}

Using the style parameter in the Text composable:

@Composable
private fun PickerLabel(
    text: String,
    modifier: Modifier
) {
    Text(
        text = text,
        style = LocalTextStyle.current.copy(color = White),
        fontSize = 64.sp,
        modifier = modifier
            .pointerInput(Unit) {
                detectTapGestures { }
            }
    )
}

Using a custom LocalContentColor to override the default Black color:

setContent {
    AppTheme {
        CompositionLocalProvider(
            LocalContentColor provides White
        ) {
            ScreenContent()
        }
    }
}

NONE of these solutions worked for me - each time I've tried them the Text color remained black no matter what.

Maybe there is a different factor deciding about the Text color that the mentioned answers didn't recognize. Or maybe I've made a mistake that can be spotted here in my code. Either way, if You have the slightest idea about what might be going on, please help.

Edit: changed the Theme.kt to include the check for system theme, to decide which color palette to use.

Body:
Maybe this could be a different solution :D Using MaterialTheme

**Method**
@Composable
private fun PickerLabel(
    text: String,
    modifier: Modifier = Modifier
) {
    Text(
        text = text,
//you can use body1, h5, h4, caption etc for your typography
        style = MaterialTheme.typography.caption.copy(fontSize = 64.sp),
        modifier = modifier.pointerInput(Unit) {
                detectTapGestures { }
        }
    )
}

**Preview**
@Preview(showBackground = true)
@Composable
fun DefaultPreview() {
    AppTheme {
        Surface {
            Column {
                PickerLabel("12:53")
            }
        }
    }
}

@Preview(showBackground = true, uiMode = Configuration.UI_MODE_NIGHT_YES)
@Composable
fun DefaultDarkPreview() {
    AppTheme {
        Surface {
            Column {
                PickerLabel("12:53")
            }
        }
    }
}

**Result here :D **
Dark and light mode text


问:
How to curl in Python with header, data?
I'm trying replace the following curl command by a Python script:

curl --request POST \
 --url https://xx.com/login \
 --header 'Content-Type: application/json' \
 --data '{
"email": "user@domain.com",
"password": "PASSWORD"
}'
```
<p>Script that I tried:</p>
```import urllib.request
import json

body = {"email": "xxx@xx.com","password": "xxx"}
myurl = "https://xx.com/login"

req = urllib.request.Request(myurl)
req.add_header('Content-Type', 'application/json; charset=utf-8')
jsondata = json.dumps(body)
jsondataasbytes = jsondata.encode('utf-8')   # needs to be bytes
req.add_header('Content-Length', len(jsondataasbytes))
response = urllib.request.urlopen(req, jsondataasbytes)
```

When I tried to run this script, it doesn't return me anything and show processed completed. Is my code logic correct? Or there is something wrong with my code?

答:
you can simply just use requests:

```<code>import requests

headers = {
    'Content-Type': 'application/json',
}

data = '{\n"email": "user@domain.com",\n"password": "PASSWORD"\n}'

response = requests.post('https://xx.com/login', headers=headers, data=data)
</code>```

Body:
I'm trying replace the following curl command by a Python script:

curl --request POST \
 --url https://xx.com/login \
 --header 'Content-Type: application/json' \
 --data '{
"email": "user@domain.com",
"password": "PASSWORD"
}'

Script that I tried:

import urllib.request
import json

body = {"email": "xxx@xx.com","password": "xxx"}
myurl = "https://xx.com/login"

req = urllib.request.Request(myurl)
req.add_header('Content-Type', 'application/json; charset=utf-8')
jsondata = json.dumps(body)
jsondataasbytes = jsondata.encode('utf-8')   # needs to be bytes
req.add_header('Content-Length', len(jsondataasbytes))
response = urllib.request.urlopen(req, jsondataasbytes)

When I tried to run this script, it doesn't return me anything and show processed completed. Is my code logic correct? Or there is something wrong with my code?

Body:
you can simply just use requests:

import requests

headers = {
    'Content-Type': 'application/json',
}

data = '{\n"email": "user@domain.com",\n"password": "PASSWORD"\n}'

response = requests.post('https://xx.com/login', headers=headers, data=data)


问:
Issue with babel-jest dependency when running npm start in a React app
All I am doing is running create-react-app and cd'ing into the app, then trying to run npm/yarn start. I get the following error/output/log. I have walked through all of the suggested steps. The only thing that works is the SKIP_PREFLIGHT_CHECK=true in my .env as the last resort for both
Yarn and npm. I have recently updated to Mojave and had to reinstall my Xcode if people have had a similar experience.

```<code>Last login: Tue Oct 30 16:30:24 on ttys002
TheLAB11:~ jasonspiller$ cd repos/react-express-graphql-app/
TheLAB11:react-express-graphql-app jasonspiller$ npm start

> react-express-graphql-app@0.1.0 start /Users/jasonspiller/repos/react-express-graphql-app
> react-scripts start

There might be a problem with the project dependency tree.
It is likely not a bug in Create React App, but something you need to fix locally.

The react-scripts package provided by Create React App requires a dependency:

  "babel-jest": "23.6.0"

Don't try to install it manually: your package manager does it automatically.
However, a different version of babel-jest was detected higher up in the tree:

  /Users/jasonspiller/node_modules/babel-jest (version: 23.4.2)

Manually installing incompatible versions is known to cause hard-to-debug issues.

If prefer to ignore this check, add SKIP_PREFLIGHT_CHECK=true to an .env file in your project.
That will permanently disable this message but you might encounter other issues.

To fix the dependency tree, try following the steps below in the exact order:

  1. Delete package-lock.json (not package.json!) and/or yarn.lock in your project folder.
  2. Delete node_modules in your project folder.
  3. Remove "babel-jest" from dependencies and/or devDependencies in the package.json file in your project folder.
  4. Run npm install or yarn, depending on the package manager you use.

In most cases, this should be enough to fix the problem.
If this has not helped, there are a few other things you can try:

  5. If you used npm, install yarn (http://yarnpkg.com/) and repeat the above steps with it instead.
     This may help because npm has known issues with package hoisting which may get resolved in future versions.

  6. Check if /Users/jasonspiller/node_modules/babel-jest is outside your project directory.
     For example, you might have accidentally installed something in your home folder.

  7. Try running npm ls babel-jest in your project folder.
     This will tell you which other package (apart from the expected react-scripts) installed babel-jest.

If nothing else helps, add SKIP_PREFLIGHT_CHECK=true to an .env file in your project.
That would permanently disable this preflight check in case you want to proceed anyway.

P.S. We know this message is long but please read the steps above :-) We hope you find them helpful!

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! react-express-graphql-app@0.1.0 start: `react-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the react-express-graphql-app@0.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/jasonspiller/.npm/_logs/2018-10-30T23_09_42_358Z-debug.log
</code>```

答: my issue was that I have both frontend and backend that I am running concurrently. I installed jest to my root project (for backend) and I guess there is collision with pre-installed react jest. I just uninstalled jest from backend and voila I am happy now. I don't have anything related with babel.

Body:
All I am doing is running create-react-app and cd'ing into the app, then trying to run npm/yarn start. I get the following error/output/log. I have walked through all of the suggested steps. The only thing that works is the SKIP_PREFLIGHT_CHECK=true in my .env as the last resort for both
Yarn and npm. I have recently updated to Mojave and had to reinstall my Xcode if people have had a similar experience.

Last login: Tue Oct 30 16:30:24 on ttys002
TheLAB11:~ jasonspiller$ cd repos/react-express-graphql-app/
TheLAB11:react-express-graphql-app jasonspiller$ npm start

> react-express-graphql-app@0.1.0 start /Users/jasonspiller/repos/react-express-graphql-app
> react-scripts start

There might be a problem with the project dependency tree.
It is likely not a bug in Create React App, but something you need to fix locally.

The react-scripts package provided by Create React App requires a dependency:

  "babel-jest": "23.6.0"

Don't try to install it manually: your package manager does it automatically.
However, a different version of babel-jest was detected higher up in the tree:

  /Users/jasonspiller/node_modules/babel-jest (version: 23.4.2)

Manually installing incompatible versions is known to cause hard-to-debug issues.

If prefer to ignore this check, add SKIP_PREFLIGHT_CHECK=true to an .env file in your project.
That will permanently disable this message but you might encounter other issues.

To fix the dependency tree, try following the steps below in the exact order:

  1. Delete package-lock.json (not package.json!) and/or yarn.lock in your project folder.
  2. Delete node_modules in your project folder.
  3. Remove "babel-jest" from dependencies and/or devDependencies in the package.json file in your project folder.
  4. Run npm install or yarn, depending on the package manager you use.

In most cases, this should be enough to fix the problem.
If this has not helped, there are a few other things you can try:

  5. If you used npm, install yarn (http://yarnpkg.com/) and repeat the above steps with it instead.
     This may help because npm has known issues with package hoisting which may get resolved in future versions.

  6. Check if /Users/jasonspiller/node_modules/babel-jest is outside your project directory.
     For example, you might have accidentally installed something in your home folder.

  7. Try running npm ls babel-jest in your project folder.
     This will tell you which other package (apart from the expected react-scripts) installed babel-jest.

If nothing else helps, add SKIP_PREFLIGHT_CHECK=true to an .env file in your project.
That would permanently disable this preflight check in case you want to proceed anyway.

P.S. We know this message is long but please read the steps above :-) We hope you find them helpful!

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! react-express-graphql-app@0.1.0 start: `react-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the react-express-graphql-app@0.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/jasonspiller/.npm/_logs/2018-10-30T23_09_42_358Z-debug.log


问:
Can we use Morris traversal for postorder?
I have visited many websites but couldnt find any algorithm for Morris postOrder traversal.
I know that we can use Morris algorithm for preOrder and inOrder.It will be of great help if someone points me to the postOrder Morris algorithm, if it exists.</p>

答:
Morris Traversal
T(n) = O(n) S(n) = O(1)

Video link - https://www.youtube.com/watch?v=80Zug6D1_r4

Question link - https://leetcode.com/problems/binary-tree-postorder-traversal/

We will modify the preorder Morris traversal from root->left->right to root->right->left. For this we need to do one more change. While in normal preorder and inorder, we were creating thread from right most node of left subtree to present node, here we will create thread from left most node of right subtree to present node as here we have to cover right subtree before left subtree

```<code>        class Solution {
        public:
        vector<int> postorderTraversal(TreeNode* root) {
            vector<int> ans;
            while(root)
            {
                TreeNode *curr = root;//We will create thread from left most node of right subtree to present node and will travell to that node using curr

                if(curr->right)//if root has right child
                            //We can't push directly this root node val to ans as we are not sure whether we are here
                            //thorough thread link after covering right subtree or we are here for the first time
                {
                    curr = curr->right;
                    while(curr->left && curr->left != root)//go to left most node of right subtree
                        curr=curr->left;
                    if(curr->left != root)//not threaded yet
                    {
                        ans.push_back(root->val);//it means root was visited for first time and this is modified preorder hence
                                                //push this node's val to ans
                        curr->left = root;//create the thread
                        root = root->right;//go to right to cover right subtree as modified preorder is root->right->left
                    }
                    else//was threaded
                    {
                        curr->left = NULL;//break the thread
                        root = root->left;//right subtree has been covered hence now cover the left one
                                            //no need to push this node value as we are here for the second time using thread
                                            //link
                    }
                }
                else//root hasn't right child
                {
                    ans.push_back(root->val);//modified preorder is root->right->left hence push this value before going to left
                    root = root->left;
                }
            }
            reverse(ans.begin(),ans.end());//reversing root->right->left to left->right->root to make it post order
            return ans;
        }
    };
</code>```

ContentLicense: CC BY-SA 3.0

Body:
Morris Traversal
T(n) = O(n) S(n) = O(1)

Video link - https://www.youtube.com/watch?v=80Zug6D1_r4

Question link - https://leetcode.com/problems/binary-tree-postorder-traversal/

We will modify the preorder Morris traversal from root->left->right to root->right->left. For this we need to do one more change. While in normal preorder and inorder, we were creating thread from right most node of left subtree to present node, here we will create thread from left most node of right subtree to present node as here we have to cover right subtree before left subtree

        class Solution {
        public:
        vector<int> postorderTraversal(TreeNode* root) {
            vector<int> ans;
            while(root)
            {
                TreeNode *curr = root;//We will create thread from left most node of right subtree to present node and will travell to that node using curr

                if(curr->right)//if root has right child
                            //We can't push directly this root node val to ans as we are not sure whether we are here
                            //thorough thread link after covering right subtree or we are here for the first time
                {
                    curr = curr->right;
                    while(curr->left && curr->left != root)//go to left most node of right subtree
                        curr=curr->left;
                    if(curr->left != root)//not threaded yet
                    {
                        ans.push_back(root->val);//it means root was visited for first time and this is modified preorder hence
                                                //push this node's val to ans
                        curr->left = root;//create the thread
                        root = root->right;//go to right to cover right subtree as modified preorder is root->right->left
                    }
                    else//was threaded
                    {
                        curr->left = NULL;//break the thread
                        root = root->left;//right subtree has been covered hence now cover the left one
                                            //no need to push this node value as we are here for the second time using thread
                                            //link
                    }
                }
                else//root hasn't right child
                {
                    ans.push_back(root->val);//modified preorder is root->right->left hence push this value before going to left
                    root = root->left;
                }
            }
            reverse(ans.begin(),ans.end());//reversing root->right->left to left->right->root to make it post order
            return ans;
        }
    };


问:
how to make application with android
I am trying to create a new android apps but it says me like this

[2011-08-18 15:27:39 - jeetu] Conversion to Dalvik format failed:
  Unable to execute dex: wrapper was not properly loaded first

What does it mean?

答:
A good tutorial to start :
http://developer.android.com/resources/tutorials/hello-world.html

For your error, Go to Project -> Clean, it will rebuilt workspace and fix the error

Title: how to make application with android


问:
What is the best lossless way to scale up a barcode image in c#
I've come across this problem many times over the years and still live in hope that there is an easy way to do this that I have missed.
I work with barcodes a lot.  They are usually made of black dots or lines on a white background.  Barcode readers generally work faster and more accurately when the edges are crisp and then size of the lines or dots are precise.

Most barcode generation algorithms will give you a compact barcode usually with the smallest element size being one pixel.  A typical QR code could fit in a 21 x 21 grid.  This would be too small to see if printed pixel to pixel on most printers and would typically be scaled up.  The result of scaling it up depends on the method used and although sometimes you are given a choice, often you have no options that make the image suitable.  Even printing directly will often give you expected gray artefacts or forms of dithering.  The most consistent way I have found is to scale the images before they are use daily in other places such as Microsoft Word, lightburn and a few others I use that still give me a headache.

Below I will go through what I have tried and show the results.  I am limiting this to bitmaps only because using vectors here is not something I need on my current project.

My current best resolution is not pretty, it is slow and although I could improve the speed by locking the bits in the bitmap, I am hoping someone has a really simple answer that I had totally missed on my search again this time.

Here is an image of a simple QR code blown up in GIMP.

The problem is, if it is scaled up, it'll often end up looking like this:

Below I created a small test program to go through all the different modes I know of and then generate a matrix of images which I have reproduced below.  The version I currently use is Mode 99 which involves inspecting each pixel and drawing a square.

Does anyone have any better ideas?

```<code>using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Media.Imaging;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;

namespace PSWpfCommon.Images
{
    public partial class WPFImageHelper
    {

        public class Test
        {
            public int smode = 0;
            public int imode = 0;
            public int mode = 0;
            public string title = "";
            public Test(int s, int i, int m, string t)
            {
                smode = s;
                imode = i;
                mode = m;
                title = t;
            }
        }

        public static Bitmap TestImage()
        {
            byte[] img =
             {
           0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A, 0x00, 0x00, 0x00, 0x0D, 0x49, 0x48, 0x44,
           0x52, 0x00, 0x00, 0x00, 0x15, 0x00, 0x00, 0x00, 0x15, 0x08, 0x06, 0x00, 0x00, 0x00, 0xA9,
           0x17, 0xA5, 0x96, 0x00, 0x00, 0x00, 0xCF, 0x49, 0x44, 0x41, 0x54, 0x38, 0xCB, 0x9D, 0x54,
           0x5B, 0x0E, 0xC3, 0x30, 0x08, 0xB3, 0xAB, 0xDC, 0xFF, 0xCA, 0xDE, 0xC7, 0xD4, 0x88, 0x7A,
           0x3C, 0xD2, 0x21, 0x55, 0xAD, 0x48, 0xA0, 0xC6, 0x80, 0x09, 0x40, 0x28, 0x4C, 0x12, 0x48,
           0xEE, 0x6F, 0x00, 0x20, 0xF9, 0xF0, 0x67, 0xB6, 0x62, 0x40, 0xB4, 0x98, 0xAC, 0x4A, 0x50,
           0xC5, 0x2D, 0x4F, 0xE2, 0x97, 0x23, 0xB2, 0xEE, 0xE7, 0x31, 0xEE, 0xC2, 0xA1, 0x75, 0x89,
           0xD3, 0xF2, 0x27, 0x73, 0x5E, 0x8F, 0x93, 0x56, 0x01, 0x53, 0xA2, 0xEC, 0x7C, 0x39, 0x2F,
           0x19, 0xCA, 0x58, 0x7A, 0xA4, 0xA0, 0x8A, 0xA3, 0x0E, 0x6A, 0x7A, 0x5B, 0xFE, 0x45, 0x12,
           0xF1, 0xF1, 0x44, 0x59, 0x73, 0xFC, 0x5E, 0x8C, 0x25, 0xF9, 0xED, 0xBE, 0xA4, 0x47, 0x49,
           0xDD, 0x18, 0x79, 0xF9, 0x25, 0xA7, 0xD9, 0xA6, 0x74, 0xE3, 0xE3, 0x48, 0x9D, 0xE3, 0x55,
           0xA1, 0x98, 0xB8, 0xCC, 0x16, 0xE4, 0xF6, 0x5F, 0xBE, 0xDF, 0x8E, 0x74, 0x42, 0x9F, 0x4D,
           0xC0, 0x0F, 0xA7, 0xFE, 0x76, 0x14, 0x5D, 0x65, 0xDB, 0x3F, 0xA9, 0x54, 0xC7, 0x9D, 0x8B,
           0xCD, 0x7D, 0x3E, 0xAA, 0xD4, 0x24, 0x77, 0x99, 0x7F, 0x54, 0xA9, 0xAA, 0x69, 0x7E, 0x3F,
           0xCE, 0xEA, 0xFA, 0x67, 0x9B, 0x3A, 0x2A, 0x24, 0x9D, 0x49, 0x9F, 0x23, 0x99, 0x64, 0x71,
           0x9D, 0xA8, 0x51, 0xC5, 0x6F, 0x36, 0x21, 0x5B, 0xF9, 0x3B, 0x95, 0xAA, 0x1A, 0x52, 0xAD,
           0xB1, 0x24, 0x7C, 0x00, 0x22, 0x8E, 0xDE, 0x4C, 0xC4, 0x8F, 0x11, 0x7F, 0x00, 0x00, 0x00,
           0x00, 0x49, 0x45, 0x4E, 0x44, 0xAE, 0x42, 0x60, 0x82,
             };

            Bitmap qr;
            using (var ms = new MemoryStream(img))
            {
                qr = new Bitmap(ms);
            }

            int factor = 4;

            var l = new List<Test>();
            for (int i = 0; i <= 7; i++)
                for (int s = 0; s <= 4; s++)
                    l.Add(new Test(s, i, 0, $"s={s} i={i}"));

            l.Add(new Test(2, 8, 99, $"Mode 99"));

            Bitmap fullimage = new Bitmap(((qr.Width * factor) + 20) * 5, ((qr.Height * factor) + 20) * 9);

            fullimage.SetResolution(72, 72);
            var font = new Font("Arial", 10);

            using (var grPhoto = Graphics.FromImage(fullimage))
            using (var blackbrush = new SolidBrush(System.Drawing.Color.Black))
            using (var whitebrush = new SolidBrush(System.Drawing.Color.White))
            {
                grPhoto.InterpolationMode = InterpolationMode.High;

                grPhoto.FillRectangle(whitebrush, 0, 0, fullimage.Width, fullimage.Height);

                foreach (var t in l)
                {
                    var newqr = GrowImage(qr, factor: 4, mode: t.mode, imode: t.imode, smode: t.smode);

                    grPhoto.DrawImage(newqr,
                        t.smode * ((qr.Width * factor) + 20),
                        t.imode * ((qr.Height * factor) + 20));
                    grPhoto.DrawString(t.title, font, blackbrush,
                        t.smode * ((qr.Width * factor) + 20),
                        (t.imode + 1) * ((qr.Height * factor) + 20) - 20);

                }
            }

            fullimage.Save(@"c:\temp\newqr.png", ImageFormat.Png);

            return null;
        }

        public static Bitmap GrowImage(Bitmap im, int factor = 4, int mode = 1, int imode = 0, int smode = 0, int border = 2)
        {
            bool translate = true;

            var bmPhoto = new Bitmap(im.Width * factor + 2 * border, im.Height * factor + border * 2, PixelFormat.Format24bppRgb);

            bmPhoto.SetResolution(72, 72);

            using (var grPhoto = Graphics.FromImage(bmPhoto))
            using (var blackbrush = new SolidBrush(System.Drawing.Color.Black))
            using (var whitebrush = new SolidBrush(System.Drawing.Color.White))
            {
                grPhoto.FillRectangle(whitebrush, 0, 0, bmPhoto.Width, bmPhoto.Height);

                switch (smode)
                {
                    case 0:
                        grPhoto.SmoothingMode = SmoothingMode.Default;
                        break;
                    case 1:
                        grPhoto.SmoothingMode = SmoothingMode.AntiAlias;
                        break;
                    case 2:
                        grPhoto.SmoothingMode = SmoothingMode.HighQuality;
                        break;
                    case 3:
                        grPhoto.SmoothingMode = SmoothingMode.HighSpeed;
                        break;
                    case 4:
                        grPhoto.SmoothingMode = SmoothingMode.None;
                        break;
                    default:
                        break;
                }
                switch (imode)
                {
                    case 0:
                        grPhoto.InterpolationMode = InterpolationMode.Default;
                        break;
                    case 1:
                        grPhoto.InterpolationMode = InterpolationMode.Bicubic;
                        break;
                    case 2:
                        grPhoto.InterpolationMode = InterpolationMode.Bilinear;
                        break;
                    case 3:
                        grPhoto.InterpolationMode = InterpolationMode.High;
                        break;
                    case 4:
                        grPhoto.InterpolationMode = InterpolationMode.HighQualityBicubic;
                        break;
                    case 5:
                        grPhoto.InterpolationMode = InterpolationMode.HighQualityBilinear;
                        break;
                    case 6:
                        grPhoto.InterpolationMode = InterpolationMode.Low;
                        break;
                    case 7:
                        grPhoto.InterpolationMode = InterpolationMode.NearestNeighbor;
                        break;
                    default:
                        break;
                }

                switch (mode)
                {
                    case 99:
                        // These are what worked best for me...
                        grPhoto.SmoothingMode = SmoothingMode.None;
                        grPhoto.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor;

                        for (int x = 0; x < im.Width; x++)
                            for (int y = 0; y < im.Height; y++)
                            {
                                var g = im.GetPixel(x, y);
                                if (g.R < 120 && g.B < 120) // Just being really lazy here... if the pixel has not much blue and not much red I'll treat it as black
                                {
                                    grPhoto.FillRectangle(blackbrush, border + factor * x, border + factor * y, factor, factor);

                                }
                            }
                        translate = false;
                        break;
                    default:
                        break;
                }

                if (translate) // If we used mode 99, don't draw the image
                    grPhoto.DrawImage(im, new System.Drawing.Rectangle(border, border, im.Width * factor, im.Height * factor), 0, 0, im.Width, im.Height, System.Drawing.GraphicsUnit.Pixel);
            }

            return bmPhoto;
        }
    }
}

</code>```

答:
You can use a library like ImageTracer.NET to convert the image to a vector image, then it'll scale as big as you need:

https://github.com/MiYanni/ImageTracer.NET

Body:
I've come across this problem many times over the years and still live in hope that there is an easy way to do this that I have missed.
I work with barcodes a lot.  They are usually made of black dots or lines on a white background.  Barcode readers generally work faster and more accurately when the edges are crisp and then size of the lines or dots are precise.

Most barcode generation algorithms will give you a compact barcode usually with the smallest element size being one pixel.  A typical QR code could fit in a 21 x 21 grid.  This would be too small to see if printed pixel to pixel on most printers and would typically be scaled up.  The result of scaling it up depends on the method used and although sometimes you are given a choice, often you have no options that make the image suitable.  Even printing directly will often give you expected gray artefacts or forms of dithering.  The most consistent way I have found is to scale the images before they are use daily in other places such as Microsoft Word, lightburn and a few others I use that still give me a headache.

Below I will go through what I have tried and show the results.  I am limiting this to bitmaps only because using vectors here is not something I need on my current project.

My current best resolution is not pretty, it is slow and although I could improve the speed by locking the bits in the bitmap, I am hoping someone has a really simple answer that I had totally missed on my search again this time.

Here is an image of a simple QR code blown up in GIMP.

The problem is, if it is scaled up, it'll often end up looking like this:

Below I created a small test program to go through all the different modes I know of and then generate a matrix of images which I have reproduced below.  The version I currently use is Mode 99 which involves inspecting each pixel and drawing a square.

Does anyone have any better ideas?

using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Media.Imaging;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;

namespace PSWpfCommon.Images
{
    public partial class WPFImageHelper
    {

        public class Test
        {
            public int smode = 0;
            public int imode = 0;
            public int mode = 0;
            public string title = "";
            public Test(int s, int i, int m, string t)
            {
                smode = s;
                imode = i;
                mode = m;
                title = t;
            }
        }

        public static Bitmap TestImage()
        {
            byte[] img =
             {
           0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A, 0x00, 0x00, 0x00, 0x0D, 0x49, 0x48, 0x44,
           0x52, 0x00, 0x00, 0x00, 0x15, 0x00, 0x00, 0x00, 0x15, 0x08, 0x06, 0x00, 0x00, 0x00, 0xA9,
           0x17, 0xA5, 0x96, 0x00, 0x00, 0x00, 0xCF, 0x49, 0x44, 0x41, 0x54, 0x38, 0xCB, 0x9D, 0x54,
           0x5B, 0x0E, 0xC3, 0x30, 0x08, 0xB3, 0xAB, 0xDC, 0xFF, 0xCA, 0xDE, 0xC7, 0xD4, 0x88, 0x7A,
           0x3C, 0xD2, 0x21, 0x55, 0xAD, 0x48, 0xA0, 0xC6, 0x80, 0x09, 0x40, 0x28, 0x4C, 0x12, 0x48,
           0xEE, 0x6F, 0x00, 0x20, 0xF9, 0xF0, 0x67, 0xB6, 0x62, 0x40, 0xB4, 0x98, 0xAC, 0x4A, 0x50,
           0xC5, 0x2D, 0x4F, 0xE2, 0x97, 0x23, 0xB2, 0xEE, 0xE7, 0x31, 0xEE, 0xC2, 0xA1, 0x75, 0x89,
           0xD3, 0xF2, 0x27, 0x73, 0x5E, 0x8F, 0x93, 0x56, 0x01, 0x53, 0xA2, 0xEC, 0x7C, 0x39, 0x2F,
           0x19, 0xCA, 0x58, 0x7A, 0xA4, 0xA0, 0x8A, 0xA3, 0x0E, 0x6A, 0x7A, 0x5B, 0xFE, 0x45, 0x12,
           0xF1, 0xF1, 0x44, 0x59, 0x73, 0xFC, 0x5E, 0x8C, 0x25, 0xF9, 0xED, 0xBE, 0xA4, 0x47, 0x49,
           0xDD, 0x18, 0x79, 0xF9, 0x25, 0xA7, 0xD9, 0xA6, 0x74, 0xE3, 0xE3, 0x48, 0x9D, 0xE3, 0x55,
           0xA1, 0x98, 0xB8, 0xCC, 0x16, 0xE4, 0xF6, 0x5F, 0xBE, 0xDF, 0x8E, 0x74, 0x42, 0x9F, 0x4D,
           0xC0, 0x0F, 0xA7, 0xFE, 0x76, 0x14, 0x5D, 0x65, 0xDB, 0x3F, 0xA9, 0x54, 0xC7, 0x9D, 0x8B,
           0xCD, 0x7D, 0x3E, 0xAA, 0xD4, 0x24, 0x77, 0x99, 0x7F, 0x54, 0xA9, 0xAA, 0x69, 0x7E, 0x3F,
           0xCE, 0xEA, 0xFA, 0x67, 0x9B, 0x3A, 0x2A, 0x24, 0x9D, 0x49, 0x9F, 0x23, 0x99, 0x64, 0x71,
           0x9D, 0xA8, 0x51, 0xC5, 0x6F, 0x36, 0x21, 0x5B, 0xF9, 0x3B, 0x95, 0xAA, 0x1A, 0x52, 0xAD,
           0xB1, 0x24, 0x7C, 0x00, 0x22, 0x8E, 0xDE, 0x4C, 0xC4, 0x8F, 0x11, 0x7F, 0x00, 0x00, 0x00,
           0x00, 0x49, 0x45, 0x4E, 0x44, 0xAE, 0x42, 0x60, 0x82,
             };

            Bitmap qr;
            using (var ms = new MemoryStream(img))
            {
                qr = new Bitmap(ms);
            }

            int factor = 4;

            var l = new List<Test>();
            for (int i = 0; i <= 7; i++)
                for (int s = 0; s <= 4; s++)
                    l.Add(new Test(s, i, 0, $"s={s} i={i}"));

            l.Add(new Test(2, 8, 99, $"Mode 99"));

            Bitmap fullimage = new Bitmap(((qr.Width * factor) + 20) * 5, ((qr.Height * factor) + 20) * 9);

            fullimage.SetResolution(72, 72);
            var font = new Font("Arial", 10);

            using (var grPhoto = Graphics.FromImage(fullimage))
            using (var blackbrush = new SolidBrush(System.Drawing.Color.Black))
            using (var whitebrush = new SolidBrush(System.Drawing.Color.White))
            {
                grPhoto.InterpolationMode = InterpolationMode.High;

                grPhoto.FillRectangle(whitebrush, 0, 0, fullimage.Width, fullimage.Height);

                foreach (var t in l)
                {
                    var newqr = GrowImage(qr, factor: 4, mode: t.mode, imode: t.imode, smode: t.smode);

                    grPhoto.DrawImage(newqr,
                        t.smode * ((qr.Width * factor) + 20),
                        t.imode * ((qr.Height * factor) + 20));
                    grPhoto.DrawString(t.title, font, blackbrush,
                        t.smode * ((qr.Width * factor) + 20),
                        (t.imode + 1) * ((qr.Height * factor) + 20) - 20);

                }
            }

            fullimage.Save(@"c:\temp\newqr.png", ImageFormat.Png);

            return null;
        }

        public static Bitmap GrowImage(Bitmap im, int factor = 4, int mode = 1, int imode = 0, int smode = 0, int border = 2)
        {
            bool translate = true;

            var bmPhoto = new Bitmap(im.Width * factor + 2 * border, im.Height * factor + border * 2, PixelFormat.Format24bppRgb);

            bmPhoto.SetResolution(72, 72);

            using (var grPhoto = Graphics.FromImage(bmPhoto))
            using (var blackbrush = new SolidBrush(System.Drawing.Color.Black))
            using (var whitebrush = new SolidBrush(System.Drawing.Color.White))
            {
                grPhoto.FillRectangle(whitebrush, 0, 0, bmPhoto.Width, bmPhoto.Height);

                switch (smode)
                {
                    case 0:
                        grPhoto.SmoothingMode = SmoothingMode.Default;
                        break;
                    case 1:
                        grPhoto.SmoothingMode = SmoothingMode.AntiAlias;
                        break;
                    case 2:
                        grPhoto.SmoothingMode = SmoothingMode.HighQuality;
                        break;
                    case 3:
                        grPhoto.SmoothingMode = SmoothingMode.HighSpeed;
                        break;
                    case 4:
                        grPhoto.SmoothingMode = SmoothingMode.None;
                        break;
                    default:
                        break;
                }
                switch (imode)
                {
                    case 0:
                        grPhoto.InterpolationMode = InterpolationMode.Default;
                        break;
                    case 1:
                        grPhoto.InterpolationMode = InterpolationMode.Bicubic;
                        break;
                    case 2:
                        grPhoto.InterpolationMode = InterpolationMode.Bilinear;
                        break;
                    case 3:
                        grPhoto.InterpolationMode = InterpolationMode.High;
                        break;
                    case 4:
                        grPhoto.InterpolationMode = InterpolationMode.HighQualityBicubic;
                        break;
                    case 5:
                        grPhoto.InterpolationMode = InterpolationMode.HighQualityBilinear;
                        break;
                    case 6:
                        grPhoto.InterpolationMode = InterpolationMode.Low;
                        break;
                    case 7:
                        grPhoto.InterpolationMode = InterpolationMode.NearestNeighbor;
                        break;
                    default:
                        break;
                }

                switch (mode)
                {
                    case 99:
                        // These are what worked best for me...
                        grPhoto.SmoothingMode = SmoothingMode.None;
                        grPhoto.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor;

                        for (int x = 0; x < im.Width; x++)
                            for (int y = 0; y < im.Height; y++)
                            {
                                var g = im.GetPixel(x, y);
                                if (g.R < 120 && g.B < 120) // Just being really lazy here... if the pixel has not much blue and not much red I'll treat it as black
                                {
                                    grPhoto.FillRectangle(blackbrush, border + factor * x, border + factor * y, factor, factor);

                                }
                            }
                        translate = false;
                        break;
                    default:
                        break;
                }

                if (translate) // If we used mode 99, don't draw the image
                    grPhoto.DrawImage(im, new System.Drawing.Rectangle(border, border, im.Width * factor, im.Height * factor), 0, 0, im.Width, im.Height, System.Drawing.GraphicsUnit.Pixel);
            }

            return bmPhoto;
        }
    }
}


问:
Angular selectionCange on multiple inputs
I have two selects, based on selected value from one select i am filtering data on second select, also i have option to add same row of form if desired, my problem is that if i select value from second row data (filteredcarPartsSub) from first changes do. how can i do selectionChange on only current row i am on?

here is my stackblitz

.html

```<code>       <mat-select #multiSelect formControlName="cat" name="cat" (selectionChange)="onChange($event); getCarPartsSubCategory($event, i)">
          <mat-option>
            <ngx-mat-select-search [formControl]="carPartsMultiFilterCtrl" [placeholderLabel]="'search...'"
            [noEntriesFoundLabel]="'not found'">
          </ngx-mat-select-search>
          </mat-option>
          <mat-option *ngFor="let item of filteredcarParts | async" [value]="item">{{
            item.name
          }}</mat-option>
        </mat-select>

        <mat-select #multiSelect formControlName="carPartSubCategory">
          <mat-option>
            <ngx-mat-select-search [formControl]="carPartsMultiFilterCtrl" [placeholderLabel]="'search...'"
              [noEntriesFoundLabel]="'not found'">
            </ngx-mat-select-search>
          </mat-option>
          <mat-option *ngFor="let item of filteredcarPartsSub | async; let i = index;" [value]="item">{{item.name}}
          </mat-option>
        </mat-select>
</code>```

.ts

```<code>  // get car part subcategory
  getCarPartsSubCategory(event: any) {
    let value = event.value;
    this.inputValue = [];
    console.log(value);
    this.inputValue = [...this.inputValue, ...value.carPartSubCategories];
    this.filteredcarPartsSub.next(this.inputValue);
  }
</code>```

答:
Your stackblitz was not able to open dropdown options for some reason.

Anyway by looking at your code, I see that, for all records you are refering to same ReplaySubject "filteredcarPartsSub". so when ever you update that subject from any of the row, it will trigger change in all rows.

Better have different subjects with their own options for each row.

If there can be too many rows, then may be you can have a custom pipe which filters the value from super set of options for mat-options in each row.

Body:
I have two selects, based on selected value from one select i am filtering data on second select, also i have option to add same row of form if desired, my problem is that if i select value from second row data (filteredcarPartsSub) from first changes do. how can i do selectionChange on only current row i am on?

here is my stackblitz

.html

       <mat-select #multiSelect formControlName="cat" name="cat" (selectionChange)="onChange($event); getCarPartsSubCategory($event, i)">
          <mat-option>
            <ngx-mat-select-search [formControl]="carPartsMultiFilterCtrl" [placeholderLabel]="'search...'"
            [noEntriesFoundLabel]="'not found'">
          </ngx-mat-select-search>
          </mat-option>
          <mat-option *ngFor="let item of filteredcarParts | async" [value]="item">{{
            item.name
          }}</mat-option>
        </mat-select>

        <mat-select #multiSelect formControlName="carPartSubCategory">
          <mat-option>
            <ngx-mat-select-search [formControl]="carPartsMultiFilterCtrl" [placeholderLabel]="'search...'"
              [noEntriesFoundLabel]="'not found'">
            </ngx-mat-select-search>
          </mat-option>
          <mat-option *ngFor="let item of filteredcarPartsSub | async; let i = index;" [value]="item">{{item.name}}
          </mat-option>
        </mat-select>

.ts

  // get car part subcategory
  getCarPartsSubCategory(event: any) {
    let value = event.value;
    this.inputValue = [];
    console.log(value);
    this.inputValue = [...this.inputValue, ...value.carPartSubCategories];
    this.filteredcarPartsSub.next(this.inputValue);
  }