Persistent data structures in Java [closed] - java

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this question
I need a persistent storage in Java for certain (possibly large) data structures, such as:
dense and sparse matrices of integers, doubles, booleans
directed graphs with labeled nodes and edges
binary trees
maps: string->string, string->integer (with fast retrieval of the keys with largest values)
sets of integers or strings
I don't mind if there is a separate storage for each data structure, as long as all the storages have similar, consistent interfaces.
I need to be able to efficiently modify the data structures "remotely", that is, without fetching the entire structure to RAM, modifying it, and storing back. Example operations: put a key-value in a map, remove a node from a tree, modify a node's label in a graph, add a value to a set.
It would be very nice if these storages could be also easily accessed from other programming languages, most notably Python. I'm thinking of a RESTful service in the backend and client APIs in Java and Python.
Motivation: I need to process a large collection of documents and perform various analyses on them. I want to explore various approaches and create fast prototypes (for that reason I need simple, easy-to-use APIs).
I guess I'm not the first person needing such a functionality and I would hate to reinvent the wheel here. Which brings me to the question: which open-source solutions allow easy-to-use persistence of data structures in Java?
Thanks in advance!

Have you thought about using something like MongoDB? It seem perfect for what your looking for and Its picking up a lot of steam. It's a high-performance, schema-free document-oriented database and I love the fact it's based on json! Check it out!
Here is nice Java tutorial.

How about ObjectOutputStream and ObjectInputStream?

It's very hard to wire all that but you can use JPA with bi-directional mappings and lazy-loading.

It would really depend on you usage patterens, i.e., how many reads, how many writes, how often, etc, but I would suggest you just use sql until you prove that it will not work.

Related

What should One learn first? Java Collection Frameworks or Data structures and Algorithms? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 2 years ago.
Improve this question
I have learnt the basics of Java language and now can program easily in Java. Now I want to know that whether should I learn Java Collection Frameworks first or Data Structures and Algorithms.
As though you can program easily in java so now you start learn some common data structure and algorithm then try to implement them with java. it will clear your concept. after completing those common ds and algo then start java collection framework
Learn first Data Structures and algorithms because now technology generation in every selection interview are based on these two things Structures and algorithms . These is very important now for every developer select any programming with data structure and algorithms
Because all method of data structure and algorithms are apply during big project its necessary . if you have stamina so learn more hour and focused only this two then only structures and algorithms. Monday to Saturday (data structures and algorithms) and Sunday
(Java collection ) you can learn java collection framework. You can do it.
first data and algorithms is clear then we better understand easily java collection. hope you will get answer of your question.
Obviously Data Structure and Algorithm first.
because those are the only way to get understand with the frameworks.
best of luck brother.

High performance string hashing function in Java/Scala [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 2 years ago.
Improve this question
Looking for a high-performance String hashing functions in Java/Scala - something faster than functions from MurmurHash family, doesn't need to be cryptographically strong, only distribute well.
Any suggestions?
You can find very fast hash function implementations for Java, which BTW account internal String implementation (char[] array) to maximize speed, here: https://github.com/OpenHFT/Zero-Allocation-Hashing
The fastest hashing algorithm that fits the bill presently seems to be xxHash. The lz4-java project contains an implementation ported to Java. I don't know whether the Java implementation has been benchmarked against MurmurHash, though; performance optimizations in C++ don't always port to/from Java. (In particular, xxHash contains more array access, so there could be non-negligible bounds-checking overhead.)
Edit: it looks to me like it uses JNI to call the C++ implementation of xxHash, but JNI overhead is non-negligible, so the performance concerns remain.
However, given that Scala includes a MurmurHash function, and that Java contains a faster default hash (about 2x) that is sorta-reasonably distributed sometimes, one does wonder whether it's really necessary. For instance, scala.util.hashing.MurmurHash3 is about as fast as string creation from an array of bytes, and is twice as fast as that if you give it an array of bytes.

binary decision diagram [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 6 years ago.
Improve this question
In Java, I have set of expressions like cond1 AND (cond2 OR cond3) AND ( cond 4 OR cond5). I would like to convert it into tree and then evaluate the final boolean answer. I tried searching a lot around java BDD but not able to get any. Any suggestion with sample code ?
A 5-second Google search returned some reasonable-looking results:
JavaBDD
Java Decision Diagram Libraries
What is the best Binary Decision Diagram library for Java?
Is this not what you're looking for?
He means Binary Decision Diagrams.
I've been tinkering with JavaBDD and JBDD/JDD. Both are based on BuDDY (a C library) -- JBDD actually uses the C DLLs for a marginal performance boost.
It looks to me like JavaBDD is more fully-featured (ex. it supports composing BDDs, which is what I need). But there is also no tutorial for it, and while the class docs aren't terrible, frankly I can't figure out how to use it for the most basic of boolean operations (like the problem you pose).
JBDD/JDD requires you to use manual garbage collection, and does weird things like store BDD objects in Java integers -- clearly carry-overs from C. But it has a set of tutorials.
If you want to run your own parser, check out JavaCC.
Here is a nice tutorial to get you started. A bit older, but still valid:
http://www.javaworld.com/jw-12-2000/jw-1229-cooltools.html

Need a standalone Java library for performing spatial calculations on lat/lon data [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 5 years ago.
Improve this question
I'm looking for a Java library that is capable of performing spatial calculations on sets of lat/lon data. Here are some of the functions that I'm looking for:
Calculate the Great Circle distance between two points
Determine if a point lies within a simple closed polygon, where the polygon is defined by an ordered list of points
Determine if the line between point "A" and point "B" intersects a simple closed polygon, where the polygon is defined by an ordered list of points
Determine if point "A" is within a certain radius of point "B"
What I'm NOT looking for:
I don't want a library that is dependent upon a database geospatial component, such as Oracle Spatial, and cannot function independently.
I don't want a library whose purpose is to generate graphics/maps/etc. I am building an analysis module for an existing application and the end goal is not to create pretty pictures.
I don't want a library for searching large amounts of spatial data. If it also happens to do this, that's ok, but I'm not going to use that feature.
The organization is planning to acquire a license for Oracle Spatial eventually (so spatial searching will be covered at that point), but for now I need to implement the analysis functions that I have mentioned above on small data sets without relying on database-supplied spatial support.
I believe GeoTools would satisfy your requirements. Note that it does have facilities for doing graphics/maps, but they can be left unused easily enough.
There is a new library Spatial4J that seems to fullfill your needs, it supports various spaces and shapes
Spatial4j is a general purpose spatial / geospatial ASL licensed open-source Java library (...)
I haven't used it so far but the README is complete, and repositery is rather popular, and it's available on maven repositery
I was looking for such spatial library when I end up both on the repo and on this question.
Simplelatlng gives more simple API for this:
https://code.google.com/p/simplelatlng/wiki/GettingStarted
In spite of your desire to avoid a library that is used to draw maps, I'd recommend OpenMap. The com.bbn.openmap.geo package of that library does most if not all of the things you are asking for.
I've used STRtree java class to index by lat lng data and distance queries
https://locationtech.github.io/jts/javadoc/org/locationtech/jts/index/strtree/STRtree.html

java: libraries for immutable functional-style data structures [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 5 years ago.
Improve this question
This is very similar to another question (Functional Data Structures in Java) but the answers there are not particularly useful.
I need to use immutable versions of the standard Java collections (e.g. HashMap / TreeMap / ArrayList / LinkedList / HashSet / TreeSet). By "immutable" I mean immutable in the functional sense (e.g. purely functional data structures), where updating operations on the data structure do not change the original data, but instead return a new instance of the same kind of data structure. Also typically new and old instances of the data structure will share immutable data to be efficient in time and space.
From what I can tell my options include:
Functional Java
Scala
Clojure
but I'm not sure whether any of these are particularly appealing to me. I have a few requirements/desirements:
the collections in question should be usable directly in Java (with the appropriate libraries in the classpath). FJ would work for me; I'm not sure if I can use Scala's or Clojure's data structures in Java w/o having to use the compilers/interpreters from those languages and w/o having to write Scala or Clojure code.
Core operations on lists/maps/sets should be possible w/o having to create function objects with confusing syntaxes (FJ looks slightly iffy)
They should be efficient in time and space. I'm looking for a library which ideally has done some performance testing. FJ's TreeMap is based on a red-black tree, not sure how that rates.
Documentation / tutorials should be good enough so someone can get started quickly using the data structures. FJ fails on that front.
Any suggestions?
It seems to me you already know what your options are, you just aren't happy with any of them. Here is my take on the three choices you've provided:
Functional Java - This one seems like the best fit for you. It fits all of your requirements except that you don't like the documentation. From my perspective the documentation looks basic, but serviceable. Their code snippets should get you up and running quickly. The learning curve seems almost non-existent which should help mitigate the lack of documentation. FYI, core Java's TreeMap is based on a Red-Black tree as well.
Scala - This is the choice I would make if I was in your shoes. You seem to not want to learn a new language, but Scala is a very easy transition from Java. You can write very java-like code at first, and slowly adopt more functional idioms. The Java <-> Scala interop is excellent in both directions as well.
Clojure - As much as I love Clojure, its tough to recommend in this particular instance due to the radically different syntax and steep learning curve for a java developer.
Perhaps Google's guava-libraries may be of some use:
https://code.google.com/p/guava-libraries/wiki/ImmutableCollectionsExplained
Scala
You can call the methods of either language from methods in the other one
http://www.scala-lang.org/faq/4
I've spent some time making the Clojure persistent/immutable data-structures work in Java, with sensible constructors and generics as part of Pure4J.
This also includes #ImmutableValue class for ensuring that not only are the collections immutable, but the values you put in them are immutable too.
Hope this helps.

Categories

Resources