当前位置: 首页>>代码示例>>Java>>正文


Java CFMetaData.getColumnDefinition方法代码示例

本文整理汇总了Java中org.apache.cassandra.config.CFMetaData.getColumnDefinition方法的典型用法代码示例。如果您正苦于以下问题:Java CFMetaData.getColumnDefinition方法的具体用法?Java CFMetaData.getColumnDefinition怎么用?Java CFMetaData.getColumnDefinition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.cassandra.config.CFMetaData的用法示例。


在下文中一共展示了CFMetaData.getColumnDefinition方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: deserialize

import org.apache.cassandra.config.CFMetaData; //导入方法依赖的package包/类
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());
}
 
开发者ID:Netflix,项目名称:sstable-adaptor,代码行数:23,代码来源:Columns.java

示例2: toHeader

import org.apache.cassandra.config.CFMetaData; //导入方法依赖的package包/类
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);
}
 
开发者ID:Netflix,项目名称:sstable-adaptor,代码行数:30,代码来源:SerializationHeader.java

示例3: deserialize

import org.apache.cassandra.config.CFMetaData; //导入方法依赖的package包/类
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();
}
 
开发者ID:Netflix,项目名称:sstable-adaptor,代码行数:28,代码来源:ColumnSubselection.java

示例4: decodeCellName

import org.apache.cassandra.config.CFMetaData; //导入方法依赖的package包/类
public static LegacyCellName decodeCellName(CFMetaData metadata, ByteBuffer cellname, boolean readAllAsDynamic) throws UnknownColumnException
{
    Clustering clustering = decodeClustering(metadata, cellname);

    if (metadata.isSuper())
        return decodeForSuperColumn(metadata, clustering, CompositeType.extractComponent(cellname, 1));

    if (metadata.isDense() || (metadata.isCompactTable() && readAllAsDynamic))
        return new LegacyCellName(clustering, metadata.compactValueColumn(), null);

    ByteBuffer column = metadata.isCompound() ? CompositeType.extractComponent(cellname, metadata.comparator.size()) : cellname;
    if (column == null)
    {
        // Tables for composite 2ndary indexes used to be compound but dense, but we've transformed them into regular tables
        // (non compact ones) but with no regular column (i.e. we only care about the clustering). So we'll get here
        // in that case, and what we want to return is basically a row marker.
        if (metadata.partitionColumns().isEmpty())
            return new LegacyCellName(clustering, null, null);

        // Otherwise, we shouldn't get there
        throw new IllegalArgumentException("No column name component found in cell name");
    }

    // Row marker, this is ok
    if (!column.hasRemaining())
        return new LegacyCellName(clustering, null, null);

    ColumnDefinition def = metadata.getColumnDefinition(column);
    if ((def == null) || def.isPrimaryKeyColumn())
    {
        // If it's a compact table, it means the column is in fact a "dynamic" one
        if (metadata.isCompactTable())
            return new LegacyCellName(Clustering.make(column), metadata.compactValueColumn(), null);

        if (def == null)
            throw new UnknownColumnException(metadata, column);
        else
            throw new IllegalArgumentException("Cannot add primary key column to partition update");
    }

    ByteBuffer collectionElement = metadata.isCompound() ? CompositeType.extractComponent(cellname, metadata.comparator.size() + 1) : null;

    // Note that because static compact columns are translated to static defs in the new world order, we need to force a static
    // clustering if the definition is static (as it might not be in this case).
    return new LegacyCellName(def.isStatic() ? Clustering.STATIC_CLUSTERING : clustering, def, collectionElement);
}
 
开发者ID:Netflix,项目名称:sstable-adaptor,代码行数:47,代码来源:LegacyLayout.java


注:本文中的org.apache.cassandra.config.CFMetaData.getColumnDefinition方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。