Will rocksDB support nested keys for one value? - java

I am new to RocksDB. I am testing it on java spring boot(dependency: org.rocksdb.rocksdbjni). Will it support on storing nested keys for one value and retrieve a value using nested keys.
Example:
In Java, I am using the following data structure. Map<Type1, Map<Type2, Type3>>().
Will it workout in rocksDB implementation?. Here 'Type1' is the outer key, 'Type2' is the inner key and 'Type3' is the value for the respective keys.

RocksDB does not support Map within a Map, you could look at other databases that are built over RocksDB.
Though One way you could represent Map within a Map is to use to keys with the following form:
"type1/type2/type3": value

Related

Is there any multimap with different values of different object for one key in java-redis?

My application requires a multivaluemap to store in redis cache with a key having 2 different objects saying object1 and object2. Map can return all the values or a single value based on type parameter as in get(key, type).
Couldn't find such feature in either reddison or jedis. Is there any other library providing this data structure or I would have to implement my own?
As I know, there is no this kind of data structure in Redis, you have to do a little design by yourself, using extra keys to store extra information.

Freemarker - access value at a particular key in map

I have Map variable in my Freemarker template. How can I fetch a value at a particular key in the map, as we do in Java (map.get(<key>)).
I know how to iterate through keys and values of a map in a FTL. But I want a solution without iteration, on the lines of Java get() method of Map interface.
map[dynamicKey] or map.staticKey if the key is a string. Due to historical limitations, if the key isn't a string, map?api.get(nonStringKey).

Which collection should I use to easely get certain object from it by the pair of properties?

Info about network interfaces comes from several servers and must be shown in the table. Each interface must have name and serverName, they're not unique, but pair of them is.
Problem: Information comes every second, and I need to update fields of each interface with new data. So I need to get certain (identified by name and serverName) interface from some list with minimum effort (resources). Table works only with observableList, but searching through it is the overkill. It can contain thousand of interface objects.
Should I create own realization of list, which can be flatten to observableList, or the best way will be to hold HashMap<String, NetInterface> of each server (key is interface's name) with refences from observableList?
HashMap>
use as auto increment for Integer.
The best way will be using the unique thing(name+server name) as the key of your Hash Map.
Use a Map<String, Map<String, NetInterface>, where the outer key is the name and the inner key is the server name.

Most efficient way to implement table with multiple column?

I am attempting to create a table with multiple column such as
The initial implementation I thought was is that use
Hashtable with key being "String" and value being "List" of String.
But is this the most efficient way? I would be accessing data entry a lot and I am assuming since Java List is implemented in ArrayList, updating each data entry is not too slow. Am I correct?
You can use Guava's Table.
For instance using a HashBasedTable:
Table<RowType, ColumnType, String> table = HashBasedTable.create();

Adding non-primitive typed data as property value in nodes and relationships

In neo4j we can add node and relationships with various properties using
node.setProperty("NodePropertyName",NodePropertyValue)
relationship.setProperty("EdgePropertyName",EdgePropertyValue)
Is there any way by which I can use non-primitive datatypes like MAP , Array or user-defined object as NodePropertyValue and EdgePropertyValue ?
Or do i need to give all values in MAP<> individually as separate properties of Node or Relationship ?
I tried using
node.setProperty("USER_PROPERTIES", GraphNode.getNodeproperties());
where,
GraphNode.getNodeproperties() returns MAP<String,Double>
But this is giving me an error:
java.lang.IllegalArgumentException: Unknown property type on: {Property1=0.0, Property2=0.0, Property3=0.0, Property4=0.0, Property5=0.0, Property6=0.0, Property7=0.0}
Is there any way by which I can use non-primitive datatypes like MAP ,
Array or user-defined object as NodePropertyValue and
EdgePropertyValue ?
Neo4J allows you to store an array of String, or an array of a primitive datatype.
Maps are not supported (yet), but an alternative could be to store the map as a JSON structure (using GSON or Jackson), or even as an XML structure, using XStream.
You can indeed only store primitive values as properties. If you want to store a collection of values (and if you're using Spring), then DynamicPropertiesContainer might be an option. If you want to store custom objects, you probably want to create some related nodes. Use createRelationshipTo(Node otherNode, RelationshipType type) to accompish this.

Categories

Resources