本文整理汇总了Java中org.apache.cassandra.db.marshal.TypeParser类的典型用法代码示例。如果您正苦于以下问题:Java TypeParser类的具体用法?Java TypeParser怎么用?Java TypeParser使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TypeParser类属于org.apache.cassandra.db.marshal包,在下文中一共展示了TypeParser类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parseValidatorType
import org.apache.cassandra.db.marshal.TypeParser; //导入依赖的package包/类
/**
* Parses the cassandra columns mapping to identify the column name.
* One of the Hive table columns maps to the cassandra row key, by default the
* first column.
*
* @param columnList a list of column validator type in String format
* @return a list of cassandra validator type
*/
private List<AbstractType> parseValidatorType(List<String> columnList)
throws SerDeException {
List<AbstractType> types = new ArrayList<AbstractType>();
for (String str : columnList) {
if (StringUtils.isBlank(str)) {
types.add(DEFAULT_VALIDATOR_TYPE);
} else {
try {
types.add(TypeParser.parse(str));
} catch (Exception e) {
throw new SerDeException("Invalid Cassandra validator type ' " + str + "'");
}
}
}
return types;
}
示例2: setup
import org.apache.cassandra.db.marshal.TypeParser; //导入依赖的package包/类
@Override protected void setup(
Context context)
throws IOException, InterruptedException {
super.setup(context);
maxRowSize = context.getConfiguration().getLong(Aegisthus.Feature.CONF_MAXCOLSIZE, Long.MAX_VALUE);
String columnType = context.getConfiguration().get(Aegisthus.Feature.CONF_COLUMNTYPE, "BytesType");
String rowKeyType = context.getConfiguration().get(Aegisthus.Feature.CONF_KEYTYPE, "BytesType");
try {
columnComparator = TypeParser.parse(columnType);
rowKeyComparator = TypeParser.parse(rowKeyType);
} catch (SyntaxException | ConfigurationException e) {
throw new RuntimeException(e);
}
}
示例3: getColumns
import org.apache.cassandra.db.marshal.TypeParser; //导入依赖的package包/类
private Map<ByteBuffer, ColumnDefinition> getColumns(AbstractType<?> comparator) throws InvalidRequestException
{
Map<ByteBuffer, ColumnDefinition> columnDefs = new HashMap<ByteBuffer, ColumnDefinition>();
for (Map.Entry<Term, String> col : columns.entrySet())
{
try
{
ByteBuffer columnName = comparator.fromString(col.getKey().getText());
String validatorClassName = comparators.containsKey(col.getValue()) ? comparators.get(col.getValue()) : col.getValue();
AbstractType<?> validator = TypeParser.parse(validatorClassName);
columnDefs.put(columnName, new ColumnDefinition(columnName, validator, null, null));
}
catch (ConfigurationException e)
{
InvalidRequestException ex = new InvalidRequestException(e.toString());
ex.initCause(e);
throw ex;
}
}
return columnDefs;
}
示例4: getDefaultMarshallers
import org.apache.cassandra.db.marshal.TypeParser; //导入依赖的package包/类
private List<AbstractType> getDefaultMarshallers(CfDef cfDef) throws IOException
{
ArrayList<AbstractType> marshallers = new ArrayList<AbstractType>();
AbstractType comparator = null;
AbstractType default_validator = null;
try
{
comparator = TypeParser.parse(cfDef.comparator_type);
default_validator = TypeParser.parse(cfDef.default_validation_class);
}
catch (ConfigurationException e)
{
throw new IOException(e);
}
marshallers.add(comparator);
marshallers.add(default_validator);
return marshallers;
}
示例5: getValidatorMap
import org.apache.cassandra.db.marshal.TypeParser; //导入依赖的package包/类
private Map<ByteBuffer,AbstractType> getValidatorMap(CfDef cfDef) throws IOException
{
Map<ByteBuffer, AbstractType> validators = new HashMap<ByteBuffer, AbstractType>();
for (ColumnDef cd : cfDef.column_metadata)
{
if (cd.getValidation_class() != null && !cd.getValidation_class().isEmpty())
{
AbstractType validator = null;
try
{
validator = TypeParser.parse(cd.getValidation_class());
validators.put(cd.name, validator);
}
catch (ConfigurationException e)
{
throw new IOException(e);
}
}
}
return validators;
}
示例6: maybeCreateColumnFamily
import org.apache.cassandra.db.marshal.TypeParser; //导入依赖的package包/类
private void maybeCreateColumnFamily(RequiresColumnFamily rcf) {
try {
CFMetaData cfMetaData;
if ( rcf.isCounter() ) {
cfMetaData = new CFMetaData(rcf.ksName(), rcf.cfName(),
ColumnFamilyType.Standard, TypeParser.parse(rcf.comparator()), null)
.replicateOnWrite(false).defaultValidator(CounterColumnType.instance);
} else {
cfMetaData = new CFMetaData(rcf.ksName(), rcf.cfName(),
ColumnFamilyType.Standard, TypeParser.parse(rcf.comparator()), null);
}
MigrationManager.announceNewColumnFamily(cfMetaData);
} catch(AlreadyExistsException aee) {
logger.info("CF already exists for " + rcf.cfName());
maybeTruncateSafely(rcf);
} catch (Exception ex) {
throw new RuntimeException("Could not create CF for: " + rcf.cfName(), ex);
}
}
示例7: ColumnFamilyMetadata
import org.apache.cassandra.db.marshal.TypeParser; //导入依赖的package包/类
public ColumnFamilyMetadata(String keyspace, String columnFamily, String keyAliasesString, String columnAliasesString, String keyValidatorString,
String comparatorString) {
// @formatter:off
if (keyspace == null) throw new IllegalArgumentException("keyspace cannot be null");
if (columnFamily == null) throw new IllegalArgumentException("columnFamily cannot be null");
if (keyAliasesString == null) throw new IllegalArgumentException("keyAliasesString cannot be null");
if (columnAliasesString == null) throw new IllegalArgumentException("columnAliasesString cannot be null");
if (keyValidatorString == null) throw new IllegalArgumentException("keyValidatorString cannot be null");
if (comparatorString == null) throw new IllegalArgumentException("comparatorString cannot be null");
// @formatter:on
this.keyspace = keyspace;
this.columnFamily = columnFamily;
this.keyAliasesString = keyAliasesString;
this.keyAliases = FBUtilities.fromJsonList(keyAliasesString);
this.columnAliasesString = columnAliasesString;
this.columnAliases = FBUtilities.fromJsonList(columnAliasesString);
this.keyValidatorString = keyValidatorString;
this.comparatorString = comparatorString;
try {
this.keyValidator = TypeParser.parse(keyValidatorString);
this.comparator = TypeParser.parse(comparatorString);
} catch (Exception e) {
throw new IllegalArgumentException("Can't parse type string", e);
}
}
示例8: parseType
import org.apache.cassandra.db.marshal.TypeParser; //导入依赖的package包/类
private AbstractType<?> parseType(String type) throws ConfigurationException
{
try
{
// always treat counters like longs, specifically CCT.serialize is not what we need
if (type != null && type.equals("org.apache.cassandra.db.marshal.CounterColumnType"))
return LongType.instance;
return TypeParser.parse(type);
}
catch (SyntaxException e)
{
throw new ConfigurationException(e.getMessage(), e);
}
}
示例9: argsListFromString
import org.apache.cassandra.db.marshal.TypeParser; //导入依赖的package包/类
private static List<AbstractType<?>> argsListFromString(String s)
{
List<AbstractType<?>> argTypes = new ArrayList<>();
for(String type : Splitter.on("^").omitEmptyStrings().trimResults().split(s))
argTypes.add(TypeParser.parse(type));
return argTypes;
}
示例10: parseType
import org.apache.cassandra.db.marshal.TypeParser; //导入依赖的package包/类
private static AbstractType<?> parseType(String str)
{
// We only use this when reading the schema where we shouldn't get an error
try
{
return TypeParser.parse(str);
}
catch (SyntaxException | ConfigurationException e)
{
throw new RuntimeException(e);
}
}
示例11: parseType
import org.apache.cassandra.db.marshal.TypeParser; //导入依赖的package包/类
private AbstractType<?> parseType(String type) throws ConfigurationException
{
try
{
// always treat counters like longs, specifically CCT.compose is not what we need
if (type != null && type.equals("org.apache.cassandra.db.marshal.CounterColumnType"))
return LongType.instance;
return TypeParser.parse(type);
}
catch (SyntaxException e)
{
throw new ConfigurationException(e.getMessage(), e);
}
}
示例12: columnFromAvro
import org.apache.cassandra.db.marshal.TypeParser; //导入依赖的package包/类
@Deprecated
public static ColumnDefinition columnFromAvro(org.apache.cassandra.db.migration.avro.ColumnDef cd)
{
IndexType index_type = cd.index_type == null ? null : Enum.valueOf(IndexType.class, cd.index_type.name());
String index_name = cd.index_name == null ? null : cd.index_name.toString();
try
{
AbstractType<?> validatorType = TypeParser.parse(cd.validation_class);
return new ColumnDefinition(ByteBufferUtil.clone(cd.name), validatorType, index_type, ColumnDefinition.getStringMap(cd.index_options), index_name, null);
}
catch (RequestValidationException e)
{
throw new RuntimeException(e);
}
}
示例13: parseType
import org.apache.cassandra.db.marshal.TypeParser; //导入依赖的package包/类
private AbstractType<?> parseType(String type) throws ConfigurationException {
try {
// always treat counters like longs, specifically CCT.serialize is not what we need
if (type != null && type.equals("org.apache.cassandra.db.marshal.CounterColumnType")) {
return LongType.instance;
}
return TypeParser.parse(type);
} catch (SyntaxException e) {
throw new ConfigurationException(e.getMessage(), e);
}
}
示例14: getConverter
import org.apache.cassandra.db.marshal.TypeParser; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private AbstractType<ByteBuffer> getConverter(Configuration conf, String key) {
String converterType = conf.get(key);
if (Strings.isNullOrEmpty(key)) {
return BytesType.instance;
}
try {
return (AbstractType<ByteBuffer>) TypeParser.parse(converterType);
} catch (SyntaxException | ConfigurationException e) {
throw Throwables.propagate(e);
}
}
示例15: setConf
import org.apache.cassandra.db.marshal.TypeParser; //导入依赖的package包/类
@Override
public void setConf(Configuration conf) {
this.conf = conf;
String columnType = conf.get(Aegisthus.Feature.CONF_COLUMNTYPE, "BytesType");
legacyColumnNameFormatting = conf.getBoolean(Aegisthus.Feature.CONF_LEGACY_COLUMN_NAME_FORMATTING, false);
sortColumnsByName = conf.getBoolean(Aegisthus.Feature.CONF_SORT_COLUMNS_BY_NAME, false);
try {
//noinspection unchecked
columnNameConverter = (AbstractType<ByteBuffer>) TypeParser.parse(columnType);
} catch (SyntaxException | ConfigurationException e) {
throw new RuntimeException(e);
}
}