java Java在内存中的SQL表之类的数据结构
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4558855/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Java in memory SQL Table like data structure
提问by Adam Gent
Several times I have wanted a data structure that is similar to a SQL Table where you can select on various fields and multiple fields. Similar to an in memory SQL implementation except that I don't want to store that many objects in the data structure.
有几次我想要一个类似于 SQL 表的数据结构,您可以在其中选择各种字段和多个字段。类似于内存中的 SQL 实现,只是我不想在数据结构中存储那么多对象。
I also require the object to be serializable through standard Java means.
我还要求对象可以通过标准 Java 方式进行序列化。
I have done this before with multiple hash tables or custom hash keys but it ended up being a lot of code and very specific the problem.
我之前使用多个哈希表或自定义哈希键完成了此操作,但最终是大量代码并且问题非常具体。
I have also used Groovy with its closure ability and gpath to help but I don't always have it available (different projects).
我还使用 Groovy 的关闭功能和 gpath 来提供帮助,但我并不总是可用(不同的项目)。
EDIT: I think my problem is more of an object traversal/selection problem Here are some interesting projects:
编辑:我认为我的问题更像是一个对象遍历/选择问题这里有一些有趣的项目:
- http://josql.sourceforge.net/
- http://homepages.mcs.vuw.ac.nz/~djp/JQL/
- http://today.java.net/pub/a/today/2006/08/03/java-object-querying-using-jxpath.html
- http://code.google.com/p/lambdaj/(I used this in the past and it was.... slow...)
- http://jedi.codehaus.org/Jedi
- http://josql.sourceforge.net/
- http://homepages.mcs.vuw.ac.nz/~djp/JQL/
- http://today.java.net/pub/a/today/2006/08/03/java-object-querying-using-jxpath.html
- http://code.google.com/p/lambdaj/(我过去使用过它,但它......很慢......)
- http://jedi.codehaus.org/绝地武士
However the downside to most of these projects is that they are much slower than accessing the objects directly (non reflection getter/setter) and definitely slower than an index (hash).
然而,大多数这些项目的缺点是它们比直接访问对象(非反射 getter/setter)慢得多,而且绝对比索引(哈希)慢。
回答by Alex Weinstein
What concerns you about using in-memory SQL storage for these purposes? You'd save a ton of development time; performance overhead is really insignificant. You risk much more by trying to implement this yourself.
出于这些目的使用内存中的 SQL 存储有什么顾虑?您将节省大量的开发时间;性能开销真的微不足道。尝试自己实现它会冒更多的风险。