How to use affinity key with BinaryObject - ignite

I want to use the affinity key with BinaryObject. I have used below code to set my affinity key but it didn't work. My Cache key is off type BinaryObject.
CacheKeyConfiguration keyConfiguration = new CacheKeyConfiguration(BinaryObject.class.getName(), affinityKeyConfig);
cfg.setKeyConfiguration(keyConfiguration);
I have used BinaryObject in key and value also. I have used bank as affinity key. I had inserted 4 records for 'SBI' and 8 'records for 'HDFC'. For node 1, it should show 4/8 on primary/backup and for node 2, it should show 8/4 on primary/backup.
But I can see records are equally distributed. If I use affinity key then data should not distributed equally.

Related

How couchbase ensures uniqueness of id?

As per the documentation primary index (index on document key) is optional in Couchbase. How does Couchbase efficiently ensure uniqueness of document key without an index?
The primary index that documentation refers to is only for N1QL queries, and has nothing to do with enforcing uniqueness.
Instead, uniqueness is enforced by the key/value data service. From the "Data" overview documentation:
Each value (binary or JSON) is identified by a unique key, defined by
the user or application when the item is saved. The key is immutable:
once the item is saved, the key cannot be changed.
I am not an expert on Couchbase internals, but unique keys are fundamental to how Couchbase stores/retrieves/shards data. Check out Understanding vBuckets for more information ('vBucket' is analogous to 'shard'). Here's a snippet:
Items are written to and retrieved from vBuckets by means of a CRC32
hashing algorithm, which is applied to the item’s key, and so produces
the number of the vBucket in which the item resides.

Key type in Cache Configuration for table without key?

What will be the Key type in Cache Configuration if the database table that I'm loading cache from has no key, but in fact, also has duplicate rows.
You can use an artificial key in this case. If you assign, for example, a unique integer key to each row, then you'll be able to store them in Ignite cache. It can be done during data loading.

Copy one key from one redis instance to another

I have a Redis implementation with 6 nodes (3 masters 3 slaves - cluster enabled). I have load in every master an amount of keys.
So, my question is:
Is it possible to actual copy one key from 127.0.0.1:30001 to 127.0.0.1:30002?
For example lets say that my key has the name "testkey". If i copy this key from 30001 to 30002, when i want to get the key from 30001 or from 30002 the response must fetch the value of "testkey" in both calls.
No, that not how it works.
Keys in the cluster are assigned to hash slots and slots are assigned to master nodes. The keys' assignment is done by hashing their names (or the hash tag in them) so it is consistent, meaning that a given key name always hashes to the same slot.
A key can exist only once in the keyspace, but the slot it belongs to can be moved between masters. To scale reads from that key you can use the slave of the applicable master.
A good point to start understanding how the cluster works is by referring to the [tutorial](https://redis.io/topics/cluster-tutorial].

Is the row key of HBase Table automatically indexed?

This may be a silly question - but I couldn't find out how to "index" the row key in Hbase so I am assuming that when HBase puts in the row key they have built-in support to automatically index the table based on the row key - in other words, treating the row key as primary key automatically?
thanks!
The table is not just indexed by the key it is actually lexicographically ordered by the key. i.e. Hbase knows on which region service to find each key and within that regionserver the region and the sepecific HFile. The data that is written to the HFile is ordered by the key.
The lexicographic ordering means you can also retrive data by partial key (e.g. a scan for "a") will get everything that starts with "a". This is used a lot of time to put multiple dimensions in the key e.g. you can have the key set to country followed by city to get aggregates per country and then get a breakdown by city efficiently.
Yes, the tables are ordered via the row key. And clients can get the region server ids that contain the range of row keys, allowing then to connect directly to the region server that contains the row key that they require. Furthermore, since the keys are ordered byte arrays, the region server can do a binary search to retrieve the row from list of rows that it contains. This makes random retrieval very efficient, and it makes scanning contiguous rows very efficient.

Redis: Is it possible to get just one value of a Set by its key?

I have a Set named 'Projects' with many key-value pairs and I want to retrieve one of the values by providing its key. I checked the redis doc but I only found how to retrieve the entire Set. Is it possible to just retrieve one value by providing its key?
Your concept of Set does not match Redis'.
All members of a set in Redis are stored in a single key. Therefore you can't access members individually by a key.
You should use hashes: http://www.redis.io/commands#hash
HSET key field value does what you are looking for.