当前位置: 首页>>代码示例>>Java>>正文


Java ColumnFamily.delete方法代码示例

本文整理汇总了Java中org.apache.cassandra.db.ColumnFamily.delete方法的典型用法代码示例。如果您正苦于以下问题:Java ColumnFamily.delete方法的具体用法?Java ColumnFamily.delete怎么用?Java ColumnFamily.delete使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.cassandra.db.ColumnFamily的用法示例。


在下文中一共展示了ColumnFamily.delete方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testResolveDeleted

import org.apache.cassandra.db.ColumnFamily; //导入方法依赖的package包/类
@Test
public void testResolveDeleted()
{
    // one CF with columns timestamped before a delete in another cf
    ColumnFamily cf1 = ArrayBackedSortedColumns.factory.create("Keyspace1", "Standard1");
    cf1.addColumn(column("one", "A", 0));

    ColumnFamily cf2 = ArrayBackedSortedColumns.factory.create("Keyspace1", "Standard1");
    cf2.delete(new DeletionInfo(1L, (int) (System.currentTimeMillis() / 1000)));

    ColumnFamily resolved = RowDataResolver.resolveSuperset(Arrays.asList(cf1, cf2), System.currentTimeMillis());
    // no columns in the cf
    assertColumns(resolved);
    assertTrue(resolved.isMarkedForDelete());
    assertEquals(1, resolved.deletionInfo().getTopLevelDeletion().markedForDeleteAt);
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:17,代码来源:RowResolverTest.java

示例2: testResolveDeleted

import org.apache.cassandra.db.ColumnFamily; //导入方法依赖的package包/类
@Test
public void testResolveDeleted()
{
    // one CF with columns timestamped before a delete in another cf
    ColumnFamily cf1 = TreeMapBackedSortedColumns.factory.create("Keyspace1", "Standard1");
    cf1.addColumn(column("one", "A", 0));

    ColumnFamily cf2 = TreeMapBackedSortedColumns.factory.create("Keyspace1", "Standard1");
    cf2.delete(new DeletionInfo(1L, (int) (System.currentTimeMillis() / 1000)));

    ColumnFamily resolved = RowDataResolver.resolveSuperset(Arrays.asList(cf1, cf2), System.currentTimeMillis());
    // no columns in the cf
    assertColumns(resolved);
    assertTrue(resolved.isMarkedForDelete());
    assertEquals(1, resolved.deletionInfo().getTopLevelDeletion().markedForDeleteAt);
}
 
开发者ID:pgaref,项目名称:ACaZoo,代码行数:17,代码来源:RowResolverTest.java

示例3: testResolveMultipleDeleted

import org.apache.cassandra.db.ColumnFamily; //导入方法依赖的package包/类
@Test
public void testResolveMultipleDeleted()
{
    // deletes and columns with interleaved timestamp, with out of order return sequence

    ColumnFamily cf1 = ArrayBackedSortedColumns.factory.create("Keyspace1", "Standard1");
    cf1.delete(new DeletionInfo(0L, (int) (System.currentTimeMillis() / 1000)));

    // these columns created after the previous deletion
    ColumnFamily cf2 = ArrayBackedSortedColumns.factory.create("Keyspace1", "Standard1");
    cf2.addColumn(column("one", "A", 1));
    cf2.addColumn(column("two", "A", 1));

    //this column created after the next delete
    ColumnFamily cf3 = ArrayBackedSortedColumns.factory.create("Keyspace1", "Standard1");
    cf3.addColumn(column("two", "B", 3));

    ColumnFamily cf4 = ArrayBackedSortedColumns.factory.create("Keyspace1", "Standard1");
    cf4.delete(new DeletionInfo(2L, (int) (System.currentTimeMillis() / 1000)));

    ColumnFamily resolved = RowDataResolver.resolveSuperset(Arrays.asList(cf1, cf2, cf3, cf4), System.currentTimeMillis());
    // will have deleted marker and one column
    assertColumns(resolved, "two");
    assertColumn(resolved, "two", "B", 3);
    assertTrue(resolved.isMarkedForDelete());
    assertEquals(2, resolved.deletionInfo().getTopLevelDeletion().markedForDeleteAt);
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:28,代码来源:RowResolverTest.java

示例4: testResolveMultipleDeleted

import org.apache.cassandra.db.ColumnFamily; //导入方法依赖的package包/类
@Test
public void testResolveMultipleDeleted()
{
    // deletes and columns with interleaved timestamp, with out of order return sequence

    ColumnFamily cf1 = TreeMapBackedSortedColumns.factory.create("Keyspace1", "Standard1");
    cf1.delete(new DeletionInfo(0L, (int) (System.currentTimeMillis() / 1000)));

    // these columns created after the previous deletion
    ColumnFamily cf2 = TreeMapBackedSortedColumns.factory.create("Keyspace1", "Standard1");
    cf2.addColumn(column("one", "A", 1));
    cf2.addColumn(column("two", "A", 1));

    //this column created after the next delete
    ColumnFamily cf3 = TreeMapBackedSortedColumns.factory.create("Keyspace1", "Standard1");
    cf3.addColumn(column("two", "B", 3));

    ColumnFamily cf4 = TreeMapBackedSortedColumns.factory.create("Keyspace1", "Standard1");
    cf4.delete(new DeletionInfo(2L, (int) (System.currentTimeMillis() / 1000)));

    ColumnFamily resolved = RowDataResolver.resolveSuperset(Arrays.asList(cf1, cf2, cf3, cf4), System.currentTimeMillis());
    // will have deleted marker and one column
    assertColumns(resolved, "two");
    assertColumn(resolved, "two", "B", 3);
    assertTrue(resolved.isMarkedForDelete());
    assertEquals(2, resolved.deletionInfo().getTopLevelDeletion().markedForDeleteAt);
}
 
开发者ID:pgaref,项目名称:ACaZoo,代码行数:28,代码来源:RowResolverTest.java

示例5: testExportColumnsWithMetadata

import org.apache.cassandra.db.ColumnFamily; //导入方法依赖的package包/类
@Test
public void testExportColumnsWithMetadata() throws IOException, ParseException
{

    File tempSS = tempSSTableFile("Keyspace1", "Standard1");
    ColumnFamily cfamily = TreeMapBackedSortedColumns.factory.create("Keyspace1", "Standard1");
    SSTableWriter writer = new SSTableWriter(tempSS.getPath(), 2);

    // Add rowA
    cfamily.addColumn(ByteBufferUtil.bytes("colName"), ByteBufferUtil.bytes("val"), System.currentTimeMillis());
    cfamily.addColumn(ByteBufferUtil.bytes("colName1"), ByteBufferUtil.bytes("val1"), System.currentTimeMillis());
    cfamily.delete(new DeletionInfo(0, 0));
    writer.append(Util.dk("rowA"), cfamily);

    SSTableReader reader = writer.closeAndOpenReader();
    // Export to JSON and verify
    File tempJson = File.createTempFile("CFWithDeletionInfo", ".json");
    SSTableExport.export(reader, new PrintStream(tempJson.getPath()), new String[0]);

    JSONArray json = (JSONArray)JSONValue.parseWithException(new FileReader(tempJson));
    System.out.println(json.toJSONString());
    assertEquals("unexpected number of rows", 1, json.size());

    JSONObject row = (JSONObject)json.get(0);
    assertEquals("unexpected number of keys", 3, row.keySet().size());
    assertEquals("unexpected row key",asHex("rowA"),row.get("key"));

    // check that the row key is there and present
    String rowKey = (String) row.get("key");
    assertNotNull("expecing key to be present", rowKey);
    assertEquals("key did not match", ByteBufferUtil.bytes("rowA"), hexToBytes(rowKey));

    // check that there is metadata and that it contains deletionInfo
    JSONObject meta = (JSONObject) row.get("metadata");
    assertNotNull("expecing metadata to be present", meta);

    assertEquals("unexpected number of metadata entries", 1, meta.keySet().size());

    JSONObject serializedDeletionInfo = (JSONObject) meta.get("deletionInfo");
    assertNotNull("expecing deletionInfo to be present", serializedDeletionInfo);

    assertEquals(
            "unexpected serialization format for topLevelDeletion",
            "{\"markedForDeleteAt\":0,\"localDeletionTime\":0}",
            serializedDeletionInfo.toJSONString());

    // check the colums are what we put in
    JSONArray cols = (JSONArray) row.get("columns");
    assertNotNull("expecing columns to be present", cols);
    assertEquals("expecting two columns", 2, cols.size());

    JSONArray col1 = (JSONArray) cols.get(0);
    assertEquals("column name did not match", ByteBufferUtil.bytes("colName"), hexToBytes((String) col1.get(0)));
    assertEquals("column value did not match", ByteBufferUtil.bytes("val"), hexToBytes((String) col1.get(1)));

    JSONArray col2 = (JSONArray) cols.get(1);
    assertEquals("column name did not match", ByteBufferUtil.bytes("colName1"), hexToBytes((String) col2.get(0)));
    assertEquals("column value did not match", ByteBufferUtil.bytes("val1"), hexToBytes((String) col2.get(1)));

}
 
开发者ID:pgaref,项目名称:ACaZoo,代码行数:61,代码来源:SSTableExportTest.java


注:本文中的org.apache.cassandra.db.ColumnFamily.delete方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。