本文整理汇总了Java中com.mapr.db.MapRDB类的典型用法代码示例。如果您正苦于以下问题:Java MapRDB类的具体用法?Java MapRDB怎么用?Java MapRDB使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MapRDB类属于com.mapr.db包,在下文中一共展示了MapRDB类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getData
import com.mapr.db.MapRDB; //导入依赖的package包/类
@GET
@Produces(APPLICATION_JSON)
public Response getData() throws JsonProcessingException {
List<Document> items = new ArrayList<>();
ObjectMapper object = new ObjectMapper();
table = dao.getStatsTable();
QueryCondition c = MapRDB.newCondition().is("simulationId", QueryCondition.Op.EQUAL, dao.getLastSimulationID());
DocumentStream rs = table.find(c);
if (rs != null) {
for(Document doc : rs) {
items.add(doc);
System.out.println(doc.asJsonString());
}
rs.close();
}
return Response.ok(object.writeValueAsString(items)).build();
}
开发者ID:mapr-demos,项目名称:telco-anomaly-detection-spark,代码行数:21,代码来源:TelcoRestApi.java
示例2: addInitialStats
import com.mapr.db.MapRDB; //导入依赖的package包/类
private void addInitialStats() {
long lastSimulationID = getLastSimulationID();
for(int i=1; i<=Config.TOWER_COUNT; i++) {
Document towerDoc = MapRDB.newDocument().
set("_id", lastSimulationID+"/tower"+i).
set("towerId", i).
set("towerAllInfo", 0).
set("towerFails", 0).
set("towerDurations", 0).
set("sessions", 0).
set("time", 1).
set("simulationId", lastSimulationID);
statsTable.insert(towerDoc);
}
statsTable.flush();
}
开发者ID:mapr-demos,项目名称:telco-anomaly-detection-spark,代码行数:17,代码来源:DAO.java
示例3: mergeScanSpec
import com.mapr.db.MapRDB; //导入依赖的package包/类
public void mergeScanSpec(String functionName, JsonScanSpec scanSpec) {
if (this.condition != null && scanSpec.getCondition() != null) {
QueryCondition newCond = MapRDB.newCondition();
switch (functionName) {
case "booleanAnd":
newCond.and();
break;
case "booleanOr":
newCond.or();
break;
default:
assert(false);
}
newCond.condition(this.condition)
.condition(scanSpec.getCondition())
.close()
.build();
this.condition = newCond;
} else if (scanSpec.getCondition() != null){
this.condition = scanSpec.getCondition();
}
}
开发者ID:axbaretto,项目名称:drill,代码行数:26,代码来源:JsonScanSpec.java
示例4: init
import com.mapr.db.MapRDB; //导入依赖的package包/类
private void init() {
logger.debug("Getting tablet locations");
try {
Configuration conf = new Configuration();
// Fetch table and tabletInfo only once and cache.
table = MapRDB.getTable(scanSpec.getTableName());
tabletInfos = table.getTabletInfos(scanSpec.getCondition());
// Calculate totalRowCount for the table from tabletInfos estimatedRowCount.
// This will avoid calling expensive MapRDBTableStats API to get total rowCount, avoiding
// duplicate work and RPCs to MapR DB server.
for (TabletInfo tabletInfo : tabletInfos) {
totalRowCount += tabletInfo.getEstimatedNumRows();
}
computeRegionsToScan();
} catch (Exception e) {
throw new DrillRuntimeException("Error getting region info for table: " + scanSpec.getTableName(), e);
}
}
开发者ID:axbaretto,项目名称:drill,代码行数:23,代码来源:JsonTableGroupScan.java
示例5: queryByAge
import com.mapr.db.MapRDB; //导入依赖的package包/类
private void queryByAge() {
QueryCondition condition = MapRDB.newCondition()
.is("age", QueryCondition.Op.GREATER , 50)
.build();
int counter = 0;
try(DocumentStream documentStream = table.find(condition)) {
for (Document doc : documentStream ) {
System.out.print(".");
counter++;
}
}
System.out.println("\n\nTotal documents : "+ counter + " for "+ condition);
}
开发者ID:mapr-demos,项目名称:maprdb-ojai-101,代码行数:17,代码来源:Ex04MultipleDocumentsQuery.java
示例6: initTable
import com.mapr.db.MapRDB; //导入依赖的package包/类
private void initTable(String tableName, boolean createTable) throws MapRJsonDocumentLoaderException {
// if we've encountered this table name already, it's open.
if(theTables.containsKey(tableName)) {
theTables.get(tableName);
}
// open table (optionally create it)
// and add to the group of open tables.
try {
theTables.put(tableName, MapRDB.getTable(tableName));
} catch (DBException ex) {
if (createTable) {
try {
theTables.put(tableName, MapRDB.createTable(tableName));
} catch (DBException ex2) {
throw new MapRJsonDocumentLoaderException(
"Encountered error creating table " + tableName, ex2);
}
} else {
throw new MapRJsonDocumentLoaderException(
"MapR DB table " + tableName + "does not exist, and not configured to create", ex);
}
}
}
开发者ID:streamsets,项目名称:datacollector,代码行数:25,代码来源:MapRJson5_2DocumentLoader.java
示例7: recordCount
import com.mapr.db.MapRDB; //导入依赖的package包/类
private int recordCount() {
Table tab;
try {
tab = MapRDB.getTable(TABLE_NAME);
DocumentStream stream = tab.find();
Iterator<Document> iter = stream.iterator();
int i = 0 ;
while(iter.hasNext()) {
iter.next(); // don't care about the returned Document.
i++;
}
tab.close();
return i;
} catch (DBException ex) {
throw ex;
}
}
开发者ID:streamsets,项目名称:datacollector,代码行数:19,代码来源:MapRJsonTargetIT.java
示例8: getTable
import com.mapr.db.MapRDB; //导入依赖的package包/类
private Table getTable(String tableName) {
Table table;
System.out.println("Check DB");
synchronized (lock) {
if (!MapRDB.tableExists(tableName)) {
table = MapRDB.createTable(tableName);
} else {
table = MapRDB.getTable(tableName);
}
}
return table;
}
开发者ID:mapr-demos,项目名称:telco-anomaly-detection-spark,代码行数:13,代码来源:DAO.java
示例9: newSimulation
import com.mapr.db.MapRDB; //导入依赖的package包/类
public void newSimulation(){
DocumentMutation mutation = MapRDB.newMutation().
setOrReplace("time", new Date().getTime()).
increment("simulationId", 1);
simulationTable.update(SIMULATION_KEY, mutation);
addInitialStats();
}
开发者ID:mapr-demos,项目名称:telco-anomaly-detection-spark,代码行数:8,代码来源:DAO.java
示例10: addCDR
import com.mapr.db.MapRDB; //导入依赖的package包/类
public void addCDR(String cdrJson) {
Document document = MapRDB.newDocument(cdrJson);
document.set("simulationId", getLastSimulationID());
cdrsTable.insert(String.format("%08d", document.getLong("simulationId"))+"/00000"+document.getDouble("time") +"/"+ document.getString("callerId")+"/"
+ document.getString("towerId") +"/"+document.getString("state"), document);
System.out.println("inserted " + document.toString());
cdrsTable.flush();
}
开发者ID:mapr-demos,项目名称:telco-anomaly-detection-spark,代码行数:9,代码来源:DAO.java
示例11: receive
import com.mapr.db.MapRDB; //导入依赖的package包/类
private void receive() {
long lastId = DAO.getInstance().getLastSimulationID();
QueryCondition c = MapRDB.newCondition().is("simulationId", QueryCondition.Op.EQUAL, lastId);
for (Document document : table.find(c)) {
store(document.toString());
}
}
开发者ID:mapr-demos,项目名称:telco-anomaly-detection-spark,代码行数:8,代码来源:MaprDBReceiver.java
示例12: getTable
import com.mapr.db.MapRDB; //导入依赖的package包/类
private static Table getTable(String tablePath) {
if ( ! MapRDB.tableExists(tablePath)) {
return MapRDB.createTable(tablePath);
} else {
return MapRDB.getTable(tablePath);
}
}
开发者ID:mapr-demos,项目名称:mapr-streams-sample-programs,代码行数:10,代码来源:DBConsumer.java
示例13: setup
import com.mapr.db.MapRDB; //导入依赖的package包/类
@Override
public void setup(OperatorContext context, OutputMutator output) throws ExecutionSetupException {
this.vectorWriter = new VectorContainerWriter(output, unionEnabled);
this.operatorContext = context;
try {
table = MapRDB.getTable(tableName);
table.setOption(TableOption.EXCLUDEID, !includeId);
documentStream = table.find(condition, projectedFields);
documentReaderIterators = documentStream.documentReaders().iterator();
} catch (DBException e) {
throw new ExecutionSetupException(e);
}
}
开发者ID:axbaretto,项目名称:drill,代码行数:15,代码来源:MaprDBJsonRecordReader.java
示例14: createJsonTables
import com.mapr.db.MapRDB; //导入依赖的package包/类
public static void createJsonTables() throws IOException {
admin = MapRDB.newAdmin();
if (admin.tableExists(TMP_BUSINESS_TABLE)) {
admin.deleteTable(TMP_BUSINESS_TABLE);
}
try (Table table = admin.createTable(TMP_BUSINESS_TABLE);
InputStream in = getJsonStream("json/business.json");
DocumentStream stream = Json.newDocumentStream(in)) {
for (Document document : stream) {
table.insert(document, "business_id");
}
table.flush();
}
}
开发者ID:axbaretto,项目名称:drill,代码行数:16,代码来源:MaprDBTestsSuite.java
示例15: createTable
import com.mapr.db.MapRDB; //导入依赖的package包/类
private void createTable() throws IOException {
// delete table
if ( MapRDB.tableExists(TABLE_PATH)) {
MapRDB.deleteTable(TABLE_PATH);
}
// Admin Tool
Admin admin = MapRDB.newAdmin();
// Create a table descriptor
TableDescriptor tableDescriptor = MapRDB.newTableDescriptor()
.setPath(TABLE_PATH) // set the Path of the table in MapR-FS
.setSplitSize(512) // Size in mebibyte (Mega Binary Bytes)
.setBulkLoad(false); // Created with Bulk mode by default
// Configuration of the default Column Family, used to store JSON element by default
FamilyDescriptor familyDesc = MapRDB.newDefaultFamilyDescriptor()
.setCompression(FamilyDescriptor.Compression.None)
.setInMemory(true); // To tell the DB to keep these value in RAM as much as possible
tableDescriptor.addFamily(familyDesc);
// Create a new colmn family to store specific JSON attributes
familyDesc = MapRDB.newFamilyDescriptor()
.setName("clicks")
.setJsonFieldPath("clicks")
.setCompression(FamilyDescriptor.Compression.ZLIB) // compression for this CF
.setInMemory(false);
tableDescriptor.addFamily(familyDesc);
Table table = admin.createTable(tableDescriptor);
}
开发者ID:mapr-demos,项目名称:maprdb-ojai-101,代码行数:35,代码来源:Ex02MapRdbAdmin.java
示例16: addNewClickToPage
import com.mapr.db.MapRDB; //导入依赖的package包/类
private void addNewClickToPage(String s) {
// add clicks to the document
Document clickDetail = Json.newDocument()
.set("ip", "54.54.54.54")
.set("at", new OTimestamp(new java.util.Date()));
DocumentMutation mutation = MapRDB.newMutation()
.increment("nb_of_clicks", 1)
.append("X", "X")
.append("clicks", Arrays.asList(clickDetail));
table.update("index.html", mutation);
}
开发者ID:mapr-demos,项目名称:maprdb-ojai-101,代码行数:14,代码来源:Ex02MapRdbAdmin.java
示例17: printTableInformation
import com.mapr.db.MapRDB; //导入依赖的package包/类
/**
* Print table information such as Name, Path and Tablets information (sharding)
*
* @param tableName
* @throws IOException
*/
private void printTableInformation(String tableName) throws IOException {
Table table = MapRDB.getTable(tableName);
System.out.println("\n=============== TABLE INFO ===============");
System.out.println(" Table Name : " + table.getName());
System.out.println(" Table Path : " + table.getPath());
System.out.println(" Table Infos : " + Arrays.toString(table.getTabletInfos()));
System.out.println("Table Descriptor : " + table.getTableDescriptor() );
System.out.println("==========================================\n");
}
开发者ID:mapr-demos,项目名称:maprdb-ojai-101,代码行数:18,代码来源:Ex02MapRdbAdmin.java
示例18: getTable
import com.mapr.db.MapRDB; //导入依赖的package包/类
/**
* Get the table, create it if not present
*
* @throws IOException
*/
private Table getTable(String tableName) throws IOException {
Table table;
if (!MapRDB.tableExists(tableName)) {
table = MapRDB.createTable(tableName); // Create the table if not already present
} else {
table = MapRDB.getTable(tableName); // get the table
}
return table;
}
开发者ID:mapr-demos,项目名称:maprdb-ojai-101,代码行数:16,代码来源:Ex01SimpleCRUD.java
示例19: printTableInformation
import com.mapr.db.MapRDB; //导入依赖的package包/类
/**
* Print table information such as Name, Path and Tablets information (sharding)
*
* @param tableName The table to describe
* @throws IOException If anything goes wrong accessing the table
*/
private void printTableInformation(String tableName) throws IOException {
Table table = MapRDB.getTable(tableName);
System.out.println("\n=============== TABLE INFO ===============");
System.out.println(" Table Name : " + table.getName());
System.out.println(" Table Path : " + table.getPath());
System.out.println(" Table Infos : " + Arrays.toString(table.getTabletInfos()));
System.out.println("==========================================\n");
}
开发者ID:mapr-demos,项目名称:maprdb-ojai-101,代码行数:15,代码来源:Ex01SimpleCRUD.java
示例20: insertDocuments
import com.mapr.db.MapRDB; //导入依赖的package包/类
private void insertDocuments(Table table) {
String doc1 = "{\"_id\":\"test001\",\"string_list\":[\"zero\",\"one\",\"two\",\"three\",\"four\"],\"int_list\":[0,1,2,3,4,5],\"doc_list\":[{\"name\":\"subdoc0\",\"value\":\"ZERO\"},{\"name\":\"subdoc1\",\"value\":\"one\"},{\"name\":\"subdoc2\",\"value\":\"two\"},{\"name\":\"subdoc3\",\"value\":\"three\"}]}";
String doc2 ="{\"_id\":\"test002\",\"string_list\":[\"zero\",\"un\",\"deux\",\"trois\",\"quatre\"],\"int_list\":[10,20,30,40,50],\"doc_list\":[{\"name\":\"mood\",\"value\":\"good\"},{\"name\":\"time\",\"value\":\"bad\"},{\"name\":\"temperature\",\"value\":\"hot\"}]}";
String doc3 = "{\"_id\":\"test003\",\"string_list\":[\"0\",\"1\",\"deux\",\"trois\",\"cinq\"],\"int_list\":[0,10,20,3,40,5],\"doc_list\":[{\"name\":\"mood\",\"value\":\"bad\"},{\"name\":\"mood\",\"value\":\"good\"},{\"name\":\"temperature\",\"value\":\"cold\"}]}";
table.insertOrReplace( MapRDB.newDocument(doc1) );
table.insertOrReplace( MapRDB.newDocument(doc2) );
table.insertOrReplace( MapRDB.newDocument(doc3) );
table.flush();
}
开发者ID:mapr-demos,项目名称:maprdb-ojai-101,代码行数:12,代码来源:Ex06ArraysFind.java
注:本文中的com.mapr.db.MapRDB类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论