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

error when it scans for hbase #110

Closed
juneng603 opened this issue Aug 23, 2012 · 9 comments
Closed

error when it scans for hbase #110

juneng603 opened this issue Aug 23, 2012 · 9 comments
Labels

Comments

@juneng603
Copy link

hi, developers.

I have a following method to scan data for hbase.

Scan Method

public <E> List<E> scan(Class<E> clazz) {
        Query q = em.createQuery("select o from " + clazz.getSimpleName() + " o");

        return q.getResultList();
}

Sample Entity

@Entity
@Table(name="TWITTER_TEST", schema="hbase@hbase-test")
public class Twitter {
    @Id
    private byte[] key;

    @Embedded
    private TwitterService S;

    @Embedded
    private TwitterSearch O;

    ....

in a test-case,

List<Twitter> scan = (List<Twitter>) service.scan(Twitter.class);

When I executed a test-case, I got the error like this.

2012-08-22 17:56:18,833 ERROR com.impetus.client.hbase.admin.HBaseDataHandler - Error while creating an instance of class net.daum.search.drp.bifrost.storage.entities.Twitter

internally, it prints out this kinds of traces.

javax.persistence.PersistenceException: java.lang.RuntimeException: com.impetus.kundera.property.PropertyAccessException: > > java.lang.IllegalArgumentException: argument type mismatch
at com.impetus.client.hbase.admin.HBaseDataHandler.onRead(HBaseDataHandler.java:843)
at com.impetus.client.hbase.admin.HBaseDataHandler.readDataByRange(HBaseDataHandler.java:242)
at com.impetus.client.hbase.HBaseClient.findByRange(HBaseClient.java:285)
at com.impetus.client.hbase.query.HBaseQuery.onQuery(HBaseQuery.java:168)
at com.impetus.client.hbase.query.HBaseQuery.populateEntities(HBaseQuery.java:89)
at com.impetus.kundera.query.QueryImpl.getResultList(QueryImpl.java:146)
at net.daum.search.drp.bifrost.storage.BFStorageService.scan(BFStorageService.java:117)
at net.daum.search.drp.bifrost.storage.BFStorageServiceTest.testCount(BFStorageServiceTest.java:162)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:30)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
at org.mockito.internal.runners.JUnit45AndHigherRunnerImpl.run(JUnit45AndHigherRunnerImpl.java:37)
at org.mockito.runners.MockitoJUnitRunner.run(MockitoJUnitRunner.java:62)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: java.lang.RuntimeException: com.impetus.kundera.property.PropertyAccessException: java.lang.IllegalArgumentException: argument type mismatch
at com.impetus.client.hbase.admin.HBaseDataHandler.populateEntityFromHbaseData(HBaseDataHandler.java:704)
at com.impetus.client.hbase.admin.HBaseDataHandler.onRead(HBaseDataHandler.java:817)
... 34 more
Caused by: com.impetus.kundera.property.PropertyAccessException: java.lang.IllegalArgumentException: argument type >mismatch
at com.impetus.kundera.property.PropertyAccessorHelper.setId(PropertyAccessorHelper.java:245)
at com.impetus.client.hbase.admin.HBaseDataHandler.populateEntityFromHbaseData(HBaseDataHandler.java:534)
... 35 more
Caused by: java.lang.IllegalArgumentException: argument type mismatch
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.impetus.kundera.property.PropertyAccessorHelper.setId(PropertyAccessorHelper.java:241)
... 36 more

my guess is an error from this.
In a PropertyAccessorHelper.setId(Object entity, EntityMeta metadata, String rowKey)

Field idField = metadata.getIdColumn().getField();
PropertyAccessor<?> accessor = PropertyAccessorFactory.getPropertyAccessor(idField);
Object obj = accessor.fromString(idField.getClass(), rowKey);

metadata.getWriteIdentifierMethod().invoke(entity, obj); // <-- at this point, exception has been occured.
@juneng603
Copy link
Author

yes,

when I modified my Entity to

@Entity
@Table(name="TWITTER_TEST", schema="hbase@hbase-test")
public class Twitter {
    @Id
    private String key;

    @Embedded
    private TwitterService S;

    @Embedded
    private TwitterSearch O;

    ....

THERE IS NO PROBLEM YET.

@mevivs
Copy link
Collaborator

mevivs commented Aug 23, 2012

We are working to add full support on byte[] as a row key in hbase, will update on this JIRA once done. As a work around String can be used as storage will always be in bytes only.

-Vviek

@juneng603
Copy link
Author

If I want to make a rowkey as a composite key for the better performance of hbase, how could I refect it?

I mean that our plan for a rowkey is liek this

rowkey = cpid + channelid + url

cpid, channelid are long type values.
url is a string type value which has a variable length.

for this situation, String typed id is not highly recommended because long typed values could be different length.

I mean that long type '1', '10000' has a same length in Long bug different length in String.

any ideas?

- Henry

@xamry
Copy link
Contributor

xamry commented Aug 24, 2012

Composite keys support is planned for next release but it's not there as of
now.

This means you have to build your primary key (probably by concatenating
them to form a String)

One approach for long values would be to padding characters keeping length
fixed. This will make sure that they are of similar length.
Another approach would be to use a different field for primary key (may be
a randomly generated string). These 3 fields should then be either columns
(or part of a column family)

Regards,
Amresh

On Fri, Aug 24, 2012 at 11:14 AM, Henry JunYoung Kim <
notifications@github.com> wrote:

If I want to make a rowkey as a composite key for the better performance
of hbase, how could I refect it?

I mean that our plan for a rowkey is liek this

rowkey = cpid + channelid + url

cpid, channelid are long type values.
url is a string type value which has a variable length.

for this situation, String typed id is not highly recommended because long
typed values could be different length.

I mean that long type '1', '10000' has a same length in Long bug different
length in String.

any ideas?

  • Henry


Reply to this email directly or view it on GitHubhttps://github.com//issues/110#issuecomment-7992841.

@ghost ghost assigned xamry Sep 12, 2012
@mevivs mevivs added this to the 2.11 release milestone Feb 5, 2014
@mevivs mevivs assigned kkmishra and unassigned xamry Feb 5, 2014
@FangmingD
Copy link

Is the "Composite keys support" working now for Hbase???

I'm trying to use the example for Cassandra to Hbase, but met an error

@mevivs
Copy link
Collaborator

mevivs commented Feb 10, 2014

Not yet supported. planned with 2.11 .

-Vivek

@mevivs mevivs removed this from the 2.11 release milestone Mar 28, 2014
@ghost
Copy link

ghost commented Apr 18, 2014

Hey Guys,
Is the composite key feature supported for HBase in 2.11 ? or planned for future release?

@chhavigangwal
Copy link
Collaborator

It is on road map. Team is working on it. Will post an update soon.

@chhavigangwal
Copy link
Collaborator

Opened #603 to enable composite key support for HBase.

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

No branches or pull requests

7 participants