本文整理汇总了Java中com.iobeam.api.resource.DataStore类的典型用法代码示例。如果您正苦于以下问题:Java DataStore类的具体用法?Java DataStore怎么用?Java DataStore使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DataStore类属于com.iobeam.api.resource包,在下文中一共展示了DataStore类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: convertImportToImportBatchs
import com.iobeam.api.resource.DataStore; //导入依赖的package包/类
private List<ImportBatch> convertImportToImportBatchs(Import imp) {
Map<String, Set<DataPoint>> store = imp.getSeries();
List<ImportBatch> ret = new ArrayList<ImportBatch>();
for (String name : store.keySet()) {
DataStore batch = new DataStore(new String[]{name});
for (DataPoint p : store.get(name)) {
batch.add(p.getTime(), new String[]{name}, new Object[]{p.getValue()});
}
List<DataStore> batches = batch.split(REQ_MAX_POINTS / batch.getColumns().size());
for (DataStore b : batches) {
ret.add(ImportBatch.createLegacy(imp.getProjectId(), imp.getDeviceId(), b));
}
}
return ret;
}
示例2: addBulkData
import com.iobeam.api.resource.DataStore; //导入依赖的package包/类
private void addBulkData(final ImportBatch data) {
if (data == null) {
return;
}
if (data.isFromLegacy()) {
synchronized (dataStoreLock) {
if (dataStore == null) {
dataStore = new Import(deviceId, projectId);
}
String key = data.getData().getColumns().get(0);
DataStore db = seriesToBatch.get(key);
db.merge(data.getData());
}
} else {
final DataStore ds = getDataStore(data.getData().getColumns());
ds.merge(data.getData());
}
}
示例3: testPrepareDataRequests
import com.iobeam.api.resource.DataStore; //导入依赖的package包/类
@Test
public void testPrepareDataRequests() throws Exception {
final Iobeam iobeam = getBuilder().setDeviceId(DEVICE_ID).build();
final DataStore ds = iobeam.createDataStore("col1", "col2");
ds.add("col1", 5);
List<ImportService.Submit> batches = iobeam.prepareDataRequests();
assertEquals(1, batches.size());
ImportBatch b = (ImportBatch) batches.get(0).getBuilder().getContent();
assertFalse(b.isFromLegacy());
iobeam.addData("test", new DataPoint(10));
batches = iobeam.prepareDataRequests();
assertEquals(1, batches.size());
boolean legacy = false;
for (final ImportService.Submit s : batches) {
b = (ImportBatch) s.getBuilder().getContent();
if (b.getData().getColumns().size() == 1) {
assertTrue(b.isFromLegacy());
legacy = true;
} else {
assertFalse(b.isFromLegacy());
}
}
assertTrue(legacy);
}
示例4: splitBigImportBatches
import com.iobeam.api.resource.DataStore; //导入依赖的package包/类
private List<ImportBatch> splitBigImportBatches(ImportBatch imp) {
List<ImportBatch> ret = new ArrayList<ImportBatch>();
DataStore batch = imp.getData();
List<DataStore> batches = batch.split(REQ_MAX_POINTS / batch.getColumns().size());
if (batches.size() == 1) {
ret.add(imp);
} else {
for (DataStore b : batches) {
ret.add(new ImportBatch(imp.getProjectId(), imp.getDeviceId(), b));
}
}
return ret;
}
示例5: getDataStore
import com.iobeam.api.resource.DataStore; //导入依赖的package包/类
/**
* Get the DataStore associated with a collection of column names.
*
* @param columns Collection of columns to find a corresponding DataStore for.
* @return DataStore corresponding to the columns, or null if not found.
*/
public DataStore getDataStore(final Collection<String> columns) {
for (DataStore ds : dataBatches) {
if (ds.hasColumns(columns)) {
return ds;
}
}
return null;
}
示例6: getOrAddDataStore
import com.iobeam.api.resource.DataStore; //导入依赖的package包/类
/**
* Get the DataStore associated with a collection of column names, adding a new one if
* necessary.
*
* @param columns Collection of columns to find a corresponding DataStore for.
* @return DataStore corresponding to the columns.
*/
public DataStore getOrAddDataStore(final Collection<String> columns) {
DataStore ret = getDataStore(columns);
if (ret == null) {
ret = this.createDataStore(columns);
}
return ret;
}
示例7: getDataSize
import com.iobeam.api.resource.DataStore; //导入依赖的package包/类
/**
* Returns the size of all of the data in all the series.
*
* @return Size of the data store, or 0 if it has not been made yet.
*/
public long getDataSize() {
long size = 0;
synchronized (dataStoreLock) {
for (DataStore b : dataBatches) {
size += b.getDataSize();
}
}
return size;
}
示例8: trackDataStore
import com.iobeam.api.resource.DataStore; //导入依赖的package包/类
/**
* Track a DataStore so that any data stored in it will be sent on subsequent send calls.
*
* @param store DataStore to be tracked by this client.
*/
public void trackDataStore(DataStore store) {
synchronized (dataStoreLock) {
dataBatches.add(store);
}
}
示例9: prepareDataRequests
import com.iobeam.api.resource.DataStore; //导入依赖的package包/类
List<ImportService.Submit> prepareDataRequests() throws ApiException {
if (!isInitialized()) {
throw new NotInitializedException();
}
if (deviceId == null) {
throw new ApiException("Device id not set, cannot send data.");
}
// Synchronize so no more data is added to this object while we send.
final List<DataStore> stores;
synchronized (dataStoreLock) {
dataStore = null;
if (dataBatches != null) {
stores = new ArrayList<DataStore>(dataBatches.size());
for (DataStore b : dataBatches) {
if (b.getRows().size() > 0) {
stores.add(DataStore.snapshot(b));
b.reset();
}
}
} else {
stores = Collections.<DataStore>emptyList();
}
}
// No data to send, log a warning and return an empty list.
if (stores.size() == 0) {
logger.warning("No data to send.");
return new ArrayList<ImportService.Submit>();
}
List<ImportBatch> impBatches = new ArrayList<ImportBatch>();
for (final DataStore store : stores) {
boolean legacy = store.getColumns().size() == 1 &&
seriesToBatch.containsKey(store.getColumns().get(0));
if (legacy) {
impBatches.add(ImportBatch.createLegacy(projectId, deviceId, store));
} else {
impBatches.add(new ImportBatch(projectId, deviceId, store));
}
}
ImportService service = new ImportService(client);
return service.submit(impBatches);
}
示例10: createDataStore
import com.iobeam.api.resource.DataStore; //导入依赖的package包/类
/**
* Creates a DataStore with a given set of columns, and tracks it so that any data added will be
* sent on a subsequent send calls.
*
* @param columns Columns in the DataStore
* @return DataStore for storing data for a given set of columns.
*/
public DataStore createDataStore(Collection<String> columns) {
DataStore b = new DataStore(columns);
trackDataStore(b);
return b;
}
示例11: trackDataBatch
import com.iobeam.api.resource.DataStore; //导入依赖的package包/类
/**
* Track a DataStore so that any data stored in it will be sent on subsequent send calls.
*
* @param batch Data stored in a batch/table format.
* @deprecated Use {@link #trackDataStore(DataStore)} instead.
*/
@Deprecated
public void trackDataBatch(DataStore batch) {
trackDataStore(batch);
}