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


Java DataType类代码示例

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


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

示例1: createJSONDataRepresentation

import org.md2k.datakitapi.datatype.DataType; //导入依赖的package包/类
private boolean createJSONDataRepresentation(JsonWriter writer, Iterator iter, boolean segmentData) throws IOException {
    Gson gson = new GsonBuilder().setPrettyPrinting().create();

    while(iter.hasNext()) {
        List<DataType> result = (List<DataType>) iter.next();
        System.out.println("Iterator:" + result.size());
        for (DataType dt : result) {
            TSV entry = new TSV(dt.getDateTime(), DataTypeConverter.dataTypeToJSON(dt));
            gson.toJson(entry, TSV.class, writer);
        }
        if(segmentData) {
            break;
        }
    }

    return iter.hasNext();
}
 
开发者ID:MD2Korg,项目名称:DataExporter,代码行数:18,代码来源:DataExport.java

示例2: writeCSVDataFile

import org.md2k.datakitapi.datatype.DataType; //导入依赖的package包/类
/**
 * Generate and write a data stream to a CSV file.  Note: meta data that is in the JSON representations is not
 * present in the CSV files.
 *
 * @param id Datastream id
 */
public void writeCSVDataFile(Integer id) {
    try {
        String filename = getOutputFilename(id);


        if (getQueryIDs().contains(id)) {
            Writer writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(filename + "_DATA.csv", false), "utf-8"));
            SQLiteIterator sqli = new SQLiteIterator(statement, id, CSV_BUFFER_SIZE);
            while (sqli.hasNext()) {
                List<DataType> result = sqli.next();
                System.out.println("Iterator:" + result.size());
                for (DataType dt : result) {
                    writer.write(DataTypeConverter.dataTypeToString(dt) + "\n");
                }
            }
            writer.close();

        }


    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
开发者ID:MD2Korg,项目名称:DataExporter,代码行数:31,代码来源:DataExport.java

示例3: subscribe

import org.md2k.datakitapi.datatype.DataType; //导入依赖的package包/类
public void subscribe(String platformType, final String dataSourceType) throws DataKitException {
    DataSourceClient dataSourceClient = findDataSourceClient(platformType, dataSourceType);
    dataKitAPI.subscribe(dataSourceClient, new OnReceiveListener() {
        @Override
        public void onReceived(DataType dataType) {
            try {
                DataTypeDoubleArray dataTypeDoubleArray = (DataTypeDoubleArray) dataType;
                CSVDataPoint csvDataPoint = new CSVDataPoint(dataSourceTypeTOChannel.get(dataSourceType), dataTypeDoubleArray.getDateTime(), dataTypeDoubleArray.getSample()[0]);
                streamProcessorWrapper.addDataPoint(csvDataPoint);
            } catch (Exception ignored) {

            }
        }
    });

}
 
开发者ID:MD2Korg,项目名称:mCerebrum-StreamProcessor,代码行数:17,代码来源:DataKitManager.java

示例4: query

import org.md2k.datakitapi.datatype.DataType; //导入依赖的package包/类
public PendingResult<ArrayList<DataType>> query(final DataSourceClient dataSourceClient, final long starttimestamp, final long endtimestamp) throws DataKitException {
    return new PendingResult<ArrayList<DataType>>() {
        @Override
        public ArrayList<DataType> await() {
            try {
                queryData = null;
                lock();
                Bundle bundle = new Bundle();
                bundle.putInt(Constants.RC_DSID, dataSourceClient.getDs_id());
                bundle.putLong(Constants.RC_STARTTIMESTAMP, starttimestamp);
                bundle.putLong(Constants.RC_ENDTIMESTAMP, endtimestamp);
                prepareAndSend(bundle, MessageType.QUERY);
                semaphoreReceive.tryAcquire(WAIT_TIME, TimeUnit.MILLISECONDS);
            } catch (Exception e) {
                queryData = null;
            } finally {
                unlock();
            }
            return queryData;
        }
    };
}
 
开发者ID:MD2Korg,项目名称:mCerebrum-DataKitAPI,代码行数:23,代码来源:DataKitAPIExecute.java

示例5: query

import org.md2k.datakitapi.datatype.DataType; //导入依赖的package包/类
public synchronized ArrayList<DataType> query(SQLiteDatabase db, int ds_id, long starttimestamp, long endtimestamp) {
    long totalst = System.currentTimeMillis();
    insertDB(db, TABLE_NAME);
    Cursor mCursor;
    ArrayList<DataType> dataTypes = new ArrayList<>();
    String[] columns = new String[]{C_SAMPLE};
    String selection = prepareSelection();
    String[] selectionArgs = prepareSelectionArgs(ds_id, starttimestamp, endtimestamp);
    mCursor = db.query(TABLE_NAME,
            columns, selection, selectionArgs, null, null, null);
    if (mCursor.moveToFirst()) {
        do {
            try {
                dataTypes.add(fromBytes(mCursor.getBlob(mCursor.getColumnIndex(C_SAMPLE))));
            } catch (Exception e) {
                Log.e("DataKit", "Object failed deserialization");
                Log.e("DataKit", "DataSourceID: " + ds_id + " Row: " + mCursor.getLong(mCursor.getColumnIndex(C_ID)));
                e.printStackTrace();
            }
        } while (mCursor.moveToNext());
    }
    mCursor.close();

    return dataTypes;
}
 
开发者ID:MD2Korg,项目名称:mCerebrum-DataKit,代码行数:26,代码来源:DatabaseTable_Data.java

示例6: queryLastKey

import org.md2k.datakitapi.datatype.DataType; //导入依赖的package包/类
public synchronized ArrayList<RowObject> queryLastKey(SQLiteDatabase db, int ds_id, int limit) {
    long totalst = System.currentTimeMillis();
    insertDB(db, TABLE_NAME);
    ArrayList<RowObject> rowObjects = new ArrayList<>();
    String sql = "select _id, sample from data where cc_sync = 0 and datasource_id=" + Integer.toString(ds_id) + " LIMIT " + Integer.toString(limit);
    Cursor mCursor = db.rawQuery(sql, null);
    if (mCursor.moveToFirst()) {
        do {
            try {
                DataType dt = fromBytes(mCursor.getBlob(mCursor.getColumnIndex(C_SAMPLE)));
                rowObjects.add(new RowObject(mCursor.getLong(mCursor.getColumnIndex(C_ID)), dt));
            } catch (Exception e) {
                Log.e("DataKit", "Object failed deserialization");
                Log.e("DataKit", "DataSourceID: " + ds_id + " Row: " + mCursor.getLong(mCursor.getColumnIndex(C_ID)));
                e.printStackTrace();
            }
        } while (mCursor.moveToNext());
    }
    mCursor.close();

    return rowObjects;
}
 
开发者ID:MD2Korg,项目名称:mCerebrum-DataKit,代码行数:23,代码来源:DatabaseTable_Data.java

示例7: querySyncedData

import org.md2k.datakitapi.datatype.DataType; //导入依赖的package包/类
public synchronized ArrayList<RowObject> querySyncedData(SQLiteDatabase db, int ds_id, long ageLimit, int limit) {
    long totalst = System.currentTimeMillis();
    insertDB(db, TABLE_NAME);
    ArrayList<RowObject> rowObjects = new ArrayList<>(limit);
    String sql = "select _id, sample from data where cc_sync = 1 and datasource_id=" + Integer.toString(ds_id) + " and datetime <= " + ageLimit + " LIMIT " + Integer.toString(limit);
    Cursor mCursor = db.rawQuery(sql, null);
    if (mCursor.moveToFirst()) {
        do {
            try {
                DataType dt = fromBytes(mCursor.getBlob(mCursor.getColumnIndex(C_SAMPLE)));
                rowObjects.add(new RowObject(mCursor.getLong(mCursor.getColumnIndex(C_ID)), dt));
            } catch (Exception e) {
                Log.e("DataKit", "Object failed deserialization");
                Log.e("DataKit", "DataSourceID: " + ds_id + " Row: " + mCursor.getLong(mCursor.getColumnIndex(C_ID)));
                e.printStackTrace();
            }
        } while (mCursor.moveToNext());
    }
    mCursor.close();
    return rowObjects;
}
 
开发者ID:MD2Korg,项目名称:mCerebrum-DataKit,代码行数:22,代码来源:DatabaseTable_Data.java

示例8: notifyAllObservers

import org.md2k.datakitapi.datatype.DataType; //导入依赖的package包/类
public Status notifyAllObservers(DataType[] dataTypes, boolean highFrequency, boolean isUpdate) {
    Status status = new Status(Status.SUCCESS);
    if (databaseSubscriber != null) {
        if (highFrequency) {
            status = databaseSubscriber.insertHF(ds_id, (DataTypeDoubleArray[]) dataTypes);
        } else {
            status = databaseSubscriber.insert(ds_id, dataTypes, isUpdate);
        }
    }

    for (Iterator<MessageSubscriber> iterator = messageSubscribers.iterator(); iterator.hasNext(); ) {
        MessageSubscriber subscriber = iterator.next();
        if (!subscriber.update(ds_id, dataTypes))
            iterator.remove();
    }
    return status;
}
 
开发者ID:MD2Korg,项目名称:mCerebrum-DataKit,代码行数:18,代码来源:Publisher.java

示例9: updateSummary

import org.md2k.datakitapi.datatype.DataType; //导入依赖的package包/类
public Status updateSummary(DataSource dataSource, DataType dataType) {
    Status status=null;
    for(int i=0;i<4;i++) {
        int ds_id=registerSummary(dataSource, i);
        long updatedTimestamp = getUpdatedTimestamp(dataType.getDateTime(), i);
        ArrayList<DataType> dataTypeLast = query(ds_id, 1);
        if(dataTypeLast.size()==0){
            status= publishers.receivedData(ds_id, new DataType[]{createDataType(dataType, null, updatedTimestamp)}, false);
        }else if(i==0){
            status= publishers.receivedData(ds_id, new DataType[]{createDataType(dataType, dataTypeLast.get(0), updatedTimestamp)}, true);
        }else if (dataTypeLast.get(0).getDateTime() != updatedTimestamp) {
            status= publishers.receivedData(ds_id, new DataType[]{createDataType(dataType, null, updatedTimestamp)}, false);
        } else {
            status= publishers.receivedData(ds_id, new DataType[]{createDataType(dataType, dataTypeLast.get(0),updatedTimestamp)}, true);
        }
    }
    return status;
}
 
开发者ID:MD2Korg,项目名称:mCerebrum-DataKit,代码行数:19,代码来源:RoutingManager.java

示例10: readWakeupTimeFromDataKit

import org.md2k.datakitapi.datatype.DataType; //导入依赖的package包/类
private void readWakeupTimeFromDataKit() {
    DataKitAPI dataKitAPI = DataKitAPI.getInstance(modelManager.getContext());
    wakeupOffset = -1;
    try {
        ArrayList<DataSourceClient> dataSourceClients = dataKitAPI.find(new DataSourceBuilder().setType(DataSourceType.WAKEUP));
        if (dataSourceClients.size() > 0) {
            ArrayList<DataType> dataTypes = dataKitAPI.query(dataSourceClients.get(0), 1);
            if (dataTypes.size() != 0) {
                DataTypeLong dataTypeLong = (DataTypeLong) dataTypes.get(0);
                wakeupOffset = dataTypeLong.getSample();
            }
        }
    } catch (Exception ignored) {

    }
}
 
开发者ID:MD2Korg,项目名称:mCerebrum-Study,代码行数:17,代码来源:DayStartEndInfoManager.java

示例11: readSleepTimeFromDataKit

import org.md2k.datakitapi.datatype.DataType; //导入依赖的package包/类
private void readSleepTimeFromDataKit() {
    DataKitAPI dataKitAPI = DataKitAPI.getInstance(modelManager.getContext());
    sleepOffset = -1;
    try {
        ArrayList<DataSourceClient> dataSourceClients = dataKitAPI.find(new DataSourceBuilder().setType(DataSourceType.SLEEP));
        if (dataSourceClients.size() > 0) {
            ArrayList<DataType> dataTypes = dataKitAPI.query(dataSourceClients.get(0), 1);
            if (dataTypes.size() != 0) {
                DataTypeLong dataTypeLong = (DataTypeLong) dataTypes.get(0);
                sleepOffset = dataTypeLong.getSample();
            }
        }
    } catch (DataKitException e) {
        LocalBroadcastManager.getInstance(modelManager.getContext()).sendBroadcast(new Intent(Constants.INTENT_RESTART));
    }
}
 
开发者ID:MD2Korg,项目名称:mCerebrum-Study,代码行数:17,代码来源:DayStartEndInfoManager.java

示例12: readFromDataKit

import org.md2k.datakitapi.datatype.DataType; //导入依赖的package包/类
private StudyInfo readFromDataKit() {
    StudyInfo studyInfo = null;
    try {
        DataKitAPI dataKitAPI = DataKitAPI.getInstance(modelManager.getContext());

        DataSourceClient dataSourceClient = dataKitAPI.register(createDataSourceBuilder());
        ArrayList<DataType> dataTypes = dataKitAPI.query(dataSourceClient, 1);
        if (dataTypes.size() != 0) {
            DataTypeJSONObject dataTypeJSONObject = (DataTypeJSONObject) dataTypes.get(0);
            Gson gson = new Gson();
            studyInfo = gson.fromJson(dataTypeJSONObject.getSample().toString(), StudyInfo.class);
        }
    } catch (Exception ignored) {
        LocalBroadcastManager.getInstance(modelManager.getContext()).sendBroadcast(new Intent(Constants.INTENT_RESTART));
    }
    return studyInfo;
}
 
开发者ID:MD2Korg,项目名称:mCerebrum-Study,代码行数:18,代码来源:StudyInfoManager.java

示例13: readFromDataKit

import org.md2k.datakitapi.datatype.DataType; //导入依赖的package包/类
private PrivacyData readFromDataKit() {
    PrivacyData privacyData = null;
    try {
        DataKitAPI dataKitAPI = DataKitAPI.getInstance(modelManager.getContext());
        ArrayList<DataSourceClient> dataSourceClients = dataKitAPI.find(createDataSourceBuilder());
        if (dataSourceClients.size() > 0) {
            ArrayList<DataType> dataTypes = dataKitAPI.query(dataSourceClients.get(0), 1);
            if (dataTypes.size() != 0) {
                try {
                    DataTypeJSONObject dataTypeJSONObject = (DataTypeJSONObject) dataTypes.get(0);
                    Gson gson = new Gson();
                    privacyData = gson.fromJson(dataTypeJSONObject.getSample().toString(), PrivacyData.class);
                } catch (Exception ignored) {
                    privacyData = null;
                    LocalBroadcastManager.getInstance(modelManager.getContext()).sendBroadcast(new Intent(Constants.INTENT_RESTART));
                }
            }
        }
    } catch (DataKitException e) {
        privacyData=null;
        LocalBroadcastManager.getInstance(modelManager.getContext()).sendBroadcast(new Intent(Constants.INTENT_RESTART));
    }
    return privacyData;
}
 
开发者ID:MD2Korg,项目名称:mCerebrum-Study,代码行数:25,代码来源:PrivacyControlManager.java

示例14: updateTable

import org.md2k.datakitapi.datatype.DataType; //导入依赖的package包/类
void updateTable(Intent intent) {
    String sampleStr = "";
    String platform = intent.getStringExtra("platformType") + ":" + intent.getStringExtra("deviceId");
    long count = intent.getLongExtra("count", 0);
    hashMapData.get(platform + "_count").setText(String.valueOf(count));

    double time = (intent.getLongExtra("timestamp", 0) - intent.getLongExtra("starttimestamp", 0)) / 1000.0;
    double freq = (double) count / time;
    hashMapData.get(platform + "_freq").setText(String.format("%.1f", freq));


    DataType data = (DataType) intent.getParcelableExtra("data");
    byte[] sample = ((DataTypeByteArray) data).getSample();
    for (int i = 0; i < sample.length; i++) {
        if (i != 0) sampleStr += ",";
        if (i % 3 == 0 && i != 0) sampleStr += "\n";
        sampleStr = sampleStr + String.valueOf(sample[i]);
    }
    hashMapData.get(platform + "_sample").setText(sampleStr);
}
 
开发者ID:MD2Korg,项目名称:mCerebrum-AutoSense,代码行数:21,代码来源:ActivityMain.java

示例15: getUserInfo

import org.md2k.datakitapi.datatype.DataType; //导入依赖的package包/类
/**
 * Retrieve the user id from its data stream
 *
 * @return populated UserInfo object
 */
private UserInfo getUserInfo() {
    UserInfo result = new UserInfo();

    int streamID = -1;
    try {
        ResultSet rs = statement.executeQuery("select ds_id from datasources where datasources.datasource_type=='USER_INFO'");
        while (rs.next()) {
            streamID = rs.getInt("ds_id");
        }
    } catch (SQLException e) {
        e.printStackTrace();
    }

    if (streamID >= 0) {
        SQLiteIterator sqli = new SQLiteIterator(statement, streamID, SHORT_BUFFER_SIZE);
        while(sqli.hasNext()) {
            List<DataType> user = sqli.next();
            for (DataType dt : user) {
                String[] json = DataTypeConverter.dataTypeToString(dt).split(",", 2);
                Gson gson = new GsonBuilder().setPrettyPrinting().create();
                UserInfo ui = gson.fromJson(json[1], UserInfo.class);
                if (!ui.uuid.isEmpty()) {
                    return ui;
                }

            }
        }
    }
    return result;
}
 
开发者ID:MD2Korg,项目名称:DataExporter,代码行数:36,代码来源:DataExport.java


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