Package com.google.code.hs4j

Examples of com.google.code.hs4j.ModifyStatement


  }

  public void writeBytesHsj4(String id, byte[] bytes) throws Exception {
    hsClient.openIndex(0, "mytest", "hs4jtest", "PRIMARY",
        new String[] { "id", "value" });
    ModifyStatement stmt = hsClient.createStatement(0);

    stmt.setString(1, id);
    stmt.setBytes(2, bytes);
    stmt.insert();

  }
View Full Code Here


        "NAME_MAIL_INDEX", icolumns, fcolumns));
    assertTrue(this.hsClient.insert(indexId, new String[] { "0", "dennis",
        "killme2008@gmail.com", "7", "2010-11-28 13:24:00" }));

    final String[] keys = {"dennis", "killme2008@gmail.com"};
    ModifyStatement stmt = session.createStatement();
    stmt.setInt(1, 1);

    // increment 100
    sum = 100;
    for (i = 0; i < sum; i++) {
      result=stmt.incr(keys, FindOperator.EQ);
      assertTrue(result == 1);
    }
    rs = session.find(keys);
    while(rs.next()){
      System.out.println("increment age is: "+rs.getInt("age"));
      assertEquals(107, rs.getInt("age"));
    }
    // decrement 100
    sum = 100;
    for (i = 0; i < sum; i++) {
      result=stmt.decr(keys, FindOperator.EQ);
      assertTrue(result == 1);
    }
    rs = session.find(keys);
    while(rs.next()){
      System.out.println("decrement age is: "+rs.getInt("age"));
View Full Code Here

    // find null
    final String[] keys = { "dennis", "killme2008@\tgmail.com" };
    ResultSet rs = this.session.find(keys);
    assertFalse(rs.next());

    ModifyStatement stmt = this.session.createStatement();
    stmt.setInt(1, 0);
    stmt.setString(2, "dennis");
    stmt.setString(3, "killme2008@\tgmail.com");
    stmt.setInt(4, 27);
    stmt.setString(5, "2010-11-28 13:24:00");

    // insert
    assertTrue(stmt.insert());

    // find once
    rs = this.session.find(keys);
    assertTrue(rs.next());

    System.out.println(rs.getInt(1));
    assertEquals("dennis", rs.getString(2));
    assertEquals("killme2008@\tgmail.com", rs.getString(3));
    assertEquals(27, rs.getInt(4));
    assertFalse(rs.next());

    // update
    stmt = this.session.createStatement();
    stmt.setInt(1, 1);
    stmt.setString(2, "dennis");
    stmt.setString(3, "test@163.com");
    stmt.setInt(4, 109);
    assertEquals(1, stmt.update(keys, FindOperator.EQ));

    // find twice
    rs = this.session.find(new String[] { "dennis" });
    assertTrue(rs.next());
View Full Code Here

TOP

Related Classes of com.google.code.hs4j.ModifyStatement

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.