本文整理汇总了Java中org.apache.cassandra.utils.ByteBufferUtil.EMPTY_BYTE_BUFFER属性的典型用法代码示例。如果您正苦于以下问题:Java ByteBufferUtil.EMPTY_BYTE_BUFFER属性的具体用法?Java ByteBufferUtil.EMPTY_BYTE_BUFFER怎么用?Java ByteBufferUtil.EMPTY_BYTE_BUFFER使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.apache.cassandra.utils.ByteBufferUtil
的用法示例。
在下文中一共展示了ByteBufferUtil.EMPTY_BYTE_BUFFER属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: fromString
public ByteBuffer fromString(String source) throws MarshalException
{
// Return an empty ByteBuffer for an empty string.
if (source.isEmpty())
return ByteBufferUtil.EMPTY_BYTE_BUFFER;
long longType;
try
{
longType = Long.parseLong(source);
}
catch (Exception e)
{
throw new MarshalException(String.format("Unable to make long from '%s'", source), e);
}
return decompose(longType);
}
示例2: fromString
public ByteBuffer fromString(String source) throws MarshalException
{
// Return an empty ByteBuffer for an empty string.
if (source.isEmpty())
return ByteBufferUtil.EMPTY_BYTE_BUFFER;
byte b;
try
{
b = Byte.parseByte(source);
}
catch (Exception e)
{
throw new MarshalException(String.format("Unable to make byte from '%s'", source), e);
}
return decompose(b);
}
示例3: fromString
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);
}
}
示例4: parse
static ByteBuffer parse(String source)
{
if (source.isEmpty())
return ByteBufferUtil.EMPTY_BYTE_BUFFER;
if (regexPattern.matcher(source).matches())
{
try
{
return UUIDGen.toByteBuffer(UUID.fromString(source));
}
catch (IllegalArgumentException e)
{
throw new MarshalException(String.format("Unable to make UUID from '%s'", source), e);
}
}
return null;
}
示例5: serialize
public ByteBuffer serialize(BigDecimal value)
{
if (value == null)
return ByteBufferUtil.EMPTY_BYTE_BUFFER;
BigInteger bi = value.unscaledValue();
int scale = value.scale();
byte[] bibytes = bi.toByteArray();
ByteBuffer bytes = ByteBuffer.allocate(4 + bibytes.length);
bytes.putInt(scale);
bytes.put(bibytes);
bytes.rewind();
return bytes;
}
示例6: fromJSONObject
@Override
public Term fromJSONObject(Object parsed) throws MarshalException
{
if (!(parsed instanceof String))
throw new MarshalException(String.format("Expected an empty string, but got: %s", parsed));
if (!((String) parsed).isEmpty())
throw new MarshalException(String.format("'%s' is not empty", parsed));
return new Constants.Value(ByteBufferUtil.EMPTY_BYTE_BUFFER);
}
示例7: buildAsEndOfRange
public ByteBuffer buildAsEndOfRange()
{
if (components.isEmpty())
return ByteBufferUtil.EMPTY_BYTE_BUFFER;
ByteBuffer bb = build();
bb.put(bb.remaining() - 1, (byte)1);
return bb;
}
示例8: fromString
public ByteBuffer fromString(String source) throws MarshalException
{
// Return an empty ByteBuffer for an empty string.
if (source.isEmpty())
return ByteBufferUtil.EMPTY_BYTE_BUFFER;
return decompose(Duration.from(source));
}
示例9: fromString
public ByteBuffer fromString(String source) throws MarshalException
{
// Return an empty ByteBuffer for an empty string.
if (source.isEmpty())
return ByteBufferUtil.EMPTY_BYTE_BUFFER;
try
{
return decompose(UUID.fromString(source));
}
catch (IllegalArgumentException e)
{
throw new MarshalException(String.format("unable to make UUID from '%s'", source), e);
}
}
示例10: deserialize
public Cell deserialize(DataInputPlus in, LivenessInfo rowLiveness, ColumnDefinition column, SerializationHeader header, SerializationHelper helper) throws IOException
{
int flags = in.readUnsignedByte();
boolean hasValue = (flags & HAS_EMPTY_VALUE_MASK) == 0;
boolean isDeleted = (flags & IS_DELETED_MASK) != 0;
boolean isExpiring = (flags & IS_EXPIRING_MASK) != 0;
boolean useRowTimestamp = (flags & USE_ROW_TIMESTAMP_MASK) != 0;
boolean useRowTTL = (flags & USE_ROW_TTL_MASK) != 0;
long timestamp = useRowTimestamp ? rowLiveness.timestamp() : header.readTimestamp(in);
int localDeletionTime = useRowTTL
? rowLiveness.localExpirationTime()
: (isDeleted || isExpiring ? header.readLocalDeletionTime(in) : NO_DELETION_TIME);
int ttl = useRowTTL ? rowLiveness.ttl() : (isExpiring ? header.readTTL(in) : NO_TTL);
CellPath path = column.isComplex()
? column.cellPathSerializer().deserialize(in)
: null;
ByteBuffer value = ByteBufferUtil.EMPTY_BYTE_BUFFER;
if (hasValue)
{
if (helper.canSkipValue(column) || (path != null && helper.canSkipValue(path)))
{
header.getType(column).skipValue(in);
}
else
{
boolean isCounter = localDeletionTime == NO_DELETION_TIME && column.type.isCounter();
value = header.getType(column).readValue(in, DatabaseDescriptor.getMaxValueSize());
if (isCounter)
value = helper.maybeClearCounterValue(value);
}
}
return new BufferCell(column, timestamp, ttl, localDeletionTime, value, path);
}
示例11: getMinimumToken
public LocalToken getMinimumToken()
{
return new LocalToken(ByteBufferUtil.EMPTY_BYTE_BUFFER);
}
示例12: serialize
public ByteBuffer serialize(Double value)
{
return (value == null) ? ByteBufferUtil.EMPTY_BYTE_BUFFER : ByteBufferUtil.bytes(value);
}
示例13: serialize
public ByteBuffer serialize(Long value)
{
return value == null ? ByteBufferUtil.EMPTY_BYTE_BUFFER : ByteBufferUtil.bytes(value);
}
示例14: serialize
public ByteBuffer serialize(Short value)
{
return value == null ? ByteBufferUtil.EMPTY_BYTE_BUFFER : ByteBufferUtil.bytes(value.shortValue());
}
示例15: serialize
public ByteBuffer serialize(UUID value)
{
return value == null ? ByteBufferUtil.EMPTY_BYTE_BUFFER : UUIDGen.toByteBuffer(value);
}