# Datatype conversion during reading records

**URL:** <https://discuss.aerospike.com/t/datatype-conversion-during-reading-records/6523>\
**Category:** General Discussion\
**Created:** [July 31, 2019, 1:21pm UTC](https://discuss.aerospike.com/t/datatype-conversion-during-reading-records/6523 "2019-07-31T13:21:36Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![asifansari80](https://avatars.discourse-cdn.com/v4/letter/a/e8c25b/32.png) [@asifansari80](https://discuss.aerospike.com/u/asifansari80)\
**Post date:** [July 31, 2019, 1:21pm UTC](https://discuss.aerospike.com/t/datatype-conversion-during-reading-records/6523/1 "2019-07-31T13:21:36Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![kporter](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.aerospike.com/kporter/32/515_2.png) [@kporter](https://discuss.aerospike.com/u/kporter)\
**Post date:** [August 7, 2019, 5:53pm UTC](https://discuss.aerospike.com/t/datatype-conversion-during-reading-records/6523/2 "2019-08-07T17:53:43Z")

</div>

1. What programming language are you using?
2. What is the version of the client library?
3. What is the Aerospike Sever version?

```auto
asadm -e 'asinfo -v "version"'

```

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

---

<div class="post-metadata">

**Author:** ![asifansari80](https://avatars.discourse-cdn.com/v4/letter/a/e8c25b/32.png) [@asifansari80](https://discuss.aerospike.com/u/asifansari80)\
**Post date:** [August 8, 2019, 2:42am UTC](https://discuss.aerospike.com/t/datatype-conversion-during-reading-records/6523/3 "2019-08-08T02:42:51Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![asifansari80](https://avatars.discourse-cdn.com/v4/letter/a/e8c25b/32.png) [@asifansari80](https://discuss.aerospike.com/u/asifansari80)\
**Post date:** [August 8, 2019, 2:24pm UTC](https://discuss.aerospike.com/t/datatype-conversion-during-reading-records/6523/4 "2019-08-08T14:24:36Z")

</div>

> [@asifansari80](#):
>
> \u0010¥

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

Sample code:

```auto
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:

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

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

```

---

<div class="post-metadata">

**Author:** ![asifansari80](https://avatars.discourse-cdn.com/v4/letter/a/e8c25b/32.png) [@asifansari80](https://discuss.aerospike.com/u/asifansari80)\
**Post date:** [August 12, 2019, 2:09pm UTC](https://discuss.aerospike.com/t/datatype-conversion-during-reading-records/6523/5 "2019-08-12T14:09:24Z")

</div>

Any luck on my case?

---

<div class="post-metadata">

**Author:** ![Brian](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.aerospike.com/brian/32/2211_2.png) [@Brian](https://discuss.aerospike.com/u/Brian)\
**Post date:** [August 12, 2019, 5:22pm UTC](https://discuss.aerospike.com/t/datatype-conversion-during-reading-records/6523/6 "2019-08-12T17:22:01Z")

</div>

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:

```java
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:

```auto
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.

---

<div class="post-metadata">

**Author:** ![system](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.aerospike.com/system/32/2274_2.png) [@system](https://discuss.aerospike.com/u/system)\
**Post date:** [August 18, 2019, 5:22pm UTC](https://discuss.aerospike.com/t/datatype-conversion-during-reading-records/6523/7 "2019-08-18T17:22:01Z")

</div>

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