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

pass Config to custom HBaseSerde #28

Open
andvit opened this issue Jun 15, 2018 · 2 comments
Open

pass Config to custom HBaseSerde #28

andvit opened this issue Jun 15, 2018 · 2 comments

Comments

@andvit
Copy link

andvit commented Jun 15, 2018

Hello

com.cloudera.labs.envelope.utils.hbase.HBaseUtils
// HBaseSerde util
public static HBaseSerde getSerde(Config config) {
HBaseSerde serde;
if (config.hasPath(SERDE_PROPERTY)) {
String serdeImpl = config.getString(SERDE_PROPERTY);
if (serdeImpl.equals(DEFAULT_SERDE_PROPERTY)) {
return new DefaultHBaseSerde();
} else {
try {
Class clazz = Class.forName(serdeImpl); Constructor constructor = clazz.getConstructor();
return (HBaseSerde) constructor.newInstance();
} catch (Exception e) {
LOG.error("Could not construct custom HBaseSerde instance [" + serdeImpl + "]: " + e);
throw new RuntimeException(e);
}
}
} else {
serde = new DefaultHBaseSerde();
}
serde.configure(config);

return serde;

}

in case of custom serde, serde.configure(config) is never called, there is no way to access config in provided serde

according to the comment below configure(config) should be called
com.cloudera.labs.envelope.utils.hbase.HBaseSerde
/**

Configure the Serde.
This will be passed the contents of an "input" or "output" configuration section.
@param config
*/
void configure(Config config);

@andvit
Copy link
Author

andvit commented Jun 15, 2018

simple change from
return (HBaseSerde) constructor.newInstance();
to
serde = (HBaseSerde) constructor.newInstance();
resolves the issue

@ianbuss
Copy link
Contributor

ianbuss commented Jun 18, 2018

Thanks @andvit, you're absolutely right. Will ensure this is fixed and rolled into the next release. We're also missing a unit test for custom serdes. To re-iterate, the fix is as described:

Line 174 to serde = (HBaseSerde) constructor.newInstance();

Line 179 to serde = new DefaultHBaseSerde();

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