Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding Hash data to a column #15

Closed
Rockyyost opened this issue Feb 23, 2014 · 2 comments
Closed

Adding Hash data to a column #15

Rockyyost opened this issue Feb 23, 2014 · 2 comments

Comments

@Rockyyost
Copy link

I was trying to add a hash as a value to a column, but was stopped by Thrift. Doesn't HBase support embedded data? Is there anyway to save that through Thrift?

Thanks,
Rockt

@nkeyes
Copy link
Owner

nkeyes commented Feb 23, 2014

You need to serialize the data yourself, HBase only really deals with strings and numbers.

if you're using OkHbase::ActiveModel, you can do something like:

User < OkHbase::ActiveModel

  def self.table_name
    'users'
  end

  def self.connection
    @ok_hbase_connection ||= OkHbase::Connection.new(...)
  end

  def preferences=(val)
    super val.to_json # serialize before saving field
  end

  def preferences
    JSON.parse(super).with_indifferent_access # deserialize field
  end
end

@Rockyyost
Copy link
Author

Oh okay. Cool, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants