本文整理汇总了Java中org.apache.cassandra.utils.ByteBufferUtil.bytes方法的典型用法代码示例。如果您正苦于以下问题:Java ByteBufferUtil.bytes方法的具体用法?Java ByteBufferUtil.bytes怎么用?Java ByteBufferUtil.bytes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.cassandra.utils.ByteBufferUtil
的用法示例。
在下文中一共展示了ByteBufferUtil.bytes方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: fromJSONObject
import org.apache.cassandra.utils.ByteBufferUtil; //导入方法依赖的package包/类
@Override
public Term fromJSONObject(Object parsed) throws MarshalException
{
if (parsed instanceof Long)
return new Constants.Value(ByteBufferUtil.bytes((Long) parsed));
try
{
return new Constants.Value(TimestampType.instance.fromString((String) parsed));
}
catch (ClassCastException exc)
{
throw new MarshalException(String.format(
"Expected a long or a datestring representation of a date value, but got a %s: %s",
parsed.getClass().getSimpleName(), parsed));
}
}
示例2: fromString
import org.apache.cassandra.utils.ByteBufferUtil; //导入方法依赖的package包/类
public ByteBuffer fromString(String source) throws MarshalException
{
// Return an empty ByteBuffer for an empty string.
if (source.isEmpty())
return ByteBufferUtil.EMPTY_BYTE_BUFFER;
try
{
float f = Float.parseFloat(source);
return ByteBufferUtil.bytes(f);
}
catch (NumberFormatException e1)
{
throw new MarshalException(String.format("Unable to make float from '%s'", source), e1);
}
}
示例3: getIdentifier
import org.apache.cassandra.utils.ByteBufferUtil; //导入方法依赖的package包/类
public ColumnIdentifier getIdentifier(CFMetaData cfm)
{
if (!cfm.isStaticCompactTable())
return ColumnIdentifier.getInterned(text, true);
AbstractType<?> thriftColumnNameType = cfm.thriftColumnNameType();
if (thriftColumnNameType instanceof UTF8Type)
return ColumnIdentifier.getInterned(text, true);
// We have a Thrift-created table with a non-text comparator. Check if we have a match column, otherwise assume we should use
// thriftColumnNameType
ByteBuffer bufferName = ByteBufferUtil.bytes(text);
for (ColumnDefinition def : cfm.allColumns())
{
if (def.name.bytes.equals(bufferName))
return def.name;
}
return ColumnIdentifier.getInterned(thriftColumnNameType, thriftColumnNameType.fromString(text), text);
}
示例4: prepare
import org.apache.cassandra.utils.ByteBufferUtil; //导入方法依赖的package包/类
public ColumnDefinition prepare(CFMetaData cfm)
{
if (!cfm.isStaticCompactTable())
return find(cfm);
AbstractType<?> thriftColumnNameType = cfm.thriftColumnNameType();
if (thriftColumnNameType instanceof UTF8Type)
return find(cfm);
// We have a Thrift-created table with a non-text comparator. Check if we have a match column, otherwise assume we should use
// thriftColumnNameType
ByteBuffer bufferName = ByteBufferUtil.bytes(text);
for (ColumnDefinition def : cfm.allColumns())
{
if (def.name.bytes.equals(bufferName))
return def;
}
return find(thriftColumnNameType.fromString(text), cfm);
}
示例5: ColumnIdentifier
import org.apache.cassandra.utils.ByteBufferUtil; //导入方法依赖的package包/类
public ColumnIdentifier(String rawText, boolean keepCase)
{
this.text = keepCase ? rawText : rawText.toLowerCase(Locale.US);
this.bytes = ByteBufferUtil.bytes(this.text);
this.prefixComparison = prefixComparison(bytes);
this.interned = false;
}
示例6: fromString
import org.apache.cassandra.utils.ByteBufferUtil; //导入方法依赖的package包/类
public ByteBuffer fromString(String source) throws MarshalException
{
// Return an empty ByteBuffer for an empty string.
if (source.isEmpty())
return ByteBufferUtil.EMPTY_BYTE_BUFFER;
return ByteBufferUtil.bytes(TimestampSerializer.dateStringToTimestamp(source));
}
示例7: getInterned
import org.apache.cassandra.utils.ByteBufferUtil; //导入方法依赖的package包/类
public static ColumnIdentifier getInterned(String rawText, boolean keepCase)
{
String text = keepCase ? rawText : rawText.toLowerCase(Locale.US);
ByteBuffer bytes = ByteBufferUtil.bytes(text);
return getInterned(UTF8Type.instance, bytes, text);
}
示例8: toByteArray
import org.apache.cassandra.utils.ByteBufferUtil; //导入方法依赖的package包/类
public ByteBuffer toByteArray(Token token)
{
LongToken longToken = (LongToken) token;
return ByteBufferUtil.bytes(longToken.token);
}
示例9: decompose
import org.apache.cassandra.utils.ByteBufferUtil; //导入方法依赖的package包/类
@Override
public ByteBuffer decompose(Long value)
{
return ByteBufferUtil.bytes(value);
}
示例10: fromTimeInMillis
import org.apache.cassandra.utils.ByteBufferUtil; //导入方法依赖的package包/类
public ByteBuffer fromTimeInMillis(long millis) throws MarshalException
{
return ByteBufferUtil.bytes(millis);
}
示例11: serialize
import org.apache.cassandra.utils.ByteBufferUtil; //导入方法依赖的package包/类
public ByteBuffer serialize(Double value)
{
return (value == null) ? ByteBufferUtil.EMPTY_BYTE_BUFFER : ByteBufferUtil.bytes(value);
}
示例12: fromString
import org.apache.cassandra.utils.ByteBufferUtil; //导入方法依赖的package包/类
public ByteBuffer fromString(String source) throws MarshalException
{
return ByteBufferUtil.bytes(SimpleDateSerializer.dateStringToDays(source));
}
示例13: serialize
import org.apache.cassandra.utils.ByteBufferUtil; //导入方法依赖的package包/类
public ByteBuffer serialize(Float value)
{
return (value == null) ? ByteBufferUtil.EMPTY_BYTE_BUFFER : ByteBufferUtil.bytes(value);
}
示例14: serialize
import org.apache.cassandra.utils.ByteBufferUtil; //导入方法依赖的package包/类
public ByteBuffer serialize(Integer value)
{
return value == null ? ByteBufferUtil.EMPTY_BYTE_BUFFER : ByteBufferUtil.bytes(value);
}
示例15: serialize
import org.apache.cassandra.utils.ByteBufferUtil; //导入方法依赖的package包/类
public ByteBuffer serialize(String value)
{
return ByteBufferUtil.bytes(value, charset);
}