hbase-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Anoop John <anoop.hb...@gmail.com>
Subject Re: scan column qualifiers in column family
Date Thu, 20 Nov 2014 12:11:36 GMT
byte[] email_b=Bytes.toBytes(mail);//column qulifier
        byte[] colmnfamily=Bytes.toBytes("colmn_fam");//column family
        Scan scan_col=new Scan (Bytes.toBytes("colmn_fam"),email_b);

Scan constructor is taking start and stop rows (rks). You seem to pass a cf
and q names.

Scan s = new Scan();
s.addColumn(byte [] family, byte [] qualifier)
s.setCaching(1)

Just open scanner and call next() once. If you get a not null result means
u have the give q in the cf.


-Anoop-



On Wed, Nov 19, 2014 at 11:24 PM, Ted Yu <yuzhihong@gmail.com> wrote:

> bq.
> org.freinds_rep.java.Insert_friend.search_column(Insert_friend.java:106)
>
> Does line 106 correspond to result.containsColumn() call ?
> If so, result was null.
>
> On Wed, Nov 19, 2014 at 9:47 AM, beeshma r <beeshma48@gmail.com> wrote:
>
> > Hi
> >
> > i need to find whether particular column qualifier present in column
> family
> >  so i did code like this
> >
> > As per document
> >
> > public boolean containsColumn(byte[] family,
> >                      byte[] qualifier)
> >
> > Checks for existence of a value for the specified column (empty or not).
> > Parameters:family - family namequalifier - column qualifierReturns:true
> if
> > at least one value exists in the result, false if not
> >
> > ////////////////////////// //my code////////////
> >
> > public static boolean search_column(String mail) throws IOException
> >     {
> >
> >         HTable testTable = new HTable(frinds_util.get_config(),
> > "people");//configuration
> >         byte[] email_b=Bytes.toBytes(mail);//column qulifier
> >         byte[] colmnfamily=Bytes.toBytes("colmn_fam");//column family
> >         Scan scan_col=new Scan (Bytes.toBytes("colmn_fam"),email_b);
> >         ResultScanner results = testTable.getScanner(scan_col);
> >         Result result = results.next();
> >
> >         if(result.containsColumn(colmnfamily, email_b))//check whether
> > column presernt
> >
> >         {
> >             System.out.println("column is present");
> >             ret=true;
> >
> >         }
> >         return ret;
> >
> >     }
> >
> > my build is failed with below o/p
> >
> >
> >
> > java.lang.reflect.InvocationTargetException
> >     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> >     at
> >
> >
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
> >     at
> >
> >
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> >     at java.lang.reflect.Method.invoke(Method.java:606)
> >     at org.codehaus.mojo.exec.ExecJavaMojo$1.run(ExecJavaMojo.java:293)
> >     at java.lang.Thread.run(Thread.java:724)
> > Caused by: java.lang.NullPointerException
> >     at
> > org.freinds_rep.java.Insert_friend.search_column(Insert_friend.java:106)
> >     at org.freinds_rep.java.Insert_friend.main(Insert_friend.java:156)
> >     ... 6 more
> > [WARNING] thread Thread[org.freinds_rep.java.Insert_friend.main(
> > 127.0.0.1:2181),5,org.freinds_rep.java.Insert_friend] was interrupted
> but
> > is still alive after waiting at least 15000msecs
> > [WARNING] thread Thread[org.freinds_rep.java.Insert_friend.main(
> > 127.0.0.1:2181),5,org.freinds_rep.java.Insert_friend] will linger
> despite
> > being asked to die via interruption
> > [WARNING] NOTE: 1 thread(s) did not finish despite being asked to  via
> > interruption. This is not a problem with exec:java, it is a problem with
> > the running code. Although not serious, it should be remedied.
> > [WARNING] Couldn't destroy threadgroup
> >
> >
> org.codehaus.mojo.exec.ExecJavaMojo$IsolatedThreadGroup[name=org.freinds_rep.java.Insert_friend,maxpri=10]
> > java.lang.IllegalThreadStateException
> >     at java.lang.ThreadGroup.destroy(ThreadGroup.java:775)
> >     at org.codehaus.mojo.exec.ExecJavaMojo.execute(ExecJavaMojo.java:328)
> >     at
> >
> >
> org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
> >     at
> >
> >
> org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
> >     at
> >
> >
> org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
> >     at
> >
> >
> org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
> >     at
> >
> >
> org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
> >     at
> >
> >
> org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
> >     at
> >
> >
> org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
> >     at
> >
> >
> org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
> >     at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320)
> >     at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
> >     at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
> >     at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
> >     at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
> >     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> >     at
> >
> >
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
> >     at
> >
> >
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> >     at java.lang.reflect.Method.invoke(Method.java:606)
> >     at
> >
> >
> org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
> >     at
> >
> org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
> >     at
> >
> >
> org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
> >     at
> > org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
> > [INFO]
> > ------------------------------------------------------------------------
> > [INFO] BUILD FAILURE
> > [INFO]
> > ------------------------------------------------------------------------
> > [INFO] Total time: 1:23.294s
> > [INFO] Finished at: Wed Nov 19 09:08:48 PST 2014
> > [INFO] Final Memory: 10M/137M
> >
> >
> >
> >
> >
> > Any idea how to solve this?
> >
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message