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


Java DataStore类代码示例

本文整理汇总了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;
}
 
开发者ID:iobeam,项目名称:iobeam-client-java,代码行数:17,代码来源:ImportService.java

示例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());
    }
}
 
开发者ID:iobeam,项目名称:iobeam-client-java,代码行数:21,代码来源:Iobeam.java

示例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);
}
 
开发者ID:iobeam,项目名称:iobeam-client-java,代码行数:27,代码来源:IobeamTest.java

示例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;
}
 
开发者ID:iobeam,项目名称:iobeam-client-java,代码行数:15,代码来源:ImportService.java

示例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;
}
 
开发者ID:iobeam,项目名称:iobeam-client-java,代码行数:15,代码来源:Iobeam.java

示例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;
}
 
开发者ID:iobeam,项目名称:iobeam-client-java,代码行数:15,代码来源:Iobeam.java

示例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;
}
 
开发者ID:iobeam,项目名称:iobeam-client-java,代码行数:15,代码来源:Iobeam.java

示例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);
    }
}
 
开发者ID:iobeam,项目名称:iobeam-client-java,代码行数:11,代码来源:Iobeam.java

示例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);
}
 
开发者ID:iobeam,项目名称:iobeam-client-java,代码行数:46,代码来源:Iobeam.java

示例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;
}
 
开发者ID:iobeam,项目名称:iobeam-client-java,代码行数:14,代码来源:Iobeam.java

示例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);
}
 
开发者ID:iobeam,项目名称:iobeam-client-java,代码行数:11,代码来源:Iobeam.java


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