Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3313922
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T22:10:18+00:00 2026-05-17T22:10:18+00:00

I wrote a simpe test to validate my own understanding of the thrift interface

  • 0

I wrote a simpe test to validate my own understanding of the thrift interface for Cassandra. It just inserts a row into the database (using the keyspace and column familty that come preconfigured with the cassandra installation), then reads it from the database and compares the results.

public class CassandraAPITest {
    @Test
    public void testCassandraAPI() throws Exception {
        TTransport tr = new TSocket("localhost", 9160);
        tr.open();
        Client client = new Cassandra.Client(new TBinaryProtocol(tr));
        String key = "123";
        byte[] value = { 52, 53, 54 };
        ColumnPath columnPath = new ColumnPath("Standard1");
        columnPath.setColumn("abc".getBytes("UTF8"));
        long timestamp = System.currentTimeMillis();

       client.insert("Keyspace1", key, columnPath, value, timestamp, ConsistencyLevel.ONE);

        SlicePredicate predicate = new SlicePredicate();
        SliceRange sliceRange = new SliceRange();
        sliceRange.setStart(new byte[0]);
        sliceRange.setFinish(new byte[0]);
        predicate.setSlice_range(sliceRange);

        List<ColumnOrSuperColumn> result = client.get_slice("Keyspace1", key, new ColumnParent("Standard1"), predicate, ConsistencyLevel.ONE);

        assertEquals(1, result.size());
        byte[] actual = result.get(0).column.value;
        assertArrayEquals(value, actual);

        // client.remove("Keyspace1", key, columnPath, System.currentTimeMillis(), ConsistencyLevel.ONE);

        tr.close();
    }
}

This test runs fine. Of course it leaves a row behind in the database. I could delete the row at the end of the test by uncommenting the client.remove statement above (this also works fine). But what I tried instead was deleting the row via the command-line interface:

cassandra> connect localhost/9160                   
Connected to: "Test Cluster" on localhost/9160
cassandra> get Keyspace1.Standard1['123']
=> (column=616263, value=456, timestamp=1287909211506)
Returned 1 results.
cassandra> del Keyspace1.Standard1['123']   
row removed.
cassandra> get Keyspace1.Standard1['123']
Returned 0 results.

The test fails afterwards. Inserting the row into the database seems to have no effect anymore, so the line assertEquals(1, result.size()) fails:

java.lang.AssertionError: expected:<1> but was:<0>
    at org.junit.Assert.fail(Assert.java:91)
    at org.junit.Assert.failNotEquals(Assert.java:618)
    at org.junit.Assert.assertEquals(Assert.java:126)
    at org.junit.Assert.assertEquals(Assert.java:443)
    at org.junit.Assert.assertEquals(Assert.java:427)
    at test.package.CassandraAPITest.testCassandraAPI(CassandraAPITest.java:48)

I don’t get any error messages (neither on the client nor on the server) and I have no idea what the cause of the problem might be.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T22:10:19+00:00Added an answer on May 17, 2026 at 10:10 pm

    You are inserting with millisecond resolution but the CLI (and other high level clients) uses microseconds. So your second insert is in the past, compared to the delete, so Cassandra correctly ignores it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wrote a simple test daemon using Proc::Daemon . Here is the daemon: #!/usr/bin/perl
I wrote a simple program to test array pointer: #include <iostream> using namespace std;
I wrote simple silverlight web application using the default ASP test page. If there
I wrote a simple test.cc as follows: #include <iostream> using namespace std; int main()
I wrote a simple program to test a theory that finally block will always
I wrote an XML RPC server in python and a simple Test Client for
A couple of weeks ago, I wrote a simple Ruby script to test a
I wrote a simple Sinatra app that generate an image using rmagick from some
I wrote simple script test echo hello #<-- inside test if I press one
I'm learning to work with lucene. I wrote a simple program to test lucene

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.