Package org.apache.cassandra.thrift

Examples of org.apache.cassandra.thrift.ColumnPath


  }

  @Test
  public void testMultigetSlice() throws HectorException {
    // insert value
    ColumnPath cp = new ColumnPath("Standard1");
    cp.setColumn(bytes("testMultigetSlice"));
    ArrayList<String> keys = new ArrayList<String>(100);
    for (int i = 0; i < 100; i++) {
      keyspace.insert("testMultigetSlice_" + i, cp, StringSerializer.get().toByteBuffer("testMultigetSlice_value_" + i));
      keys.add("testMultigetSlice_" + i);
    }
View Full Code Here


  @Test
  public void testGetCount() throws HectorException {
    // insert values
    for (int i = 0; i < 100; i++) {
      ColumnPath cp = new ColumnPath("Standard1");
      cp.setColumn(bytes("testInsertAndGetAndRemove_" + i));
      keyspace.insert("testGetCount", cp, StringSerializer.get().toByteBuffer("testInsertAndGetAndRemove_value_" + i));
    }

    // get value
    ColumnParent clp = new ColumnParent("Standard1");
    //int count = keyspace.getCount("testGetCount", clp, se);
    //assertEquals(100, count);

    ColumnPath cp = new ColumnPath("Standard1");
    keyspace.remove("testGetCount", cp);
  }
View Full Code Here

  }

  @Test
  public void testGetRangeSlice() throws HectorException {
    for (int i = 0; i < 10; i++) {
      ColumnPath cp = new ColumnPath("Standard2");
      cp.setColumn(bytes("testGetRangeSlice_" + i));

      keyspace.insert("testGetRangeSlice0", cp, StringSerializer.get().toByteBuffer("testGetRangeSlice_Value_" + i));
      keyspace.insert("testGetRangeSlice1", cp, StringSerializer.get().toByteBuffer("testGetRangeSlice_Value_" + i));
      keyspace.insert("testGetRangeSlice2", cp, StringSerializer.get().toByteBuffer("testGetRangeSlice_Value_" + i));
    }

    // get value
    ColumnParent clp = new ColumnParent("Standard2");
    SliceRange sr = new SliceRange(ByteBuffer.wrap(new byte[0]), ByteBuffer.wrap(new byte[0]), false, 150);
    SlicePredicate sp = new SlicePredicate();
    sp.setSlice_range(sr);
    /*
    @SuppressWarnings("deprecation")
    Map<String, List<Column>> keySlices = keyspace.getRangeSlice(clp, sp, "testGetRangeSlice0", "testGetRangeSlice3", 5);

    assertNotNull(keySlices);
    assertEquals(3, keySlices.size());
    assertNotNull("testGetRangeSlice1 is null", keySlices.get("testGetRangeSlice1"));
    assertEquals("testGetRangeSlice_Value_0", string(keySlices.get("testGetRangeSlice1").get(0).getValue()));
    assertEquals(10, keySlices.get("testGetRangeSlice1").size());
    */

    ColumnPath cp = new ColumnPath("Standard2");
    keyspace.remove("testGetRanageSlice0", cp);
    keyspace.remove("testGetRanageSlice1", cp);
    keyspace.remove("testGetRanageSlice2", cp);
  }
View Full Code Here

  }

  @Test
  public void testGetRangeSlices() throws HectorException {
    for (int i = 0; i < 10; i++) {
      ColumnPath cp = new ColumnPath("Standard2");
      cp.setColumn(bytes("testGetRangeSlices_" + i));

      keyspace.insert("testGetRangeSlices0", cp, StringSerializer.get().toByteBuffer("testGetRangeSlices_Value_" + i));
      keyspace.insert("testGetRangeSlices1", cp, StringSerializer.get().toByteBuffer("testGetRangeSlices_Value_" + i));
      keyspace.insert("testGetRangeSlices2", cp, StringSerializer.get().toByteBuffer("testGetRangeSlices_Value_" + i));
    }

    // get value
    ColumnParent clp = new ColumnParent("Standard2");
    SliceRange sr = new SliceRange(ByteBuffer.wrap(new byte[0]), ByteBuffer.wrap(new byte[0]), false, 150);
    SlicePredicate sp = new SlicePredicate();
    sp.setSlice_range(sr);

    KeyRange range = new KeyRange();
    range.setStart_key( "".getBytes());
    range.setEnd_key( "".getBytes());

    Map<String, List<Column>> keySlices = se.fromBytesMap(keyspace.getRangeSlices(clp, sp, range));

    assertNotNull(keySlices);

    assertNotNull("testGetRangeSlices1 is null", keySlices.get("testGetRangeSlices1"));
    assertEquals("testGetRangeSlices_Value_0", string(keySlices.get("testGetRangeSlices1").get(0).getValue()));
    assertEquals(10, keySlices.get("testGetRangeSlices1").size());

    ColumnPath cp = new ColumnPath("Standard2");
    keyspace.remove("testGetRanageSlices0", cp);
    keyspace.remove("testGetRanageSlices1", cp);
    keyspace.remove("testGetRanageSlices2", cp);
  }
View Full Code Here

  }

  @Test
  public void testGetSuperRangeSlice() throws HectorException {
    for (int i = 0; i < 10; i++) {
      ColumnPath cp = new ColumnPath("Super1");
      cp.setSuper_column(bytes("SuperColumn_1"));
      cp.setColumn(bytes("testGetSuperRangeSlice_" + i));
      keyspace.insert("testGetSuperRangeSlice0", cp, StringSerializer.get().toByteBuffer("testGetSuperRangeSlice_Value_" + i));
      keyspace.insert("testGetSuperRangeSlice1", cp, StringSerializer.get().toByteBuffer("testGetSuperRangeSlice_Value_" + i));
    }

    // get value
    ColumnParent clp = new ColumnParent("Super1");
    SliceRange sr = new SliceRange(ByteBuffer.wrap(new byte[0]), ByteBuffer.wrap(new byte[0]), false, 150);
    SlicePredicate sp = new SlicePredicate();
    sp.setSlice_range(sr);

    /*
    @SuppressWarnings("deprecation")
    Map<String, List<SuperColumn>> keySlices = keyspace.getSuperRangeSlice(clp, sp,
        "testGetSuperRangeSlice0", "testGetSuperRangeSlice3", 5);

    assertNotNull(keySlices);
    assertEquals(2, keySlices.size());
    assertNotNull("testGetSuperRangSlice0 is null", keySlices.get("testGetSuperRangeSlice0"));
    assertEquals("testGetSuperRangeSlice_Value_0",
        string(keySlices.get("testGetSuperRangeSlice0").get(0).getColumns().get(0).getValue()));
    assertEquals(1, keySlices.get("testGetSuperRangeSlice1").size());
    assertEquals(10, keySlices.get("testGetSuperRangeSlice1").get(0).getColumns().size());
    */

    ColumnPath cp = new ColumnPath("Super1");
    keyspace.remove("testGetSuperRangeSlice0", cp);
    keyspace.remove("testGetSuperRangeSlice1", cp);
  }
View Full Code Here

  }

  @Test
  public void testGetSuperRangeSlices() throws HectorException {
    for (int i = 0; i < 10; i++) {
      ColumnPath cp = new ColumnPath("Super1");
      cp.setSuper_column(bytes("SuperColumn_1"));
      cp.setColumn(bytes("testGetSuperRangeSlices_" + i));
      keyspace.insert("testGetSuperRangeSlices0", cp, StringSerializer.get().toByteBuffer("testGetSuperRangeSlices_Value_" + i));
      keyspace.insert("testGetSuperRangeSlices1", cp, StringSerializer.get().toByteBuffer("testGetSuperRangeSlices_Value_" + i));
    }

    // get value
    ColumnParent clp = new ColumnParent("Super1");
    SliceRange sr = new SliceRange(ByteBuffer.wrap(new byte[0]), ByteBuffer.wrap(new byte[0]), false, 150);
    SlicePredicate sp = new SlicePredicate();
    sp.setSlice_range(sr);

    KeyRange range = new KeyRange();
    range.setStart_key( "".getBytes());
    range.setEnd_key( "".getBytes());


    Map<String, List<SuperColumn>> keySlices = se.fromBytesMap(keyspace.getSuperRangeSlices(clp, sp, range));

    assertNotNull(keySlices);

    assertNotNull("testGetSuperRangSlices0 is null", keySlices.get("testGetSuperRangeSlices0"));
    assertEquals("testGetSuperRangeSlices_Value_0",
        string(keySlices.get("testGetSuperRangeSlices0").get(0).getColumns().get(0).getValue()));
    assertEquals(1, keySlices.get("testGetSuperRangeSlices1").size());
    assertEquals(10, keySlices.get("testGetSuperRangeSlices1").get(0).getColumns().size());

    ColumnPath cp = new ColumnPath("Super1");
    keyspace.remove("testGetSuperRangeSlices0", cp);
    keyspace.remove("testGetSuperRangeSlices1", cp);
  }
View Full Code Here

  public void testMultigetCount() {
    // insert 25 columns into 10 rows
    List<ByteBuffer> keys = new ArrayList<ByteBuffer>();
    for ( int j=0; j < 10; j++ ) {
      for (int i = 0; i < 25; i++) {
        ColumnPath cp = new ColumnPath("Standard1");
        cp.setColumn(StringSerializer.get().toByteBuffer("testMultigetCount_column_" + i));
        keyspace.insert("testMultigetCount_key_"+j, cp, StringSerializer.get().toByteBuffer("testMultigetCount_value_" + i));
      }
      if (j % 2 == 0) {
        keys.add(StringSerializer.get().toByteBuffer("testMultigetCount_key_"+j));
      }
View Full Code Here

      Serializer<N> nameSerializer) {
    return createColumnPath(columnFamilyName, nameSerializer.toByteBuffer(columnName));
  }
  private static <N> ColumnPath createColumnPath(String columnFamilyName, ByteBuffer columnName) {
    notNull(columnFamilyName, "columnFamilyName cannot be null");
    ColumnPath columnPath = new ColumnPath(columnFamilyName);
    if (columnName != null) {
      columnPath.setColumn(columnName);
    }
    return columnPath;
  }
View Full Code Here

  public static <SN,N> ColumnPath createSuperColumnPath(String columnFamilyName,
      SN superColumnName, N columnName, Serializer<SN> superNameSerializer,
      Serializer<N> nameSerializer) {
    noneNull(columnFamilyName, superColumnName, superNameSerializer, nameSerializer);
    ColumnPath columnPath = createColumnPath(columnFamilyName, nameSerializer.toByteBuffer(columnName));
    columnPath.setSuper_column(superNameSerializer.toByteBuffer(superColumnName));
    return columnPath;
  }
View Full Code Here

  }

  /*package*/ static <SN> ColumnPath createSuperColumnPath(String columnFamilyName,
      SN superColumnName, Serializer<SN> superNameSerializer) {
    noneNull(columnFamilyName, superNameSerializer);
    ColumnPath columnPath = createColumnPath(columnFamilyName, null);
    if (superColumnName != null) {
      columnPath.setSuper_column(superNameSerializer.toByteBuffer(superColumnName));
    }
    return columnPath;
  }
View Full Code Here

TOP

Related Classes of org.apache.cassandra.thrift.ColumnPath

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.