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


Java Bytes类代码示例

本文整理汇总了Java中com.datastax.driver.core.utils.Bytes的典型用法代码示例。如果您正苦于以下问题:Java Bytes类的具体用法?Java Bytes怎么用?Java Bytes使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Bytes类属于com.datastax.driver.core.utils包,在下文中一共展示了Bytes类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: toStatements

import com.datastax.driver.core.utils.Bytes; //导入依赖的package包/类
public static Iterator<Statement> toStatements(Iterator<Row> iterator)
		throws RDFParseException, RDFHandlerException, IOException {
	if (!iterator.hasNext()) {
		return Collections.emptyIterator();
	}

	Set<Statement> ret = new HashSet<Statement>();
	RDFParser rdfParser = Rio.createParser(RDFFormat.BINARY);
	StatementCollector collector = new StatementCollector(ret);
	rdfParser.setRDFHandler(collector);

	while (iterator.hasNext()) {
		toStatements(
				rdfParser,
				Bytes.getArray(iterator.next().getBytes(
						DATA_TABLE_ATTRIBUTE_3)));
	}

	return Collections.unmodifiableSet(ret).iterator();
}
 
开发者ID:markusstocker,项目名称:emrooz,代码行数:21,代码来源:StatementUtils.java

示例2: getStringValue

import com.datastax.driver.core.utils.Bytes; //导入依赖的package包/类
/**
 * Return a String equivalent of an Object.  Useful for writing SQL.
 * @param val the object to String-ify
 * @return the String value
 */
public static String getStringValue(Object val) {
	if (val == null)
		return "NULL";
	if (val instanceof String)
		return "'" + val.toString().replaceAll("'", "''") + "'";	// double any quotes
	if (val instanceof Number)
		return ""+val;
	if (val instanceof ByteBuffer)
		return "'" + Bytes.toHexString((ByteBuffer)val).substring(2) + "'";	// substring(2) is to remove the "0x" at front
	if (val instanceof Date)
		return "'" + (new Timestamp(((Date)val).getTime())).toString() + "'";
	// Boolean, and anything else
	return val.toString();
}
 
开发者ID:att,项目名称:music,代码行数:20,代码来源:Utils.java

示例3: convertEntry

import com.datastax.driver.core.utils.Bytes; //导入依赖的package包/类
@Override
public String[] convertEntry(CredDAO.Data cd) {
	String[] columns = new String[5];
	
	columns[0] = cd.id;
	columns[1] = String.valueOf(cd.type);
	DateFormat df = new SimpleDateFormat(DATE_FORMAT);
	columns[2] = df.format(cd.expires);
	columns[3] = Bytes.toHexString(cd.cred);
	columns[4] = (cd.ns==null)?"":cd.ns;
	
	return columns;
}
 
开发者ID:att,项目名称:AAF,代码行数:14,代码来源:CredEntryConverter.java

示例4: writeFile

import com.datastax.driver.core.utils.Bytes; //导入依赖的package包/类
/**
 * Overwrites the file given by the pair "desc" and "ext" witht the data in
 * the "data" ByteArray.
 *
 * @throws IOException if an exception occurs when communicating to the
 *                     database
 */
public void writeFile(DfsPackDescription desc, PackExt ext,
                      ByteBuffer data) throws IOException {
    try {
        Statement stmt = QueryBuilder.insertInto(keyspace, DATA_TABLE_NAME)
                .value("name", desc.getFileName(ext))
                .value("data", Bytes.toHexString(data));
        session.execute(stmt);
    } catch (RuntimeException e) {
        e.printStackTrace();
        throw new IOException(e);
    }
}
 
开发者ID:benhumphreys,项目名称:jgit-cassandra,代码行数:20,代码来源:ObjStore.java

示例5: get

import com.datastax.driver.core.utils.Bytes; //导入依赖的package包/类
public static byte[] get(byte[] key)
{
    BoundStatement boundStatement = new BoundStatement(getStatement);
    boundStatement.setBytes(0, ByteBuffer.wrap(key));

    final com.datastax.driver.core.ResultSet resultSet =  session.execute(boundStatement);
    final Row row = resultSet.one();
    if (row != null)
    {
        final ByteBuffer byteBuf = row.getBytes("value");
        return Bytes.getArray(byteBuf);
    }

    return null;
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:16,代码来源:CorruptionTest.java

示例6: read

import com.datastax.driver.core.utils.Bytes; //导入依赖的package包/类
public ResourceEntity read(GettableData data) {
  ResourceEntity resourceEntity = new ResourceEntity();
  resourceEntity.setId(data.getString("id"));
  resourceEntity.setDeploymentId(data.getString("deployment_id"));
  resourceEntity.setName(data.getString("name"));
  resourceEntity.setBytes(Bytes.getArray(data.getBytes("content")));
  return resourceEntity;
}
 
开发者ID:camunda,项目名称:camunda-engine-cassandra,代码行数:9,代码来源:ResourceEntitySerializer.java

示例7: serializeKeyToHex

import com.datastax.driver.core.utils.Bytes; //导入依赖的package包/类
@Override
public AsyncFuture<List<String>> serializeKeyToHex(final BackendKey key) {
    final MetricsRowKey rowKey = new MetricsRowKey(key.getSeries(), key.getBase());

    return connection.doto(c -> async.resolved(
        ImmutableList.of(Bytes.toHexString(c.schema.rowKey().serialize(rowKey)))));
}
 
开发者ID:spotify,项目名称:heroic,代码行数:8,代码来源:DatastaxBackend.java

示例8: deserializeKeyFromHex

import com.datastax.driver.core.utils.Bytes; //导入依赖的package包/类
@Override
public AsyncFuture<List<BackendKey>> deserializeKeyFromHex(String key) {
    return connection.doto(c -> {
        final MetricsRowKey rowKey = c.schema.rowKey().deserialize(Bytes.fromHexString(key));
        return async.resolved(
            ImmutableList.of(new BackendKey(rowKey.getSeries(), rowKey.getBase())));
    });
}
 
开发者ID:spotify,项目名称:heroic,代码行数:9,代码来源:DatastaxBackend.java

示例9: asByteArray

import com.datastax.driver.core.utils.Bytes; //导入依赖的package包/类
/**
 * Transforms the given row in a byte array containing term identifiers.
 * 
 * @param row the row.
 * @return a byte array containing term identifiers.
 */
private byte[][] asByteArray(final Row row) {
	final byte[] s = Bytes.getArray(row.getBytesUnsafe(0));
	final byte[] p = Bytes.getArray(row.getBytesUnsafe(1));
	final byte[] o = Bytes.getArray(row.getBytesUnsafe(2));
	final ByteBuffer c = row.getBytesUnsafe(3);
	return (c != null)
		? new byte[][] {s, p, o}
		: new byte[][] {s, p, o, Bytes.getArray(c)};
}
 
开发者ID:spaziocodice,项目名称:jena-nosql,代码行数:16,代码来源:CassandraTripleIndexDAO.java

示例10: generateId

import com.datastax.driver.core.utils.Bytes; //导入依赖的package包/类
/**
 * Generate new id using <code>endpointKeyHash</code> and <code>lastModifyTime</code>.
 *
 * @return id
 */
public String generateId() {
  String id = null;
  if (endpointKeyHash != null) {
    StringBuilder builder = new StringBuilder(Bytes.toHexString(endpointKeyHash));
    builder.append(CassandraModelConstants.KEY_DELIMITER).append(lastModifyTime.getTime());
    id = builder.toString();
  }
  return id;
}
 
开发者ID:kaaproject,项目名称:kaa,代码行数:15,代码来源:CassandraEndpointNotification.java

示例11: parseStringId

import com.datastax.driver.core.utils.Bytes; //导入依赖的package包/类
/**
 * Id consist of endpoint key hash and last modify time, we get these data and assign values on
 * fields <code>endpointKeyHash</code> and <code>lastModifyTime</code>.
 *
 * @param id is id to parsing
 */
public void parseStringId(String id) {
  String[] ids = parseId(id);
  if (ids != null && ids.length == 2) {
    endpointKeyHash = Bytes.fromHexString(ids[0]);
    lastModifyTime = new Date(Long.valueOf(ids[1]));
  }
}
 
开发者ID:kaaproject,项目名称:kaa,代码行数:14,代码来源:CassandraEndpointNotification.java

示例12: getBytes

import com.datastax.driver.core.utils.Bytes; //导入依赖的package包/类
/**
 * This method convert ByteBuffer object to byte array.
 *
 * @return the byte array or null
 */
public static byte[] getBytes(ByteBuffer byteBuffer) {
  byte[] array = null;
  if (byteBuffer != null) {
    array = Bytes.getArray(byteBuffer);
  }
  return array;
}
 
开发者ID:kaaproject,项目名称:kaa,代码行数:13,代码来源:CassandraDaoUtil.java

示例13: convertKeyHashToString

import com.datastax.driver.core.utils.Bytes; //导入依赖的package包/类
/**
 * This method convert ByteBuffer object to string representation,
 * if endpointKeyHash eq null, than return null.
 *
 * @return the String representation of endpoint key hash
 */
public static String convertKeyHashToString(ByteBuffer endpointKeyHash) {
  String id = null;
  if (endpointKeyHash != null) {
    id = Bytes.toHexString(endpointKeyHash);
  }
  return id;
}
 
开发者ID:kaaproject,项目名称:kaa,代码行数:14,代码来源:CassandraDaoUtil.java

示例14: convertStringToKeyHash

import com.datastax.driver.core.utils.Bytes; //导入依赖的package包/类
/**
 * This method convert string representation of endpoint key hash to ByteBuffer object
 * if id eq null, than return null.
 *
 * @return the ByteBuffer object
 */
public static ByteBuffer convertStringToKeyHash(String id) {
  ByteBuffer endpointKeyHash = null;
  if (id != null && id.length() != 0) {
    endpointKeyHash = Bytes.fromHexString(id);
  }
  return endpointKeyHash;
}
 
开发者ID:kaaproject,项目名称:kaa,代码行数:14,代码来源:CassandraDaoUtil.java

示例15: testBytesToStringConversation

import com.datastax.driver.core.utils.Bytes; //导入依赖的package包/类
@Test
public void testBytesToStringConversation() {
  byte[] array = new byte[]{-16, 7, 51, -98, -75, -19, -82, 119, -51, 122, -125, -14, 22, 44, -28, -56, 26, 111, 115, 2};
  String hash = Bytes.toHexString(array);
  LOG.info("---> hash is {}", hash);
  byte[] converted = Bytes.fromHexString(hash).array();
  Assert.assertArrayEquals(array, converted);
  Assert.assertEquals(hash, Bytes.toHexString(converted));
}
 
开发者ID:kaaproject,项目名称:kaa,代码行数:10,代码来源:EndpointNotificationCassandraDaoTest.java


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