Created
May 13, 2010 06:14
-
-
Save spidaman/399554 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public boolean has_key(String keySpace, String columnFamilyName, String key) throws Exception { | |
TTransport tr = new TSocket("localhost", 9160); | |
TProtocol proto = new TBinaryProtocol(tr); | |
Cassandra.Client client = new Cassandra.Client(proto); | |
tr.open(); | |
SlicePredicate predicate = new SlicePredicate(); | |
SliceRange sliceRange = new SliceRange(); | |
sliceRange.setCount(1); | |
sliceRange.setStart(new byte[0]); | |
sliceRange.setFinish(new byte[0]); | |
predicate.setSlice_range(sliceRange); | |
ColumnParent columnParent = new ColumnParent(columnFamilyName); | |
List<ColumnOrSuperColumn> result = client.get_slice(keySpace, key, columnParent, predicate, ConsistencyLevel.ALL); | |
return result.size() > 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment