Fix reflection warnings.
This commit is contained in:
parent
07b63150d1
commit
5916642b2b
3 changed files with 29 additions and 21 deletions
|
|
@ -61,7 +61,8 @@
|
|||
(:require [monger.core :as mc]
|
||||
[monger.result :as mres]
|
||||
[monger.conversion :refer :all]
|
||||
[monger.constraints :refer :all]))
|
||||
[monger.constraints :refer :all]
|
||||
[monger.util :refer [into-array-list]]))
|
||||
|
||||
|
||||
;;
|
||||
|
|
@ -450,9 +451,9 @@
|
|||
(defn drop-index
|
||||
"Drops an index from this collection."
|
||||
[^DB db ^String coll idx]
|
||||
(.dropIndex (.getCollection db (name coll)) (if (string? idx)
|
||||
idx
|
||||
(to-db-object idx))))
|
||||
(if (string? idx)
|
||||
(.dropIndex (.getCollection db (name coll)) ^String idx)
|
||||
(.dropIndex (.getCollection db (name coll)) (to-db-object idx))))
|
||||
|
||||
(defn drop-indexes
|
||||
"Drops all indixes from this collection."
|
||||
|
|
@ -524,6 +525,7 @@
|
|||
;;
|
||||
|
||||
(defn- build-aggregation-options
|
||||
^AggregationOptions
|
||||
[{:keys [^Boolean allow-disk-use cursor ^Long max-time]}]
|
||||
(cond-> (AggregationOptions/builder)
|
||||
allow-disk-use (.allowDiskUse allow-disk-use)
|
||||
|
|
@ -543,7 +545,7 @@
|
|||
[^DB db ^String coll stages & opts]
|
||||
(let [coll (.getCollection db coll)
|
||||
agg-opts (build-aggregation-options opts)
|
||||
pipe (java.util.ArrayList. (to-db-object stages))
|
||||
pipe (into-array-list (to-db-object stages))
|
||||
res (.aggregate coll pipe agg-opts)]
|
||||
(map #(from-db-object % true) (iterator-seq res))))
|
||||
|
||||
|
|
@ -554,7 +556,7 @@
|
|||
[^DB db ^String coll stages & opts]
|
||||
(let [coll (.getCollection db coll)
|
||||
agg-opts (build-aggregation-options opts)
|
||||
pipe (java.util.ArrayList. (to-db-object stages))
|
||||
pipe (into-array-list (to-db-object stages))
|
||||
res (.explainAggregate coll pipe agg-opts)]
|
||||
(from-db-object res true)))
|
||||
;;
|
||||
|
|
|
|||
|
|
@ -42,11 +42,12 @@
|
|||
* http://clojuremongodb.info/articles/commands.html
|
||||
* http://clojuremongodb.info/articles/gridfs.html"
|
||||
(:refer-clojure :exclude [count])
|
||||
(:require [monger.conversion :refer :all])
|
||||
(:require [monger.conversion :refer :all]
|
||||
[monger.util :refer [into-array-list]])
|
||||
(:import [com.mongodb MongoClient MongoClientURI MongoCredential DB WriteConcern DBObject DBCursor Bytes
|
||||
MongoClientOptions MongoClientOptions$Builder ServerAddress MapReduceOutput MongoException]
|
||||
[com.mongodb.gridfs GridFS]
|
||||
[java.util Map ArrayList]))
|
||||
[java.util Map]))
|
||||
|
||||
;;
|
||||
;; Defaults
|
||||
|
|
@ -77,18 +78,18 @@
|
|||
([server-address ^MongoClientOptions options]
|
||||
(if (coll? server-address)
|
||||
;; connect to a replica set
|
||||
(let [server-list ^ArrayList (ArrayList. ^java.util.Collection server-address)]
|
||||
(let [server-list (into-array-list server-address)]
|
||||
(MongoClient. server-list options))
|
||||
;; connect to a single instance
|
||||
(MongoClient. ^ServerAddress server-address options)))
|
||||
([server-address ^MongoClientOptions options credentials]
|
||||
(let [creds (if (coll? credentials)
|
||||
credentials
|
||||
[credentials])]
|
||||
(let [creds (into-array-list (if (coll? credentials)
|
||||
credentials
|
||||
[credentials]))]
|
||||
(if (coll? server-address)
|
||||
(let [server-list ^ArrayList (ArrayList. ^java.util.Collection server-address)]
|
||||
(MongoClient. server-list creds options))
|
||||
(MongoClient. ^ServerAddress server-address creds options))))
|
||||
(let [server-list (into-array-list server-address)]
|
||||
(MongoClient. server-list ^java.util.List creds options))
|
||||
(MongoClient. ^ServerAddress server-address ^java.util.List creds options))))
|
||||
([{ :keys [host port uri] :or { host *mongodb-host* port *mongodb-port* }}]
|
||||
(if uri
|
||||
(MongoClient. (MongoClientURI. uri))
|
||||
|
|
@ -100,11 +101,11 @@
|
|||
(connect-with-credentials *mongodb-host* *mongodb-port* credentials))
|
||||
([^String hostname credentials]
|
||||
(connect-with-credentials hostname *mongodb-port* credentials))
|
||||
([^String hostname port credentials]
|
||||
(MongoClient. [(ServerAddress. hostname port)]
|
||||
(if (coll? credentials)
|
||||
credentials
|
||||
[credentials]))))
|
||||
([^String hostname ^long port credentials]
|
||||
(MongoClient. (into-array-list [(ServerAddress. hostname port)])
|
||||
(into-array-list (if (coll? credentials)
|
||||
credentials
|
||||
[credentials])))))
|
||||
|
||||
(defn get-db-names
|
||||
"Gets a list of all database names present on the server"
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@
|
|||
"Returns a new BSON object id, or converts str to BSON object id"
|
||||
([]
|
||||
(ObjectId.))
|
||||
([s]
|
||||
([^String s]
|
||||
(ObjectId. s)))
|
||||
|
||||
(defprotocol GetDocumentId
|
||||
|
|
@ -73,3 +73,8 @@
|
|||
(get-id
|
||||
[^IPersistentMap object]
|
||||
(or (:_id object) (object "_id"))))
|
||||
|
||||
(defn into-array-list
|
||||
"Coerce a j.u.Collection into a j.u.ArrayList."
|
||||
^java.util.ArrayList [^java.util.Collection coll]
|
||||
(java.util.ArrayList. coll))
|
||||
|
|
|
|||
Loading…
Reference in a new issue