public SuperColumn toThrift() { if (superName == null || columns == null) { return null; } return new SuperColumn(superNameSerializer.toByteBuffer(superName), toThriftColumn()); }
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);
@Test public void getSizeForColumnOrSuperColumnWithANonEmptyColumnAndSuperColumn() { assertThat(ThriftObjectSizeUtils.getColumnOrSuperColumnSize(new ColumnOrSuperColumn() .setColumn(TEST_COLUMN) .setSuper_column(new SuperColumn(ByteBuffer.wrap(TEST_NAME.getBytes()), ImmutableList.of(TEST_COLUMN))))) .isEqualTo(NULL_SIZE * 2 + TEST_COLUMN_SIZE + TEST_NAME_BYTES_SIZE + TEST_COLUMN_SIZE); }
@Override public SuperColumn execute(Cassandra.Client cassandra) throws HectorException { ColumnParent clp = new ColumnParent(columnPath.getColumn_family()); clp.setSuper_column(columnPath.getSuper_column()); SlicePredicate sp = new SlicePredicate(); sp.setSlice_range(sliceRange); try { 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); } } };
if (thriftSuperColumn == null) thriftSuperColumn = new SuperColumn(); thriftSuperColumn.setName(PropertyAccessorFactory.STRING.toBytes(superColumnName)); tableToSuperColumns.put(columnFamilyName, thriftSuperColumn);
SuperColumn superCol = new SuperColumn(); superCol.setName(name); Column column = prepareColumn((byte[]) value, name, timestamp, 0);
public SuperColumn deepCopy() { return new SuperColumn(this); }
public SuperColumn deepCopy() { return new SuperColumn(this); }
public SuperColumn deepCopy() { return new SuperColumn(this); }
@Test public void testConstruction() { LongSerializer le = LongSerializer.get(); StringSerializer se = StringSerializer.get(); ByteBufferSerializer be = ByteBufferSerializer.get(); // empty one List<SuperColumn> tColumns = new ArrayList<SuperColumn>(); SuperSlice<String, Long, ByteBuffer> slice = new SuperSliceImpl<String, Long, ByteBuffer>(tColumns, se, le, be); Assert.assertTrue(slice.getSuperColumns().isEmpty()); // non-empty one Column c = new Column(le.toByteBuffer(5L)); c.setValue(be.toByteBuffer(ByteBuffer.wrap(new byte[] { 1 }))); c.setTimestamp(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()); } }
@Test public void testAddSuperInsertion() { Column column = new Column(StringSerializer.get().toByteBuffer("c_name")); column.setValue(StringSerializer.get().toByteBuffer("c_val")); column.setTimestamp(System.currentTimeMillis()); SuperColumn sc = new SuperColumn(StringSerializer.get().toByteBuffer("c_name"), Arrays.asList(column)); 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" column = new Column(StringSerializer.get().toByteBuffer("c_name")); column.setValue(StringSerializer.get().toByteBuffer("c_val")); column.setTimestamp(System.currentTimeMillis()); SuperColumn sc2 = new SuperColumn(StringSerializer.get().toByteBuffer("c_name2"), Arrays.asList(column)); batchMutate.addSuperInsertion("key1", columnFamilies, sc2); assertEquals(2, batchMutate.getMutationMap().get(StringSerializer.get().toByteBuffer("key1")).get("Standard1").size()); }
tf.addCounterSuperColumn(counterSuperColumn); } else { SuperColumn superColumn = new SuperColumn(); superColumn.setName(linkName.getBytes()); Column column = populateFkey(linkName, linkValue, timestamp);
SuperColumn thriftSuperColumn = new SuperColumn(); thriftSuperColumn.setName(indexColumnName);
public SuperColumn toThrift() { if (superName == null || columns == null) { return null; } return new SuperColumn(superNameSerializer.toByteBuffer(superName), toThriftColumn()); }
public SuperColumn toThrift() { if (superName == null || columns == null) { return null; } return new SuperColumn(superNameSerializer.toByteBuffer(superName), toThriftColumn()); }
private void addMutation(Column column) { // 2. Create the super column mutation if this is the first call if (superColumn == null) { superColumn = new SuperColumn().setName(path.get(0)); Mutation mutation = new Mutation(); mutation.setColumn_or_supercolumn(new ColumnOrSuperColumn().setSuper_column(superColumn)); mutationList.add(mutation); } superColumn.addToColumns(column); }
private void addMutation(Column column) { // 2. Create the super column mutation if this is the first call if (superColumn == null) { superColumn = new SuperColumn().setName(path.get(0)); Mutation mutation = new Mutation(); mutation.setColumn_or_supercolumn(new ColumnOrSuperColumn().setSuper_column(superColumn)); mutationList.add(mutation); } superColumn.addToColumns(column); }
@Override public SuperColumn execute(Cassandra.Client cassandra) throws HectorException { ColumnParent clp = new ColumnParent(columnPath.getColumn_family()); clp.setSuper_column(columnPath.getSuper_column()); SlicePredicate sp = new SlicePredicate(); sp.setSlice_range(sliceRange); try { 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); } } };
@Override public SuperColumn execute(Cassandra.Client cassandra) throws HectorException { ColumnParent clp = new ColumnParent(columnPath.getColumn_family()); clp.setSuper_column(columnPath.getSuper_column()); SlicePredicate sp = new SlicePredicate(); sp.setSlice_range(sliceRange); try { 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); } } };
/** * Performs a deep copy on <i>other</i>. */ public ColumnOrSuperColumn(ColumnOrSuperColumn other) { if (other.isSetColumn()) { this.column = new Column(other.column); } if (other.isSetSuper_column()) { this.super_column = new SuperColumn(other.super_column); } if (other.isSetCounter_column()) { this.counter_column = new CounterColumn(other.counter_column); } if (other.isSetCounter_super_column()) { this.counter_super_column = new CounterSuperColumn(other.counter_super_column); } }