本文整理汇总了Java中org.apache.cassandra.utils.Hex类的典型用法代码示例。如果您正苦于以下问题:Java Hex类的具体用法?Java Hex怎么用?Java Hex使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Hex类属于org.apache.cassandra.utils包,在下文中一共展示了Hex类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: close
import org.apache.cassandra.utils.Hex; //导入依赖的package包/类
public void close()
{
FileUtils.closeQuietly(writer);
byte[] bytes = digest.digest();
if (bytes == null)
return;
SequentialWriter out = SequentialWriter.open(new File(descriptor.filenameFor(SSTable.COMPONENT_DIGEST)), true);
// Writting output compatible with sha1sum
Descriptor newdesc = descriptor.asTemporary(false);
String[] tmp = newdesc.filenameFor(SSTable.COMPONENT_DATA).split(Pattern.quote(File.separator));
String dataFileName = tmp[tmp.length - 1];
try
{
out.write(String.format("%s %s", Hex.bytesToHex(bytes), dataFileName).getBytes());
}
catch (ClosedChannelException e)
{
throw new AssertionError(); // can't happen.
}
finally
{
FileUtils.closeQuietly(out);
}
}
开发者ID:pgaref,项目名称:ACaZoo,代码行数:25,代码来源:DataIntegrityMetadata.java
示例2: close
import org.apache.cassandra.utils.Hex; //导入依赖的package包/类
public void close()
{
FileUtils.closeQuietly(writer);
byte[] bytes = digest.digest();
if (bytes == null)
return;
SequentialWriter out = SequentialWriter.open(new File(descriptor.filenameFor(Component.DIGEST)), true);
// Writting output compatible with sha1sum
Descriptor newdesc = descriptor.asTemporary(false);
String[] tmp = newdesc.filenameFor(Component.DATA).split(Pattern.quote(File.separator));
String dataFileName = tmp[tmp.length - 1];
try
{
out.write(String.format("%s %s", Hex.bytesToHex(bytes), dataFileName).getBytes());
}
catch (ClosedChannelException e)
{
throw new AssertionError(); // can't happen.
}
finally
{
FileUtils.closeQuietly(out);
}
}
开发者ID:mafernandez-stratio,项目名称:cassandra-cqlMod,代码行数:25,代码来源:DataIntegrityMetadata.java
示例3: deserializeIndexedColumns
import org.apache.cassandra.utils.Hex; //导入依赖的package包/类
/**
* Serialize a set of ColumnDefs for indexed columns, read from Job
* configuration
*
* @param serialized column metadata
* @return list of column metadata objects which may be empty, but not null
*/
public static Set<ColumnDef> deserializeIndexedColumns(String serialized) {
Set<ColumnDef> columns = new HashSet<ColumnDef>();
if (null == serialized) {
return columns;
}
Iterable<String> strings = Splitter.on(AbstractCassandraSerDe.DELIMITER).omitEmptyStrings().trimResults().split(serialized);
TDeserializer deserializer = new TDeserializer(new TBinaryProtocol.Factory());
for (String encoded : strings) {
ColumnDef column = new ColumnDef();
try {
logger.info("Encoded column def: " + encoded);
deserializer.deserialize(column, Hex.hexToBytes(encoded));
} catch (TException e) {
logger.warn("Error deserializing indexed column definition", e);
}
if (null == column.getName() || null == column.validation_class) {
continue;
}
columns.add(column);
}
return columns;
}
开发者ID:2013Commons,项目名称:hive-cassandra,代码行数:31,代码来源:CqlPushdownPredicate.java
示例4: fromString
import org.apache.cassandra.utils.Hex; //导入依赖的package包/类
public ByteBuffer fromString(String source)
{
try
{
return ByteBuffer.wrap(Hex.hexToBytes(source));
}
catch (NumberFormatException e)
{
throw new MarshalException(String.format("cannot parse '%s' as hex bytes", source), e);
}
}
开发者ID:Netflix,项目名称:sstable-adaptor,代码行数:12,代码来源:BytesType.java
示例5: validate
import org.apache.cassandra.utils.Hex; //导入依赖的package包/类
public void validate(String token) throws ConfigurationException
{
try
{
if (token.length() % 2 == 1)
token = "0" + token;
Hex.hexToBytes(token);
}
catch (NumberFormatException e)
{
throw new ConfigurationException("Token " + token + " contains non-hex digits");
}
}
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:14,代码来源:AbstractByteOrderedPartitioner.java
示例6: toString
import org.apache.cassandra.utils.Hex; //导入依赖的package包/类
@Deprecated
public static String toString(List<Object> resource)
{
StringBuilder buff = new StringBuilder();
for (Object component : resource)
{
buff.append("/");
if (component instanceof byte[])
buff.append(Hex.bytesToHex((byte[])component));
else
buff.append(component.toString());
}
return buff.toString();
}
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:15,代码来源:Resources.java
示例7: toString
import org.apache.cassandra.utils.Hex; //导入依赖的package包/类
@Deprecated
public static String toString(List<Object> resource)
{
StringBuilder buff = new StringBuilder();
for (Object component : resource)
{
buff.append("/");
if (component instanceof byte[])
buff.append(Hex.bytesToHex((byte[])component));
else
buff.append(component);
}
return buff.toString();
}
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:15,代码来源:Resources.java
示例8: testValueBytes
import org.apache.cassandra.utils.Hex; //导入依赖的package包/类
@Test
public void testValueBytes() {
ColumnMapperBlob mapper = new ColumnMapperBlob();
byte[] bytes = Hex.hexToBytes("f1");
String parsed = mapper.indexValue("test", bytes);
Assert.assertEquals("f1", parsed);
}
开发者ID:Stratio,项目名称:stratio-cassandra,代码行数:8,代码来源:ColumnMapperBlobTest.java
示例9: serializeIndexedColumns
import org.apache.cassandra.utils.Hex; //导入依赖的package包/类
/**
* Serialize a set of ColumnDefs for indexed columns, so that it can be
* written to Job configuration
*
* @param columns column metadata
* @return serialized form
*/
public static String serializeIndexedColumns(Set<ColumnDef> columns) {
TSerializer serializer = new TSerializer(new TBinaryProtocol.Factory());
try {
List<String> hexStrings = new ArrayList<String>();
for (ColumnDef column : columns) {
String encoded = Hex.bytesToHex(serializer.serialize(column));
logger.info("Encoded column def: " + encoded);
hexStrings.add(encoded);
}
return Joiner.on(AbstractCassandraSerDe.DELIMITER).join(hexStrings);
} catch (TException e) {
throw new RuntimeException(e);
}
}
开发者ID:2013Commons,项目名称:hive-cassandra,代码行数:22,代码来源:CqlPushdownPredicate.java
示例10: toString
import org.apache.cassandra.utils.Hex; //导入依赖的package包/类
@Override
public String toString() {
StringBuilder valuesAsStrings = new StringBuilder();
valuesAsStrings.append("[");
for (ByteBuffer value : values) {
valuesAsStrings.append(Hex.bytesToHex(value.array()));
valuesAsStrings.append(",");
}
valuesAsStrings.deleteCharAt(valuesAsStrings.length()-1);
valuesAsStrings.append("]");
return String.format("CQLRecord(key=%s, values=%s", valuesAsStrings);
}
开发者ID:spotify,项目名称:hdfs2cass,代码行数:13,代码来源:CQLRecord.java
示例11: toString
import org.apache.cassandra.utils.Hex; //导入依赖的package包/类
@Override
public String toString()
{
return Hex.bytesToHex(token);
}
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:6,代码来源:BytesToken.java
注:本文中的org.apache.cassandra.utils.Hex类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论