Is there a way to get the datatype of a bin in aerospike?

I want to return the schema of the record. So i am trying to get the datatype of bins in records. I can get the name of the bin but i can’t find (as for now) a way to get its data type. Here is the method i wrote to get the bin name (Any help would be appreciated):

def getSchema(record:Record):String = {
    val temp: String = record.bins.keySet().toString()
    val repTemp = temp.replaceAll(" ", "")
    return repTemp.substring(1, repTemp.length()-1)
}

Hi Hammad,

Although the server stores the type of the bin on a per-record basis, this information is not returned to the client apart from implicitly in the returned value. So you could just get the value and infer whether it’s a string, double, integer, list or map from that.

Also remember that Aerospike is schema-less, so each record in the set may have different bin, and the types in a bin may not be consistent across all the records in the set.

Can I ask why you want to return the schema for a record?

Cheers,

Tim

Lets suppose i have the same number of bins in a record in a specific set. I want to use the schema to make a data frame from it in spark , and a data frame requires a Strcut type schema, so if i know the type i can easily create a schema.

Regards

Isn’t it the case that RDDs can deduce the types, if they’re consistent, and so can Data Frames?

yes you are right. I didn’t need the schema while creating a dataframe. Thanks

 val df = sqlContext.read.format("com.databricks.spark.csv").load("hdfs://172.xxx.xx.xx:xxxx/hammad/hdfs.csv")