Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/309.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何使用BasicDBObject中的数据检索ArrayList中的数据?_Java_Mongodb_Mongo Java - Fatal编程技术网

Java 如何使用BasicDBObject中的数据检索ArrayList中的数据?

Java 如何使用BasicDBObject中的数据检索ArrayList中的数据?,java,mongodb,mongo-java,Java,Mongodb,Mongo Java,我有一个对象Predictor OBJ,它包含如下数据:{“name”:“mpg”,“type”:“double”} 静态基本对象预测对象 我有一个ArrayList对象配置文件:该配置文件包含如下信息 { "MessageStatus": 2, "Origin": 2.0, "_id": { "$oid": "596340fc8b0fa35d2880d9a7" }, "accerlation": 17.5, "cylinders": 4.0, "displa

我有一个对象Predictor OBJ,它包含如下数据:{“name”:“mpg”,“type”:“double”}

静态基本对象预测对象

我有一个ArrayList对象配置文件:该配置文件包含如下信息

{
  "MessageStatus": 2,
  "Origin": 2.0,
  "_id": {
    "$oid": "596340fc8b0fa35d2880d9a7"
  },
  "accerlation": 17.5,
  "cylinders": 4.0,
  "displacement": 110.0,
  "file_id": {
    "$oid": "59633e48b760e7c8071a6c1c"
  },
  "horsepower": 87.0,
  "message_status": 2,
  "modelyear": 70.0,
  "modified_date": {
    "$date": "2017-07-10T08:47:01.641Z"
  },
  "mpg": 25.0,
  "snet_id": "new_project",
  "unique_id": "413",
  "username": "peugeot 504",
  "weight": 2672.0
}
{
  "MessageStatus": 2,
  "Origin": 3.0,
  "_id": {
    "$oid": "596340fc8b0fa35d2880d9a5"
  },
  "accerlation": 14.5,
  "cylinders": 4.0,
  "displacement": 97.0,
  "file_id": {
    "$oid": "59633e48b760e7c8071a6c1c"
  },
  "horsepower": 88.0,
  "message_status": 2,
  "modelyear": 70.0,
  "modified_date": {
    "$date": "2017-07-10T08:47:01.641Z"
  },
  "mpg": 27.0,
  "snet_id": "new_project",
  "unique_id": "411",
  "username": "datsun pl510",
  "weight": 2130.0
}
{
  "MessageStatus": 2,
  "Origin": 1.0,
  "_id": {
    "$oid": "596340fc8b0fa35d2880d9a4"
  },
  "accerlation": 16.0,
  "cylinders": 6.0,
  "displacement": 200.0,
  "file_id": {
    "$oid": "59633e48b760e7c8071a6c1c"
  },
  "horsepower": 85.0,
  "message_status": 2,
  "modelyear": 70.0,
  "modified_date": {
    "$date": "2017-07-10T08:47:01.641Z"
  },
  "mpg": 21.0,
  "snet_id": "new_project",
  "unique_id": "410",
  "username": "ford maverick",
  "weight": 2587.0
}
{
  "MessageStatus": 2,
  "Origin": 1.0,
  "_id": {
    "$oid": "596340fc8b0fa35d2880d9a3"
  },
  "accerlation": 15.5,
  "cylinders": 6.0,
  "displacement": 199.0,
  "file_id": {
    "$oid": "59633e48b760e7c8071a6c1c"
  },
  "horsepower": 97.0,
  "message_status": 2,
  "modelyear": 70.0,
  "modified_date": {
    "$date": "2017-07-10T08:47:01.641Z"
  },
  "mpg": 18.0,
  "snet_id": "new_project",
  "unique_id": "409",
  "username": "amc hornet",
  "weight": 2774.0
}
{
  "MessageStatus": 2,
  "Origin": 1.0,
  "_id": {
    "$oid": "596340fc8b0fa35d2880d997"
  },
  "accerlation": 10.5,
  "cylinders": 8.0,
  "displacement": 302.0,
  "file_id": {
    "$oid": "59633e48b760e7c8071a6c1c"
  },
  "horsepower": 140.0,
  "message_status": 2,
  "modelyear": 70.0,
  "modified_date": {
    "$date": "2017-07-10T08:47:01.641Z"
  },
  "mpg": 17.0,
  "snet_id": "new_project",
  "unique_id": "397",
  "username": "ford torino",
  "weight": 3449.0
}
{
  "MessageStatus": 2,
  "Origin": 1.0,
  "_id": {
    "$oid": "596340fc8b0fa35d2880d996"
  },
  "accerlation": 12.0,
  "cylinders": 8.0,
  "displacement": 304.0,
  "file_id": {
    "$oid": "59633e48b760e7c8071a6c1c"
  },
  "horsepower": 150.0,
  "message_status": 2,
  "modelyear": 70.0,
  "modified_date": {
    "$date": "2017-07-10T08:47:01.641Z"
  },
  "mpg": 16.0,
  "snet_id": "new_project",
  "unique_id": "396",
  "username": "amc rebel sst",
  "weight": 3433.0
}
{
  "MessageStatus": 2,
  "Origin": 1.0,
  "_id": {
    "$oid": "596340fc8b0fa35d2880d992"
  },
  "accerlation": 19.4,
  "cylinders": 4.0,
  "displacement": 119.0,
  "file_id": {
    "$oid": "59633e48b760e7c8071a6c1c"
  },
  "horsepower": 82.0,
  "message_status": 2,
  "modelyear": 82.0,
  "modified_date": {
    "$date": "2017-07-10T08:47:01.641Z"
  },
  "mpg": 31.0,
  "snet_id": "new_project",
  "unique_id": "392",
  "username": "chevy s-10",
  "weight": 2720.0
}
{
  "MessageStatus": 2,
  "Origin": 1.0,
  "_id": {
    "$oid": "596340fc8b0fa35d2880d991"
  },
  "accerlation": 18.6,
  "cylinders": 4.0,
  "displacement": 120.0,
  "file_id": {
    "$oid": "59633e48b760e7c8071a6c1c"
  },
  "horsepower": 79.0,
  "message_status": 2,
  "modelyear": 82.0,
  "modified_date": {
    "$date": "2017-07-10T08:47:01.641Z"
  },
  "mpg": 28.0,
  "snet_id": "new_project",
  "unique_id": "391",
  "username": "ford ranger",
  "weight": 2625.0
}
{
  "MessageStatus": 2,
  "Origin": 1.0,
  "_id": {
    "$oid": "596340fc8b0fa35d2880d990"
  },
  "accerlation": 11.6,
  "cylinders": 4.0,
  "displacement": 135.0,
  "file_id": {
    "$oid": "59633e48b760e7c8071a6c1c"
  },
  "horsepower": 84.0,
  "message_status": 2,
  "modelyear": 82.0,
  "modified_date": {
    "$date": "2017-07-10T08:47:01.641Z"
  },
  "mpg": 32.0,
  "snet_id": "new_project",
  "unique_id": "390",
  "username": "dodge rampage",
  "weight": 2295.0
}
{
  "MessageStatus": 2,
  "Origin": 2.0,
  "_id": {
    "$oid": "596340fc8b0fa35d2880d98f"
  },
  "accerlation": 24.6,
  "cylinders": 4.0,
  "displacement": 97.0,
  "file_id": {
    "$oid": "59633e48b760e7c8071a6c1c"
  },
  "horsepower": 52.0,
  "message_status": 2,
  "modelyear": 82.0,
  "modified_date": {
    "$date": "2017-07-10T08:47:01.641Z"
  },
  "mpg": 44.0,
  "snet_id": "new_project",
  "unique_id": "389",
  "username": "vw pickup",
  "weight": 2130.0
}
{
  "MessageStatus": 2,
  "Origin": 1.0,
  "_id": {
    "$oid": "596340fc8b0fa35d2880d98a"
  },
  "accerlation": 14.7,
  "cylinders": 6.0,
  "displacement": 232.0,
  "file_id": {
    "$oid": "59633e48b760e7c8071a6c1c"
  },
  "horsepower": 112.0,
  "message_status": 2,
  "modelyear": 82.0,
  "modified_date": {
    "$date": "2017-07-10T08:47:01.641Z"
  },
  "mpg": 22.0,
  "snet_id": "new_project",
  "unique_id": "384",
  "username": "ford granada l",
  "weight": 2835.0
}
{
  "MessageStatus": 2,
  "Origin": 3.0,
  "_id": {
    "$oid": "596340fc8b0fa35d2880d986"
  },
  "accerlation": 16.2,
  "cylinders": 4.0,
  "displacement": 91.0,
  "file_id": {
    "$oid": "59633e48b760e7c8071a6c1c"
  },
  "horsepower": 67.0,
  "message_status": 2,
  "modelyear": 82.0,
  "modified_date": {
    "$date": "2017-07-10T08:47:01.641Z"
  },
  "mpg": 38.0,
  "snet_id": "new_project",
  "unique_id": "380",
  "username": "datsun 310 gx",
  "weight": 1995.0
}
现在我想从profile中检索与predictor对象匹配的数据


有人能帮忙吗

您希望检索的mpg值是多少?它应该是一些双精度值,如25.0等。否则,我们无法匹配或筛选文档。my Predictor OBJ包含两个字段名称和类型,my list对象包含上述数据。但类型包含双精度值。你是说它是像25.0一样的双倍值吗?Yes@notionquestI要将Predictor OBJ中的数据与概要文件数据映射,无论概要文件中的字段与Predictor OBJ匹配什么,我都要收集所有信息并存储到一个收集对象中。Ex:List x=新的ArrayList;x将包含:{“mpg”:{18.0,25.0,29.0…等}