Package org.apache.cassandra.thrift

Examples of org.apache.cassandra.thrift.SuperColumn


        // Print out super columns or columns.
        for (ColumnOrSuperColumn cosc : columns)
        {
            if (cosc.isSetSuper_column())
            {
                SuperColumn superColumn = cosc.super_column;

                css_.out.printf("=> (super_column=%s,", formatSuperColumnName(keyspace, columnFamily, superColumn));
                for (Column col : superColumn.getColumns())
                    css_.out.printf("\n     (column=%s, value=%s, timestamp=%d)", formatSubcolumnName(keyspace, columnFamily, col),
                                    new String(col.value, "UTF-8"), col.timestamp);
               
                css_.out.println(")");
            }
View Full Code Here


        // Print out super columns or columns.
        for (ColumnOrSuperColumn cosc : columns)
        {
            if (cosc.isSetSuper_column())
            {
                SuperColumn superColumn = cosc.super_column;

                css_.out.printf("=> (super_column=%s,", formatSuperColumnName(keyspace, columnFamily, superColumn));
                for (Column col : superColumn.getColumns())
                    css_.out.printf("\n     (column=%s, value=%s, timestamp=%d)", formatSubcolumnName(keyspace, columnFamily, col),
                                    new String(col.value, "UTF-8"), col.timestamp);
               
                css_.out.println(")");
            }
View Full Code Here

                    }
                    else
                    {
                        for (ColumnOrSuperColumn col : row)
                        {
                            SuperColumn superColumn = col.getSuper_column();
                            if (superColumn.getColumns().size() != expect.size())
                                return false;
                            for (int i = 0 ; i < expect.size() ; i++)
                                if (!superColumn.getColumns().get(i).bufferForValue().equals(expect.get(i)))
                                    return false;
                        }
                    }
                    return true;
                }
View Full Code Here

    keyspace.insert(StringSerializer.get().toByteBuffer("testInsertSuper_key"), columnParent, column);

    // get value and assert
    ColumnPath cp2 = new ColumnPath("Super1");
    cp2.setSuper_column(bytes("testInsertSuper_super"));
    SuperColumn sc = keyspace.getSuperColumn("testInsertSuper_key", cp2);
    assertNotNull(sc);
    assertEquals("testInsertSuper_super", string(sc.getName()));
    assertEquals(2, sc.getColumns().size());
    assertEquals("testInsertSuper_value", string(sc.getColumns().get(0).getValue()));

    // remove value
    keyspace.remove("testInsertSuper_super", cp2);
  }
View Full Code Here

    assertEquals(2, mutationMap.get(StringSerializer.get().toByteBuffer("key1")).get("Standard1").size());
  }

  @Test
  public void testAddSuperInsertion() {
    SuperColumn sc = new SuperColumn(StringSerializer.get().toByteBuffer("c_name"),
        Arrays.asList(new Column(StringSerializer.get().toByteBuffer("c_name"), StringSerializer.get().toByteBuffer("c_val"), System.currentTimeMillis())));
    batchMutate.addSuperInsertion("key1", columnFamilies, sc);
    // assert there is one outter map row with 'key' as the key
    assertEquals(1, batchMutate.getMutationMap().get(StringSerializer.get().toByteBuffer("key1")).size());

    // add again with a different column and verify there is one key and two mutations underneath
    // for "standard1"
    SuperColumn sc2 = new SuperColumn(StringSerializer.get().toByteBuffer("c_name2"),
        Arrays.asList(new Column(StringSerializer.get().toByteBuffer("c_name"), StringSerializer.get().toByteBuffer("c_val"), System.currentTimeMillis())));
    batchMutate.addSuperInsertion("key1", columnFamilies, sc2);
    assertEquals(2, batchMutate.getMutationMap().get(StringSerializer.get().toByteBuffer("key1")).get("Standard1").size());
  }
View Full Code Here

  public SuperColumn toThrift() {
    if (superName == null || columns == null) {
      return null;
    }
    return new SuperColumn(superNameSerializer.toByteBuffer(superName), toThriftColumn());
  }
View Full Code Here

        be);
    Assert.assertTrue(slice.getSuperColumns().isEmpty());

    // non-empty one
    Column c = new Column(le.toByteBuffer(5L), be.toByteBuffer(ByteBuffer.wrap(new byte[] { 1 })), 2L);
    tColumns.add(new SuperColumn(se.toByteBuffer("super"), Arrays.asList(c)));
    slice = new SuperSliceImpl<String, Long, ByteBuffer>(tColumns, se, le, be);
    Assert.assertEquals(1, slice.getSuperColumns().size());
    Assert.assertEquals((Long) 5L, slice.getColumnByName("super").get(0).getName());
  }
View Full Code Here

          List<ColumnOrSuperColumn> cosc = cassandra.get_slice(key, clp, sp,
              getThriftCl(OperationType.READ));
          if (cosc == null || cosc.isEmpty()) {
            return null;
          }
          return new SuperColumn(ByteBuffer.wrap(columnPath.getSuper_column()), getColumnList(cosc));
        } catch (Exception e) {
          throw xtrans.translate(e);
        }
      }
    };
View Full Code Here

            }
            return result;
          } else {
            Map<ByteBuffer, List<SuperColumn>> result = new HashMap<ByteBuffer, List<SuperColumn>>();
            for (Map.Entry<ByteBuffer, List<ColumnOrSuperColumn>> entry : cfmap.entrySet()) {
              SuperColumn spc = new SuperColumn(ByteBuffer.wrap(columnParent.getSuper_column()),
                  getColumnList(entry.getValue()));
              ArrayList<SuperColumn> spclist = new ArrayList<SuperColumn>(1);
              spclist.add(spc);
              result.put(entry.getKey(), spclist);
            }
View Full Code Here

  public Mutate put(String superColumnFamily, String superColumnName,
      String columnName, byte[] value, long timestamp) {

    Mutation mutation = new Mutation();
    ColumnOrSuperColumn csc = new ColumnOrSuperColumn();
    csc.super_column = new SuperColumn();
    csc.super_column.name = ByteUtils.toBytes(superColumnName);
    // TODO: This will probably be slow. Try to group all columns
    // under a supercolumn within a single mutation object
    csc.super_column.addToColumns(
        new Column(ByteUtils.toBytes(columnName), value, timestamp));
View Full Code Here

TOP

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

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.