本文整理汇总了Java中org.voltdb.utils.Encoder.hexEncode方法的典型用法代码示例。如果您正苦于以下问题:Java Encoder.hexEncode方法的具体用法?Java Encoder.hexEncode怎么用?Java Encoder.hexEncode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.voltdb.utils.Encoder
的用法示例。
在下文中一共展示了Encoder.hexEncode方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: compileToCatalog
import org.voltdb.utils.Encoder; //导入方法依赖的package包/类
public void compileToCatalog(Catalog catalog, Database db) throws VoltCompilerException {
String hexDDL = Encoder.hexEncode(m_fullDDL);
catalog.execute("set " + db.getPath() + " schema \"" + hexDDL + "\"");
String xmlCatalog;
try {
xmlCatalog = m_hsql.getXMLFromCatalog();
} catch (HSQLParseException e) {
String msg = "DDL Error: " + e.getMessage();
throw m_compiler.new VoltCompilerException(msg);
}
// output the xml catalog to disk
PrintStream ddlXmlOutput = BuildDirectoryUtils.getDebugOutputPrintStream("schema-xml", "hsql-catalog-output.xml");
ddlXmlOutput.println(xmlCatalog);
ddlXmlOutput.close();
// build the local catalog from the xml catalog
fillCatalogFromXML(catalog, db, xmlCatalog);
}
示例2: getHexEncodedBytes
import org.voltdb.utils.Encoder; //导入方法依赖的package包/类
/**
* Get a ascii-string-safe version of the binary value using a
* hex encoding.
*
* @return A hex-encoded string value representing the serialized
* objects.
*/
public String getHexEncodedBytes() {
buffer.b.flip();
byte bytes[] = new byte[buffer.b.remaining()];
buffer.b.get(bytes);
String hex = Encoder.hexEncode(bytes);
buffer.discard();
return hex;
}
示例3: getHexEncodedBytes
import org.voltdb.utils.Encoder; //导入方法依赖的package包/类
/**
* Get a ascii-string-safe version of the binary value using a
* hex encoding.
*
* @return A hex-encoded string value representing the serialized
* objects.
*/
public String getHexEncodedBytes() {
buffer.b().flip();
byte bytes[] = new byte[buffer.b().remaining()];
buffer.b().get(bytes);
String hex = Encoder.hexEncode(bytes);
buffer.discard();
return hex;
}
示例4: getCacheForCatalogHash
import org.voltdb.utils.Encoder; //导入方法依赖的package包/类
/**
* Get the global cache for a given hash of the catalog. Note that there can be only
* one cache per catalogHash at a time.
*/
public synchronized static AdHocCompilerCache getCacheForCatalogHash(byte[] catalogHash) {
String hashString = Encoder.hexEncode(catalogHash);
AdHocCompilerCache cache = m_catalogHashMatch.getIfPresent(hashString);
if (cache == null) {
cache = new AdHocCompilerCache();
m_catalogHashMatch.put(hashString, cache);
}
return cache;
}
示例5: testUpdateCatalog
import org.voltdb.utils.Encoder; //导入方法依赖的package包/类
@Test
public void testUpdateCatalog() throws IOException {
// only makes sense in pro (sysproc suite has a complementary test for community)
if (VoltDB.instance().getConfig().m_isEnterprise) {
String catalogHex = Encoder.hexEncode("blah");
ByteBuffer msg = createMsg("@UpdateApplicationCatalog", catalogHex, "blah");
ClientResponseImpl resp = m_ci.handleRead(msg, m_handler, m_cxn);
assertNull(resp);
ArgumentCaptor<LocalObjectMessage> captor = ArgumentCaptor.forClass(LocalObjectMessage.class);
verify(m_messenger).send(eq(32L), // A fixed number set in setUpOnce()
captor.capture());
assertTrue(captor.getValue().payload instanceof CatalogChangeWork);
}
}
示例6: toString
import org.voltdb.utils.Encoder; //导入方法依赖的package包/类
@Override
public String toString() {
return Encoder.hexEncode(hashBytes);
}
示例7: report
import org.voltdb.utils.Encoder; //导入方法依赖的package包/类
/**
* Generate the HTML catalog report from a newly compiled VoltDB catalog
*/
public static String report(Catalog catalog, ArrayList<Feedback> warnings, String autoGenDDL) throws IOException {
// asynchronously get platform properties
new Thread() {
@Override
public void run() {
PlatformProperties.getPlatformProperties();
}
}.start();
URL url = Resources.getResource(ReportMaker.class, "template.html");
String contents = Resources.toString(url, Charsets.UTF_8);
Cluster cluster = catalog.getClusters().get("cluster");
assert(cluster != null);
Database db = cluster.getDatabases().get("database");
assert(db != null);
String statsData = getStatsHTML(db, warnings);
contents = contents.replace("##STATS##", statsData);
// generateProceduresTable needs to happen before generateSchemaTable
// because some metadata used in the later is generated in the former
String procData = generateProceduresTable(db.getTables(), db.getProcedures());
contents = contents.replace("##PROCS##", procData);
String schemaData = generateSchemaTable(db);
contents = contents.replace("##SCHEMA##", schemaData);
DatabaseSizes sizes = CatalogSizing.getCatalogSizes(db);
String sizeData = generateSizeTable(sizes);
contents = contents.replace("##SIZES##", sizeData);
String sizeSummary = generateSizeSummary(sizes);
contents = contents.replace("##SIZESUMMARY##", sizeSummary);
String platformData = PlatformProperties.getPlatformProperties().toHTML();
contents = contents.replace("##PLATFORM##", platformData);
contents = contents.replace("##VERSION##", VoltDB.instance().getVersionString());
contents = contents.replace("##DDL##", escapeHtml4(autoGenDDL));
DateFormat df = new SimpleDateFormat("d MMM yyyy HH:mm:ss z");
contents = contents.replace("##TIMESTAMP##", df.format(m_timestamp));
String msg = Encoder.hexEncode(VoltDB.instance().getVersionString() + "," + System.currentTimeMillis());
contents = contents.replace("get.py?a=KEY&", String.format("get.py?a=%s&", msg));
return contents;
}
示例8: testPartitionAndInsert
import org.voltdb.utils.Encoder; //导入方法依赖的package包/类
public void testPartitionAndInsert () throws Exception {
String my_schema =
"create table BLAH (" +
"clm_varinary varbinary(128) default '00' not null," +
"clm_smallint smallint default 0 not null, " +
");";
pathToCatalog = Configuration.getPathToCatalogForTest("csv.jar");
pathToDeployment = Configuration.getPathToCatalogForTest("csv.xml");
builder = new VoltProjectBuilder();
builder.addLiteralSchema(my_schema);
builder.addPartitionInfo("BLAH", "clm_varinary");
//builder.addStmtProcedure("Insert", "INSERT into BLAH values (?, ?, ?, ?, ?, ?, ?);");
boolean success = builder.compile(pathToCatalog, 2, 1, 0);
assertTrue(success);
MiscUtils.copyFile(builder.getPathToDeployment(), pathToDeployment);
config = new VoltDB.Configuration();
config.m_pathToCatalog = pathToCatalog;
config.m_pathToDeployment = pathToDeployment;
localServer = new ServerThread(config);
client = null;
localServer.start();
localServer.waitForInitialization();
client = ClientFactory.createClient();
client.createConnection("localhost");
ClientResponse resp;
resp = client.callProcedure("@AdHoc", "INSERT INTO BLAH VALUES ('22',1);");
assertEquals(1, resp.getResults()[0].asScalarLong());
resp = client.callProcedure("@AdHoc", "INSERT INTO BLAH VALUES ('80',3);" );
assertEquals(1, resp.getResults()[0].asScalarLong());
resp = client.callProcedure("@AdHoc", "INSERT INTO BLAH VALUES ('8081828384858687888990',4);" );
assertEquals(1, resp.getResults()[0].asScalarLong());
Random rand = new Random();
for( int i = 0; i < 1000; i++ ){
byte[] bytes = new byte[rand.nextInt(128)];
rand.nextBytes(bytes);
// Just to mix things up, alternate methods of INSERT among
// literal hex string, hex string parameter, and byte[] parameter.
if ( i % 2 == 0 ) {
String hexString = Encoder.hexEncode(bytes);
if ( i % 4 == 0 ) {
resp = client.callProcedure("@AdHoc", "INSERT INTO BLAH VALUES ('" + hexString + "',5);" );
} else {
resp = client.callProcedure("@AdHoc", "INSERT INTO BLAH VALUES (?,5);", hexString);
}
} else {
resp = client.callProcedure("@AdHoc", "INSERT INTO BLAH VALUES (?,5);", bytes);
}
assertEquals(1, resp.getResults()[0].asScalarLong());
}
resp = client.callProcedure("@AdHoc", "SELECT COUNT(*) FROM BLAH;");
assertEquals(3 + 1000, resp.getResults()[0].asScalarLong());
}