mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-10-06 10:57:51 +00:00
sanity check for set_bits
This commit is contained in:
parent
6a46cfe95a
commit
abb0e4531a
1 changed files with 22 additions and 4 deletions
26
core/http.go
26
core/http.go
|
|
@ -372,8 +372,12 @@ func bitmaps(frame string, obj JsonObject) chan uint64 {
|
|||
}
|
||||
atime, _ := time.Parse(shortForm, timestamp)
|
||||
|
||||
for _, id := range index.GetTimeIds(base_id, atime, quantum) {
|
||||
for i, id := range index.GetTimeIds(base_id, atime, quantum) {
|
||||
c <- id
|
||||
if i > 10 {
|
||||
log.Println("TO MANY TIMEIDS", base_id, atime, quantum)
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
|
@ -386,6 +390,14 @@ func bitmaps(frame string, obj JsonObject) chan uint64 {
|
|||
return c
|
||||
}
|
||||
|
||||
type SBResult struct {
|
||||
Bitmap_id uint64
|
||||
Frame string
|
||||
Filter int
|
||||
Profile_id uint64
|
||||
Result interface{}
|
||||
}
|
||||
|
||||
func (self *WebService) HandleSetBit(w http.ResponseWriter, r *http.Request) {
|
||||
if r.Method != "POST" {
|
||||
http.Error(w, "Only POST allowed", http.StatusMethodNotAllowed)
|
||||
|
|
@ -401,7 +413,12 @@ func (self *WebService) HandleSetBit(w http.ResponseWriter, r *http.Request) {
|
|||
return
|
||||
}
|
||||
//[{ "db": "3", "frame":"brand.","profile_id": 122,"filter":0, "bitmap_id":123}]
|
||||
var results []interface{}
|
||||
var results []SBResult
|
||||
if len(args) > 4096 {
|
||||
log.Println("Request too large:", len(args))
|
||||
http.Error(w, "Request To large", http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
for _, obj := range args {
|
||||
if obj["profile_id"] == nil {
|
||||
http.Error(w, "Missing Profile", http.StatusBadRequest)
|
||||
|
|
@ -442,7 +459,8 @@ func (self *WebService) HandleSetBit(w http.ResponseWriter, r *http.Request) {
|
|||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
results = append(results, result)
|
||||
bundle := SBResult{bitmap_id, frame, filter, profile_id, result}
|
||||
results = append(results, bundle)
|
||||
// results = append(results, db+" "+pql)
|
||||
}
|
||||
|
||||
|
|
@ -452,7 +470,7 @@ func (self *WebService) HandleSetBit(w http.ResponseWriter, r *http.Request) {
|
|||
err = encoder.Encode(results)
|
||||
if err != nil {
|
||||
log.Println("Error encoding set_bit", spew.Sdump(results))
|
||||
http.Error(w, "Error econding set_bit", http.StatusMethodNotAllowed)
|
||||
http.Error(w, "Error econding set_bit", http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue