Fastest Java HashSet<Integer> library

In addition to this quite old post, I need something that will use primitives and give a speedup for an application that contains lots of HashSet s of Integers : Set<Integer> set = new HashSet<Integer>(); So people mention libraries like Guava, Javalution, Trove, but there is no perfect comparison of those in terms of benchmarks and performance results, or at least good answer comin

最快的Java HashSet <Integer>库

除了这个相当古老的帖子之外,我还需要一些使用原语的应用程序,并为包含大量Integers HashSet的应用程序加速: Set<Integer> set = new HashSet<Integer>(); 因此,人们提到像Guava,Javalution,Trove这样的图书馆,但是在基准和表现结果方面没有完美的比较,或者至少从良好的经验中得到了很好的答案。 从我看到的很多推荐Trove的TIntHashSet ,但其他人都说这不是很好; 有人说番石榴是超级冷却和可管理的,但

Object getting wrong time stamp from Hibernate saved to database

I am new to Hibernate and working on a web project that uses it. I have an object called area that has a date object( java.sql.Timestamp ) attribute modifiedDate. When I create a new object modifieDate is null and after send it down to getHibernateTemplate().saveOrUpdate(area); in my own class that extends org.springframework.orm.hibernate3.support.HibernateDaoSupport it is set with current t

对象从Hibernate中获取错误的时间戳记保存到数据库

我是Hibernate的新手,并且在使用它的Web项目上工作。 我有一个名为area的对象,它具有一个日期对象( java.sql.Timestamp )属性modifiedDate。 当我创建一个新对象时,modifieDate为null,并在发送给getHibernateTemplate().saveOrUpdate(area); 在我自己的类中,它扩展了org.springframework.orm.hibernate3.support.HibernateDaoSupport它使用当前时间戳设置并保存在数据库中。 在数据库中它被保存为datetime 。 我的

Tomcat load balancer solutions

I'm looking for a good load balancer to use with Tomcat. Our application doesn't store anything in the session context so it isn't important to redirect to same server for the same user. I'd simply like something that can queue requests round-robin style or based on each server's inidividual load. I'd also like to be able to add application servers to those available to

Tomcat负载平衡器解决方案

我正在寻找一个适用于Tomcat的良好负载平衡器。 我们的应用程序不会在会话上下文中存储任何内容,因此为同一用户重定向到同一台服务器并不重要。 我只是喜欢一些可以将请求循环方式或基于每个服务器的单个负载排队的东西。 我还希望能够将应用程序服务器添加到可用于处理请求的应用程序服务器,而无需重新启动负载平衡器。 如果有问题,我们正在linux上运行应用程序。 如果你只需要一个Linux上的软件负载平衡器,可以使用A

Servlets and scopes of CDI beans

tl;dr How is it possible that the CDI bean injected to servlet is also in proper scope? In official oracle tutorial and in some books we can see simple examples that shows how to inject CDI bean to servlet. It is pretty simple since we just have to use @Inject annotation and enable bean discovery in beans.xml. The thing that I don't understand is how is it possible, that the @RequestScope

Servlet和CDI bean的范围

tl; dr注入servlet的CDI bean如何也可能处于适当的范围内? 在官方的oracle教程和一些书中,我们可以看到简单的例子,展示了如何将CDI bean注入到servlet。 这很简单,因为我们只需使用@Inject注释并在beans.xml中启用bean发现。 我不明白的是,注入到servlet中的@RequestScoped或@SessionScoped bean具有合适的范围。 servlet对象只由容器创建一次,所以据我了解注入应该只发生一次,否则会出现一些意外的行为。 但是当我

Which CDI scope should be preferred for a JPA repository

How do I determine the appropriate CDI scope for a JPA repository like below? @Transactional public class CategoryRep extends EntityRepository<Integer, Category> { private static final long serialVersionUID = 856370976984333182L; public List<Category> getAllCategories() { // TODO } public List<Post> getAllPostsOfCategory(Integer categoryId) {

JPA存储库应该首选哪个CDI范围

如何确定下面的JPA存储库的适当CDI范围? @Transactional public class CategoryRep extends EntityRepository<Integer, Category> { private static final long serialVersionUID = 856370976984333182L; public List<Category> getAllCategories() { // TODO } public List<Post> getAllPostsOfCategory(Integer categoryId) { // TODO } @Transactional(value

Function to generate tone skipping cretain frequencies

The following was taken from an Android app: public void genTone(int freq){ for(int i = 0; i<numSamples; i++){ samples[i] = Math.pow(-1, (float)(i / (sampleRate/freq))); } int idx = 0; int volume = 32767 * cx/wide; for (final double dVal : samples) { final short val = (short) ((dVal+1) * volume); generatedSnd[idx

产生音调跳过cretain频率的功能

以下内容来自Android应用程序: public void genTone(int freq){ for(int i = 0; i<numSamples; i++){ samples[i] = Math.pow(-1, (float)(i / (sampleRate/freq))); } int idx = 0; int volume = 32767 * cx/wide; for (final double dVal : samples) { final short val = (short) ((dVal+1) * volume); generatedSnd[idx++] = (byte) (v

Prevent maven module from being built with no activated profile

I have a multi-module maven project with parent POM. One child of project is customized for different environments by profiles and parent pom also build needed modules depending on selected environment (profile). I want to prevent building (read as "to run mvn package" in child module) customized child project without profile activated, because there is no "generic" or &quo

防止未使用激活的配置文件构建Maven模块

我有一个与父POM的多模块maven项目。 项目的一个孩子根据配置文件为不同的环境定制,父母pom也根据选定的环境(配置文件)构建所需的模块。 因为没有用于环境的“通用”或“默认”版本,所以我想防止构建(读作“在子模块中运行mvn包”)定制子项目而不激活配置文件。 换句话说,我想强制开发人员使用环境依赖的配置文件。 是否有可能这样做? Maven Enforcer只是为了这个要求而制作的。 只需添加所需的配置文件。 <projec

Maven child module profile

I have a maven multi-module project. The parent has a test profile and includes child a in the profile itself. If I run mvn -P test from child module, will parent's "test" profile get executed? What if I want to provide a test profile for a specific child module only? No. A child inherits the configuration from the parent, but it's not a buildchain relationship. While, s

Maven子模块配置文件

我有一个maven多模块项目。 父母有一个测试配置文件,并在配置文件中包含子a。 如果我从子模块运行mvn -P测试,父母的“测试”配置文件会被执行吗? 如果我只想为特定的子模块提供测试配置文件,该怎么办? 不可以。小孩从父项继承配置,但它不是构建链关系。 然而,由于您已经将子项指定为模块,因此从构建父项时开始构建子项,在这种情况下,从子项的角度来看,父项是“pom”类型的另一个依赖项。 您只需使用测试配置文

Java resumable hash computation

I would like to achieve resumable on-the-fly hash generation of some file being uploaded on the server. The files are big so I am using the update(byte[]) method of MessageDigest class (as described here, for instance: How can I generate an MD5 hash? ) on the fly, as new bytes arrive from the HttpServletRequest's InputStream. Everything is going well, however, it's becoming interesting

Java可恢复散列计算

我想实现在服务器上上传的某些文件的可恢复的即时散列生成。 这些文件很大,所以我正在使用MessageDigest类的更新(byte [])方法(如此处所述,例如:如何生成MD5哈希?),因为新字节从HttpServletRequest的InputStream到达。 一切都很顺利,但是,当我想添加可恢复的上传支持时,它变得很有趣。 如果上传过早终止,则不完整的文件将存储在磁盘上。 但是,控制器(和底层服务)退出,因此MessageDigest对象丢失。 在这种

Setting wallpaper in Android

I am developing a simple app that sets wallpapers based on user input. I am missing code for setting wallpapers. I have been looking for it in lots of websites in vain. Can anybody post a sample code that sets as a wallpaper as a drawable that is saved in the res folder? 适用于Android 1.5及以上版本public void setWallpaper() { Context context = this.getBaseContext(); Bitmap mBitmap = Bitm

在Android中设置壁纸

我正在开发一个简单的应用程序,根据用户输入设置壁纸。 我缺少设置壁纸的代码。 我一直在很多网站上徒劳地寻找它。 任何人都可以发布设置为壁纸的示例代码作为保存在res文件夹中的drawable? 适用于Android 1.5及以上版本public void setWallpaper() { Context context = this.getBaseContext(); Bitmap mBitmap = BitmapFactory.decodeResource(getResources(), mImageIds[pos]); context.setWallpaper(mBitmap); }