Datatype conversion during reading records

Our application stores some bins in the form of Strings. The problem that we are facing is when we are trying to save a record having value of one of the bin as "value=“0x10A5"”, Aerospike is storing the following: “msTimezone”: “\u0010¥”

It is storing the values by converting it to its Symbol representation … here Yen symbol “¥” signifies A5.

So, when data is fetched from the database and dumped in flat files, these characters are interpreted by our customer as junk characters. How during the db fetch we can get the correct value ?

Thanks Asif

  1. What programming language are you using?
  2. What is the version of the client library?
  3. What is the Aerospike Sever version?
    asadm -e 'asinfo -v "version"'
    
  4. Could you share a code example to reproduce the behavior?

Thanks for the response !!

  1. What programming language are you using?

We are using Java Application running in an Application server.

  1. What is the version of the client library?

Any particular command to check that ? -sh-4.2$ asinfo -v build 4.5.2.2

  1. What is the Aerospike Sever version?

-sh-4.2$ asadm -e ‘asinfo -v “version”’ Seed: [(‘127.0.0.1’, 3000, None)] Config_file: /opt/tpa/users/tpaadmin/.aerospike/astools.conf, /etc/aerospike/astools.conf sps44:3000 (135.249.93.44) returned: Aerospike Enterprise Edition build 4.5.2.2

  1. Could you share a code example to reproduce the behavior?

Will share this asap.

… Client Jar: aerospike-java-client-4.2.3.jar

Sample code:

import com.aerospike.client.AerospikeException;

import com.aerospike.client.Bin;

import com.aerospike.client.Host;

import com.aerospike.client.Key;

import com.aerospike.client.Record;

import com.aerospike.client.Value;

import com.aerospike.client.policy.ClientPolicy;

import com.aerospike.client.policy.WritePolicy;

public class Aerospike {
	
	public static void main(String[] args) 
	{		

			//Get host
 			Host host = new Host("127.0.0.1",3000);
 			ClientPolicy clientPolicy = new ClientPolicy();
 			WritePolicy writePolicy = new WritePolicy();
 			AerospikeClient client = new AerospikeClient(clientPolicy, host);			
			Key key = new Key("test", "myset", "mykey");
			Bin bin = new Bin("mybin", "\u0010\u00A5");
			client.put(writePolicy, key, bin);
			//Read the records
		  Record record = client.get(null, key);
		  
		  //Print all the record 
		  for(String binKey : record.bins.keySet())
		  {
		   System.out.println(binKey+" <-----> "+record.bins.get(binKey));
		  }
			client.close();
	}
}

o/P:

-sh-4.2$ aql -c "select * from test.myset" -o json
select * from test.myset

[
    [
        {
          "mybin": "\u0010¥"
        }
    ],
    [
        {
          "Status": 0
        }
    ]
]

Any luck on my case?

The send/receive bytes are identical ( “\u0010\u00A5”). The yen sign is only being shown when printing the string. The first character is not printable and the second character is the yen sign. See the following code:

String sendValue = "\u0010\u00A5";
int max = sendValue.length();

for (int i = 0; i < max; i++) {
	char c = sendValue.charAt(i);
	System.out.println("send[" + i + "]=" + (int)c);
}
System.out.println("send string=" + sendValue);

Key key = new Key("test", "myset", "mykey");
Bin bin = new Bin("mybin", sendValue);
client.put(null, key, bin);

Record record = client.get(null, key);
String receiveValue = (String)record.bins.get("mybin");
max = receiveValue.length();

for (int i = 0; i < max; i++) {
	char c = receiveValue.charAt(i);
	System.out.println("receive[" + i + "]=" + (int)c);
}
System.out.println("receive string=" + sendValue);

if (sendValue.equals(receiveValue)) {
	System.out.println("send == receive");
}
else {
	System.out.println("send != receive");
}

Results:

send[0]=16
send[1]=165
send string=¥
receive[0]=16
receive[1]=165
receive string=¥
send == receive

You can always store values as a blob if these string representations are causing confusion.

This topic was automatically closed 6 days after the last reply. New replies are no longer allowed.