private static String stringify(ByteBuffer name) { try { return UTF8Type.instance.getString(name); } catch (Exception e) { return ByteBufferUtil.bytesToHex(name); } } }
@Override public String toString() { return String.format("%s.%s", selected, UTF8Type.instance.getString(type.fieldName(field))); } }
private static String stringify(ByteBuffer name) { try { return UTF8Type.instance.getString(name); } catch (Exception e) { return ByteBufferUtil.bytesToHex(name); } } }
private static String stringify(ByteBuffer name) { try { return UTF8Type.instance.getString(name); } catch (Exception e) { return ByteBufferUtil.bytesToHex(name); } } }
private static String stringify(ByteBuffer name) { try { return UTF8Type.instance.getString(name); } catch (Exception e) { return ByteBufferUtil.bytesToHex(name); } } }
List<String> getCFColumnsWithoutCollections() { Iterator<ColumnDefinition> allColumns = CFMetaData.SchemaColumnFamiliesCf.allColumnsInSelectOrder(); List<String> selectedColumns = new ArrayList<>(); while (allColumns.hasNext()) { ColumnDefinition def = allColumns.next(); if (!def.type.isCollection()) selectedColumns.add(UTF8Type.instance.getString(def.name.bytes)); } return selectedColumns; }
private static Map<String, ByteBuffer> convertThriftCqlRow(CqlRow row) { Map<String, ByteBuffer> m = new HashMap<>(); for (org.apache.cassandra.thrift.Column column : row.getColumns()) m.put(UTF8Type.instance.getString(column.bufferForName()), column.value); return m; }
public static void checkForDuplicateNames(UserType type) throws InvalidRequestException { for (int i = 0; i < type.size() - 1; i++) { ByteBuffer fieldName = type.fieldName(i); for (int j = i+1; j < type.size(); j++) { if (fieldName.equals(type.fieldName(j))) throw new InvalidRequestException(String.format("Duplicate field name %s in type %s", UTF8Type.instance.getString(fieldName), UTF8Type.instance.getString(type.name))); } } }
public SerializationHeader toHeader(CFMetaData metadata) { Map<ByteBuffer, AbstractType<?>> typeMap = new HashMap<>(staticColumns.size() + regularColumns.size()); typeMap.putAll(staticColumns); typeMap.putAll(regularColumns); PartitionColumns.Builder builder = PartitionColumns.builder(); for (ByteBuffer name : typeMap.keySet()) { ColumnDefinition column = metadata.getColumnDefinition(name); if (column == null) { // TODO: this imply we don't read data for a column we don't yet know about, which imply this is theoretically // racy with column addition. Currently, it is up to the user to not write data before the schema has propagated // and this is far from being the only place that has such problem in practice. This doesn't mean we shouldn't // improve this. // If we don't find the definition, it could be we have data for a dropped column, and we shouldn't // fail deserialization because of that. So we grab a "fake" ColumnDefinition that ensure proper // deserialization. The column will be ignore later on anyway. boolean isStatic = staticColumns.containsKey(name); column = metadata.getDroppedColumnDefinition(name, isStatic); if (column == null) throw new RuntimeException("Unknown column " + UTF8Type.instance.getString(name) + " during deserialization"); } builder.add(column); } return new SerializationHeader(true, keyType, clusteringTypes, builder.build(), stats, typeMap); }
public SerializationHeader toHeader(CFMetaData metadata) { Map<ByteBuffer, AbstractType<?>> typeMap = new HashMap<>(staticColumns.size() + regularColumns.size()); typeMap.putAll(staticColumns); typeMap.putAll(regularColumns); PartitionColumns.Builder builder = PartitionColumns.builder(); for (ByteBuffer name : typeMap.keySet()) { ColumnDefinition column = metadata.getColumnDefinition(name); if (column == null) { // TODO: this imply we don't read data for a column we don't yet know about, which imply this is theoretically // racy with column addition. Currently, it is up to the user to not write data before the schema has propagated // and this is far from being the only place that has such problem in practice. This doesn't mean we shouldn't // improve this. // If we don't find the definition, it could be we have data for a dropped column, and we shouldn't // fail deserialization because of that. So we grab a "fake" ColumnDefinition that ensure proper // deserialization. The column will be ignore later on anyway. boolean isStatic = staticColumns.containsKey(name); column = metadata.getDroppedColumnDefinition(name, isStatic); if (column == null) throw new RuntimeException("Unknown column " + UTF8Type.instance.getString(name) + " during deserialization"); } builder.add(column); } return new SerializationHeader(true, keyType, clusteringTypes, builder.build(), stats, typeMap); }
public SerializationHeader toHeader(CFMetaData metadata) { Map<ByteBuffer, AbstractType<?>> typeMap = new HashMap<>(staticColumns.size() + regularColumns.size()); typeMap.putAll(staticColumns); typeMap.putAll(regularColumns); PartitionColumns.Builder builder = PartitionColumns.builder(); for (ByteBuffer name : typeMap.keySet()) { ColumnDefinition column = metadata.getColumnDefinition(name); if (column == null) { // TODO: this imply we don't read data for a column we don't yet know about, which imply this is theoretically // racy with column addition. Currently, it is up to the user to not write data before the schema has propagated // and this is far from being the only place that has such problem in practice. This doesn't mean we shouldn't // improve this. // If we don't find the definition, it could be we have data for a dropped column, and we shouldn't // fail deserialization because of that. So we grab a "fake" ColumnDefinition that ensure proper // deserialization. The column will be ignore later on anyway. boolean isStatic = staticColumns.containsKey(name); column = metadata.getDroppedColumnDefinition(name, isStatic); if (column == null) throw new RuntimeException("Unknown column " + UTF8Type.instance.getString(name) + " during deserialization"); } builder.add(column); } return new SerializationHeader(true, keyType, clusteringTypes, builder.build(), stats, typeMap); }
public SerializationHeader toHeader(CFMetaData metadata) { Map<ByteBuffer, AbstractType<?>> typeMap = new HashMap<>(staticColumns.size() + regularColumns.size()); typeMap.putAll(staticColumns); typeMap.putAll(regularColumns); PartitionColumns.Builder builder = PartitionColumns.builder(); for (ByteBuffer name : typeMap.keySet()) { ColumnDefinition column = metadata.getColumnDefinition(name); if (column == null) { // TODO: this imply we don't read data for a column we don't yet know about, which imply this is theoretically // racy with column addition. Currently, it is up to the user to not write data before the schema has propagated // and this is far from being the only place that has such problem in practice. This doesn't mean we shouldn't // improve this. // If we don't find the definition, it could be we have data for a dropped column, and we shouldn't // fail deserialization because of that. So we grab a "fake" ColumnDefinition that ensure proper // deserialization. The column will be ignore later on anyway. boolean isStatic = staticColumns.containsKey(name); column = metadata.getDroppedColumnDefinition(name, isStatic); if (column == null) throw new RuntimeException("Unknown column " + UTF8Type.instance.getString(name) + " during deserialization"); } builder.add(column); } return new SerializationHeader(true, keyType, clusteringTypes, builder.build(), stats, typeMap); }
public Columns deserialize(DataInputPlus in, CFMetaData metadata) throws IOException { int length = (int)in.readUnsignedVInt(); BTree.Builder<ColumnDefinition> builder = BTree.builder(Comparator.naturalOrder()); builder.auto(false); for (int i = 0; i < length; i++) { ByteBuffer name = ByteBufferUtil.readWithVIntLength(in); ColumnDefinition column = metadata.getColumnDefinition(name); if (column == null) { // If we don't find the definition, it could be we have data for a dropped column, and we shouldn't // fail deserialization because of that. So we grab a "fake" ColumnDefinition that ensure proper // deserialization. The column will be ignore later on anyway. column = metadata.getDroppedColumnDefinition(name); if (column == null) throw new RuntimeException("Unknown column " + UTF8Type.instance.getString(name) + " during deserialization"); } builder.add(column); } return new Columns(builder.build()); }
public Columns deserialize(DataInputPlus in, CFMetaData metadata) throws IOException { int length = (int)in.readUnsignedVInt(); BTree.Builder<ColumnDefinition> builder = BTree.builder(Comparator.naturalOrder()); builder.auto(false); for (int i = 0; i < length; i++) { ByteBuffer name = ByteBufferUtil.readWithVIntLength(in); ColumnDefinition column = metadata.getColumnDefinition(name); if (column == null) { // If we don't find the definition, it could be we have data for a dropped column, and we shouldn't // fail deserialization because of that. So we grab a "fake" ColumnDefinition that ensure proper // deserialization. The column will be ignore later on anyway. column = metadata.getDroppedColumnDefinition(name); if (column == null) throw new RuntimeException("Unknown column " + UTF8Type.instance.getString(name) + " during deserialization"); } builder.add(column); } return new Columns(builder.build()); }
public Columns deserialize(DataInputPlus in, CFMetaData metadata) throws IOException { int length = (int)in.readUnsignedVInt(); BTree.Builder<ColumnDefinition> builder = BTree.builder(Comparator.naturalOrder()); builder.auto(false); for (int i = 0; i < length; i++) { ByteBuffer name = ByteBufferUtil.readWithVIntLength(in); ColumnDefinition column = metadata.getColumnDefinition(name); if (column == null) { // If we don't find the definition, it could be we have data for a dropped column, and we shouldn't // fail deserialization because of that. So we grab a "fake" ColumnDefinition that ensure proper // deserialization. The column will be ignore later on anyway. column = metadata.getDroppedColumnDefinition(name); if (column == null) throw new RuntimeException("Unknown column " + UTF8Type.instance.getString(name) + " during deserialization"); } builder.add(column); } return new Columns(builder.build()); }
public Columns deserialize(DataInputPlus in, CFMetaData metadata) throws IOException { int length = (int)in.readUnsignedVInt(); BTree.Builder<ColumnDefinition> builder = BTree.builder(Comparator.naturalOrder()); builder.auto(false); for (int i = 0; i < length; i++) { ByteBuffer name = ByteBufferUtil.readWithVIntLength(in); ColumnDefinition column = metadata.getColumnDefinition(name); if (column == null) { // If we don't find the definition, it could be we have data for a dropped column, and we shouldn't // fail deserialization because of that. So we grab a "fake" ColumnDefinition that ensure proper // deserialization. The column will be ignore later on anyway. column = metadata.getDroppedColumnDefinition(name); if (column == null) throw new RuntimeException("Unknown column " + UTF8Type.instance.getString(name) + " during deserialization"); } builder.add(column); } return new Columns(builder.build()); }
public ColumnSubselection deserialize(DataInputPlus in, int version, CFMetaData metadata) throws IOException { ByteBuffer name = ByteBufferUtil.readWithShortLength(in); ColumnDefinition column = metadata.getColumnDefinition(name); if (column == null) { // If we don't find the definition, it could be we have data for a dropped column, and we shouldn't // fail deserialization because of that. So we grab a "fake" ColumnDefinition that ensure proper // deserialization. The column will be ignore later on anyway. column = metadata.getDroppedColumnDefinition(name); if (column == null) throw new RuntimeException("Unknown column " + UTF8Type.instance.getString(name) + " during deserialization"); } Kind kind = Kind.values()[in.readUnsignedByte()]; switch (kind) { case SLICE: CellPath from = column.cellPathSerializer().deserialize(in); CellPath to = column.cellPathSerializer().deserialize(in); return new Slice(column, from, to); case ELEMENT: CellPath elt = column.cellPathSerializer().deserialize(in); return new Element(column, elt); } throw new AssertionError(); }
public ColumnSubselection deserialize(DataInputPlus in, int version, CFMetaData metadata) throws IOException { ByteBuffer name = ByteBufferUtil.readWithShortLength(in); ColumnDefinition column = metadata.getColumnDefinition(name); if (column == null) { // If we don't find the definition, it could be we have data for a dropped column, and we shouldn't // fail deserialization because of that. So we grab a "fake" ColumnDefinition that ensure proper // deserialization. The column will be ignore later on anyway. column = metadata.getDroppedColumnDefinition(name); if (column == null) throw new RuntimeException("Unknown column " + UTF8Type.instance.getString(name) + " during deserialization"); } Kind kind = Kind.values()[in.readUnsignedByte()]; switch (kind) { case SLICE: CellPath from = column.cellPathSerializer().deserialize(in); CellPath to = column.cellPathSerializer().deserialize(in); return new Slice(column, from, to); case ELEMENT: CellPath elt = column.cellPathSerializer().deserialize(in); return new Element(column, elt); } throw new AssertionError(); }
public ColumnSubselection deserialize(DataInputPlus in, int version, CFMetaData metadata) throws IOException { ByteBuffer name = ByteBufferUtil.readWithShortLength(in); ColumnDefinition column = metadata.getColumnDefinition(name); if (column == null) { // If we don't find the definition, it could be we have data for a dropped column, and we shouldn't // fail deserialization because of that. So we grab a "fake" ColumnDefinition that ensure proper // deserialization. The column will be ignore later on anyway. column = metadata.getDroppedColumnDefinition(name); if (column == null) throw new RuntimeException("Unknown column " + UTF8Type.instance.getString(name) + " during deserialization"); } Kind kind = Kind.values()[in.readUnsignedByte()]; switch (kind) { case SLICE: CellPath from = column.cellPathSerializer().deserialize(in); CellPath to = column.cellPathSerializer().deserialize(in); return new Slice(column, from, to); case ELEMENT: CellPath elt = column.cellPathSerializer().deserialize(in); return new Element(column, elt); } throw new AssertionError(); }
public ColumnSubselection deserialize(DataInputPlus in, int version, CFMetaData metadata) throws IOException { ByteBuffer name = ByteBufferUtil.readWithShortLength(in); ColumnDefinition column = metadata.getColumnDefinition(name); if (column == null) { // If we don't find the definition, it could be we have data for a dropped column, and we shouldn't // fail deserialization because of that. So we grab a "fake" ColumnDefinition that ensure proper // deserialization. The column will be ignore later on anyway. column = metadata.getDroppedColumnDefinition(name); if (column == null) throw new RuntimeException("Unknown column " + UTF8Type.instance.getString(name) + " during deserialization"); } Kind kind = Kind.values()[in.readUnsignedByte()]; switch (kind) { case SLICE: CellPath from = column.cellPathSerializer().deserialize(in); CellPath to = column.cellPathSerializer().deserialize(in); return new Slice(column, from, to); case ELEMENT: CellPath elt = column.cellPathSerializer().deserialize(in); return new Element(column, elt); } throw new AssertionError(); }