private static Column getNamedColumn(List<Column> columns, String columnName) { return Iterables.getOnlyElement( columns.stream() .filter(column -> columnName.equals(PtBytes.toString(column.getName()))) .collect(Collectors.toList())); }
private static String decodeCqlColumnName(Column column) { return PtBytes.toString(column.getName()); } }
/** * @param result * @param entityMetadata * @param em * @return */ private List onNativeCassResults(List result, EntityMetadata entityMetadata, EntityManager em) { Map<String, Client<Query>> clients = (Map<String, Client<Query>>) em.getDelegate(); Client client = clients.get(entityMetadata.getPersistenceUnit()); if((client.getClass().getSimpleName().equals("ThriftClient") || client.getClass().getSimpleName().equals("PelopsClient") || client.getClass().getSimpleName().equals("DSClient")) && Column.class.equals(result.get(0).getClass())) { int count = 0; for(Object column : result) { Map<Object, Object> valueMap = new HashMap<Object, Object>(); valueMap.put(PropertyAccessorHelper.getObject(String.class, ((Column) column).getName()), PropertyAccessorHelper.getObject(Long.class, ((Column) column).getValue())); result.set(count, valueMap); count ++; } } return result; }
/** * Convenience method to get the name buffer for the specified column and * decompose it into the name and timestamp. */ public static Pair<byte[], Long> decomposeName(Column column) { ByteBuffer nameBuffer; if (column.isSetName()) { nameBuffer = column.bufferForName(); } else { // the column buffer has not yet been set/cached // so we must fallback on the slowpath and force // the transform to bytes and wrap ourselves nameBuffer = ByteBuffer.wrap(column.getName()); } return decompose(nameBuffer); }
String thriftColumnName = PropertyAccessorFactory.STRING.fromBytes(String.class, c.getName());
String thriftColumnName = PropertyAccessorFactory.STRING.fromBytes(String.class, column.getName()); byte[] thriftColumnValue = column.getValue(); PropertyAccessorHelper.set(embeddedObject, superColumnFieldMap.get(thriftColumnName), thriftColumnValue);
public static long getColumnSize(Column column) { if (column == null) { return getNullSize(); } return getByteArraySize(column.getValue()) + getByteArraySize(column.getName()) + getTtlSize() + getTimestampSize(); }
for (Column c: rowcolumns) { keyColumnIndex++; String name = StringSerializer.get().fromBytes(c.getName()); if (name.toUpperCase().equals("KEY")) { kbb = ByteBuffer.wrap(c.getValue());
byte[] columnName = column.getName(); searchResult.setPrimaryKey(PropertyAccessorHelper.getObject(m.getIdAttribute().getJavaType(), columnName));
String name = PropertyAccessorFactory.STRING.fromBytes(String.class, column.getName()); byte[] value = column.getValue();
columnDef.setName(column.getName()); columnDef.setValidation_class(CassandraValidationClassMapper.getValidationClass(columnType, false)); columnDef.setIndex_type(IndexType.KEYS); if (!indexList.contains(new StringAccessor().fromBytes(String.class, column.getName()))) { isUpdatable = true; columnFamilyDefToUpdate.addToColumn_metadata(columnDef);
Assert.assertEquals("keyspace_name", ByteBufferUtil.string(ByteBuffer.wrap(cqlRow.getColumns().get(0).getName()))); Assert.assertEquals(keyspaceName, ByteBufferUtil.string(ByteBuffer.wrap(cqlRow.getColumns().get(0).getValue()))); Assert.assertEquals("durable_writes", ByteBufferUtil.string(ByteBuffer.wrap(cqlRow.getColumns().get(1).getName()))); Assert.assertEquals(false, Boolean.getBoolean(ByteBufferUtil.string(ByteBuffer.wrap(cqlRow.getColumns().get(1).getValue())))); Assert.assertEquals("replication", ByteBufferUtil.string(ByteBuffer.wrap(cqlRow.getColumns().get(2).getName()))); Assert.assertEquals("comment", ByteBufferUtil.string(ByteBuffer.wrap(cqlRow.getColumns().get(5).getName()))); Assert.assertTrue(ByteBufferUtil.string(ByteBuffer.wrap(cqlRow.getColumns().get(5).getValue())).isEmpty()); Assert.assertEquals("comparator", ByteBufferUtil.string(ByteBuffer.wrap(cqlRow.getColumns().get(8).getName()))); Assert.assertEquals(UTF8Type.class.getName(), ByteBufferUtil.string(ByteBuffer.wrap(cqlRow.getColumns().get(8).getValue()))); Assert.assertEquals("default_validator", ByteBufferUtil.string(ByteBuffer.wrap(cqlRow.getColumns().get(10).getName()))); Assert.assertEquals(BytesType.class.getName(), Boolean.getBoolean(ByteBufferUtil.string(ByteBuffer.wrap(cqlRow.getColumns().get(10).getValue())))); Assert.assertEquals("max_compaction_threshold", ByteBufferUtil.string(ByteBuffer.wrap(cqlRow.getColumns().get(17).getName()))); Assert.assertEquals(16, ByteBufferUtil.toInt(ByteBuffer.wrap(cqlRow.getColumns().get(17).getValue()))); Assert.assertEquals("min_compaction_threshold", ByteBufferUtil.string(ByteBuffer.wrap(cqlRow.getColumns().get(18).getName()))); Assert.assertEquals(64, ByteBufferUtil.toInt(ByteBuffer.wrap(cqlRow.getColumns().get(18).getValue()))); Assert.assertEquals("replicate_on_write", ByteBufferUtil.string(ByteBuffer.wrap(cqlRow.getColumns().get(21).getName()))); Assert.assertEquals("true", ByteBufferUtil.string(ByteBuffer.wrap(cqlRow.getColumns().get(21).getValue()))); Assert.assertEquals("subcomparator", ByteBufferUtil.string(ByteBuffer.wrap(cqlRow.getColumns().get(22).getName()))); Assert.assertNull(ByteBufferUtil.string(ByteBuffer.wrap(cqlRow.getColumns().get(22).getValue()))); Assert.assertEquals("type", ByteBufferUtil.string(ByteBuffer.wrap(cqlRow.getColumns().get(23).getName()))); Assert.assertEquals("Standard", ByteBufferUtil.string(ByteBuffer.wrap(cqlRow.getColumns().get(23).getValue()))); Assert.assertEquals("comment", ByteBufferUtil.string(ByteBuffer.wrap(cqlRow.getColumns().get(5).getName()))); Assert.assertTrue(ByteBufferUtil.string(ByteBuffer.wrap(cqlRow.getColumns().get(5).getValue())).isEmpty()); Assert.assertEquals("comparator", ByteBufferUtil.string(ByteBuffer.wrap(cqlRow.getColumns().get(8).getName()))); Assert.assertEquals(UTF8Type.class.getName(), ByteBufferUtil.string(ByteBuffer.wrap(cqlRow.getColumns().get(8).getValue()))); Assert.assertEquals("default_validator", ByteBufferUtil.string(ByteBuffer.wrap(cqlRow.getColumns().get(10).getName()))); Assert.assertEquals(BytesType.class.getName(), Boolean.getBoolean(ByteBufferUtil.string(ByteBuffer.wrap(cqlRow.getColumns().get(10).getValue()))));
throws InstantiationException, IllegalAccessException String thriftColumnName = PropertyAccessorFactory.STRING.fromBytes(String.class, column.getName()); byte[] thriftColumnValue = column.getValue();
String columnName = new String(column.getName(), Constants.ENCODING); if (columnName.equals("ttl(PERSON_NAME)")) String columnName = new String(column.getName(), Constants.ENCODING); if (columnName.equals("ttl(PERSON_NAME)")) for (Column column : cqlRow.getColumns()) String columnName = new String(column.getName(), Constants.ENCODING); if (columnName.equals("ttl(PERSON_NAME)")) String columnName = new String(column.getName(), Constants.ENCODING); if (columnName.equals("ttl(PERSON_NAME)")) String columnName = new String(column.getName(), Constants.ENCODING); if (columnName.equals("ttl(PERSON_NAME)"))
String thriftColumnName = PropertyAccessorFactory.STRING.fromBytes(String.class, column.getName()); if ((CassandraConstants.CQL_KEY.equalsIgnoreCase(thriftColumnName) || ((AbstractAttribute) m .getIdAttribute()).getJPAColumnName().equals(thriftColumnName)) && tr.getId() == null)
@Test public void testGetSlice() throws HectorException { // insert value ArrayList<String> columnnames = new ArrayList<String>(100); for (int i = 0; i < 100; i++) { ColumnPath cp = new ColumnPath("Standard1"); cp.setColumn(bytes("testGetSlice_" + i)); keyspace.insert("testGetSlice", cp, StringSerializer.get().toByteBuffer("testGetSlice_Value_" + i)); columnnames.add("testGetSlice_" + i); } // get value ColumnParent clp = new ColumnParent("Standard1"); SliceRange sr = new SliceRange(ByteBuffer.wrap(new byte[0]), ByteBuffer.wrap(new byte[0]), false, 150); SlicePredicate sp = new SlicePredicate(); sp.setSlice_range(sr); List<Column> cols = keyspace.getSlice("testGetSlice", clp, sp); assertNotNull(cols); assertEquals(100, cols.size()); Collections.sort(columnnames); ArrayList<String> gotlist = new ArrayList<String>(100); for (int i = 0; i < 100; i++) { gotlist.add(string(cols.get(i).getName())); } assertEquals(columnnames, gotlist); ColumnPath cp = new ColumnPath("Standard1"); keyspace.remove("testGetSlice_", cp); keyspace.remove("testGetSlice", cp); }