Refine search
String scName = PropertyAccessorFactory.STRING.fromBytes(String.class, sc.getName()); String scNamePrefix = null; for (Column column : sc.getColumns()) String name = PropertyAccessorFactory.STRING.fromBytes(String.class, column.getName()); byte[] value = column.getValue(); if (value == null) embeddedObject = superColumnClass.newInstance(); for (Column column : sc.getColumns()) String name = PropertyAccessorFactory.STRING.fromBytes(String.class, column.getName()); byte[] value = column.getValue();
Column thriftColumn = new Column(); thriftColumn.setName(PropertyAccessorFactory.STRING.toBytes(name)); thriftColumn.setValue(value); thriftColumn.setTimestamp(timestamp); thriftColumns.add(thriftColumn); if (thriftSuperColumn == null) thriftSuperColumn = new SuperColumn(); thriftSuperColumn.setName(PropertyAccessorFactory.STRING.toBytes(superColumnName)); tableToSuperColumns.put(columnFamilyName, thriftSuperColumn); thriftSuperColumn.addToColumns(thriftColumn);
SuperColumn superCol = new SuperColumn(); superCol.setName(name); Column column = prepareColumn((byte[]) value, name, timestamp, 0); List<Column> subColumn = new ArrayList<Column>(); subColumn.add(column); superCol.setColumns(subColumn); tr.addSuperColumn(superCol);
public HSuperColumnImpl(SuperColumn thriftSuperColumn, Serializer<SN> sNameSerializer, Serializer<N> nameSerializer, Serializer<V> valueSerializer) { this(sNameSerializer, nameSerializer, valueSerializer); noneNull(thriftSuperColumn, sNameSerializer, nameSerializer); superName = sNameSerializer.fromByteBuffer(ByteBuffer.wrap(thriftSuperColumn.getName())); columns = fromThriftColumns(thriftSuperColumn.getColumns()); }
/** * Test insertion of a supercolumn using insert */ @Test public void testInsertSuper() throws IllegalArgumentException, NoSuchElementException, IllegalStateException, HNotFoundException, Exception { // insert value ColumnParent columnParent = new ColumnParent("Super1"); columnParent.setSuper_column(StringSerializer.get().toByteBuffer("testInsertSuper_super")); Column column = new Column(StringSerializer.get().toByteBuffer("testInsertSuper_column")); column.setValue(StringSerializer.get().toByteBuffer("testInsertSuper_value")); column.setTimestamp(connectionManager.createClock()); keyspace.insert(StringSerializer.get().toByteBuffer("testInsertSuper_key"), columnParent, column); column.setName(StringSerializer.get().toByteBuffer("testInsertSuper_column2")); 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); }
private List<ColumnOrSuperColumn> thriftifySuperColumns(Iterator<LegacyLayout.LegacyCell> cells, boolean reversed) { ArrayList<ColumnOrSuperColumn> thriftSuperColumns = new ArrayList<>(); SuperColumn current = null; while (cells.hasNext()) { LegacyLayout.LegacyCell cell = cells.next(); ByteBuffer scName = cell.name.superColumnName(); if (current == null || !scName.equals(current.bufferForName())) { // Generally, cells come reversed if the query is reverse. However, this is not the case within a super column because // internally a super column is a map within a row and those are never returned reversed. if (current != null && reversed) Collections.reverse(current.columns); current = new SuperColumn(scName, new ArrayList<>()); thriftSuperColumns.add(new ColumnOrSuperColumn().setSuper_column(current)); } current.getColumns().add(thriftifySubColumn(cell, cell.name.superColumnSubName())); } if (current != null && reversed) Collections.reverse(current.columns); return thriftSuperColumns; }
if (DataType.findType(pair.get(1)) == DataType.BAG) // supercolumn SuperColumn sc = new SuperColumn(); sc.setName(objToBB(pair.get(0))); List<org.apache.cassandra.thrift.Column> columns = new ArrayList<org.apache.cassandra.thrift.Column>(); for (Tuple subcol : (DataBag) pair.get(1)) org.apache.cassandra.thrift.Column column = new org.apache.cassandra.thrift.Column(); column.setName(objToBB(subcol.get(0))); column.setValue(objToBB(subcol.get(1))); column.setTimestamp(FBUtilities.timestampMicros()); columns.add(column); mutation.column_or_supercolumn = new ColumnOrSuperColumn(); mutation.column_or_supercolumn.super_column = sc;
@Override public void read(org.apache.thrift.protocol.TProtocol prot, ColumnOrSuperColumn struct) throws org.apache.thrift.TException { TTupleProtocol iprot = (TTupleProtocol) prot; BitSet incoming = iprot.readBitSet(4); if (incoming.get(0)) { struct.column = new Column(); struct.column.read(iprot); struct.setColumnIsSet(true); } if (incoming.get(1)) { struct.super_column = new SuperColumn(); struct.super_column.read(iprot); struct.setSuper_columnIsSet(true); } if (incoming.get(2)) { struct.counter_column = new CounterColumn(); struct.counter_column.read(iprot); struct.setCounter_columnIsSet(true); } if (incoming.get(3)) { struct.counter_super_column = new CounterSuperColumn(); struct.counter_super_column.read(iprot); struct.setCounter_super_columnIsSet(true); } } }
private void constructMap() { if (lookup == null) { lookup = Maps.newHashMap(); for (ColumnOrSuperColumn column : columns) { if (column.isSetSuper_column()) { lookup.put(colSer.fromBytes(column.getSuper_column().getName()), column); } else if (column.isSetColumn()) { lookup.put(colSer.fromBytes(column.getColumn().getName()), column); } else if (column.isSetCounter_column()) { lookup.put(colSer.fromBytes(column.getCounter_column().getName()), column); } else if (column.isSetCounter_super_column()) { lookup.put(colSer.fromBytes(column.getCounter_super_column().getName()), column); } else { throw new UnsupportedOperationException("Unknown column type"); } } } }
@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()); } }
/** * 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); } }
@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); }
if (cosc.isSetCounter_column()) { CounterColumn counterCol = cosc.getCounter_column(); logger.trace(" {} += ({})", Utils.deWhite(counterCol.getName()), counterCol.getValue()); } else if (cosc.isSetColumn()) { Column col = cosc.getColumn(); String colValue = Utils.deWhite(col.getValue()); if (colValue == null || colValue.length() == 0) colValue = "[null]"; logger.trace(" {} : {}", Utils.deWhite(col.getName()), colValue); } else if (cosc.isSetSuper_column()) { SuperColumn superCol = cosc.getSuper_column(); logger.trace(" Supercolumn '{}' set", Utils.deWhite(superCol.getName()));
@Override public <C2> Column<C2> getSuperColumn(int idx, Serializer<C2> colSer) { ColumnOrSuperColumn column = this.columns.get(idx); if (column == null) { // TODO: throw an exception return null; } else if (column.isSetSuper_column()) { SuperColumn sc = column.getSuper_column(); return new ThriftSuperColumnImpl<C2>(colSer.fromBytes(sc.getName()), sc); } else if (column.isSetCounter_super_column()) { CounterSuperColumn sc = column.getCounter_super_column(); return new ThriftCounterSuperColumnImpl<C2>(colSer.fromBytes(sc.getName()), sc); } throw new UnsupportedOperationException("\'" + idx + "\' is not a super column"); }
Map<String, Field> superColumnFieldMap) for (Column column : superColumn.getColumns()) String thriftColumnName = PropertyAccessorFactory.STRING.fromBytes(String.class, column.getName()); byte[] thriftColumnValue = column.getValue(); PropertyAccessorHelper.set(embeddedObject, superColumnFieldMap.get(thriftColumnName), thriftColumnValue);
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); }
if (cosc.isSetSuper_column()) for (Column col : superColumn.getColumns()) validator = getValidatorForValue(cfDef, col.getName()); sessionState.out.printf("%n (name=%s, value=%s, timestamp=%d%s)", formatSubcolumnName(keyspace, columnFamily, col.name), validator.getString(col.value), col.timestamp, col.isSetTtl() ? String.format(", ttl=%d", col.getTtl()) : ""); else if (cosc.isSetColumn()) column.isSetTtl() ? String.format(", ttl=%d", column.getTtl()) : ""); else if (cosc.isSetCounter_super_column())
String thriftColumnName = PropertyAccessorFactory.STRING.fromBytes(String.class, column.getName()); if ((CassandraConstants.CQL_KEY.equalsIgnoreCase(thriftColumnName) || ((AbstractAttribute) m .getIdAttribute()).getJPAColumnName().equals(thriftColumnName)) && tr.getId() == null) setId(m, entity, column.getValue(), isCql3Enabled); && column.getValue() != null && !PropertyAccessorFactory.STRING.fromBytes(String.class, column.getValue()).equals( discriminatorValue)) String scName = PropertyAccessorFactory.STRING.fromBytes(String.class, superColumn.getName()); String scNamePrefix = null;
public SuperColumn toThrift() { if (superName == null || columns == null) { return null; } return new SuperColumn(superNameSerializer.toByteBuffer(superName), toThriftColumn()); }
boolean isCql3Enabled) throws InstantiationException, IllegalAccessException for (Column column : superColumn.getColumns())