-
Notifications
You must be signed in to change notification settings - Fork 0
[index] Add Batch method for inserting multiple documents at a time #34
Changes from 4 commits
839c1ef
278e968
02bc291
2933f25
9bdbb22
09f4917
55c2e2c
044873f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,22 @@ | ||
#!/bin/bash | ||
|
||
if [ -z $GOPATH ]; then | ||
echo 'GOPATH is not set' | ||
exit 1 | ||
echo 'GOPATH is not set' | ||
exit 1 | ||
fi | ||
|
||
GENERIC_MAP_PATH=${GOPATH}/src/github.com/m3db/m3ninx/vendor/github.com/m3db/m3x/generics/hashmap | ||
GENERIC_MAP_IMPL=${GENERIC_MAP_PATH}/map.go | ||
|
||
if [ ! -f "$GENERIC_MAP_IMPL" ]; then | ||
echo "${GENERIC_MAP_IMPL} does not exist" | ||
exit 1 | ||
echo "${GENERIC_MAP_IMPL} does not exist" | ||
exit 1 | ||
fi | ||
|
||
GENERATED_PATH=${GOPATH}/src/github.com/m3db/m3ninx/index/segment/mem | ||
if [ ! -d "$GENERATED_PATH" ]; then | ||
echo "${GENERATED_PATH} does not exist" | ||
exit 1 | ||
echo "${GENERATED_PATH} does not exist" | ||
exit 1 | ||
fi | ||
|
||
# NB: We use (genny)[1] to combat the lack of generics in Go. It allows us | ||
|
@@ -32,11 +32,16 @@ fi | |
# [1]: https://github.com/cheekybits/genny | ||
|
||
mkdir -p $GENERATED_PATH/postingsgen | ||
cat $GENERIC_MAP_IMPL \ | ||
| genny -out=${GENERATED_PATH}/postingsgen/generated_map.go \ | ||
-pkg=postingsgen gen "KeyType=[]byte ValueType=postings.MutableList" | ||
cat $GENERIC_MAP_IMPL \ | ||
| genny -out=${GENERATED_PATH}/postingsgen/generated_map.go \ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. While you're here, could you change the name to And also update |
||
-pkg=postingsgen gen "KeyType=[]byte ValueType=postings.MutableList" | ||
|
||
mkdir -p $GENERATED_PATH/fieldsgen | ||
cat $GENERIC_MAP_IMPL \ | ||
| genny -out=${GENERATED_PATH}/fieldsgen/generated_map.go \ | ||
-pkg=fieldsgen gen "KeyType=[]byte ValueType=*postingsgen.ConcurrentMap" | ||
cat $GENERIC_MAP_IMPL \ | ||
| genny -out=${GENERATED_PATH}/fieldsgen/generated_map.go \ | ||
-pkg=fieldsgen gen "KeyType=[]byte ValueType=*postingsgen.ConcurrentMap" | ||
|
||
mkdir -p $GENERATED_PATH/idsgen | ||
cat $GENERIC_MAP_IMPL \ | ||
| genny -out=${GENERATED_PATH}/idsgen/generated_map.go \ | ||
-pkg=idsgen gen "KeyType=[]byte ValueType=struct{}" |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -80,8 +80,9 @@ func (w *writer) Open() error { | |
} | ||
|
||
func (w *writer) Write(d doc.Document) error { | ||
w.enc.PutUvarint(uint64(len(d.Fields))) | ||
w.enc.PutBytes(d.ID) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The encoder/decoder is beginning to look super similar to the types in https://github.com/m3db/m3db/blob/master/serialize/types.go Any chance we can consolidate? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not opposed to consolidating, though given that they live in separate repos that may be difficult at the moment. Perhaps we can track in an issue? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure, #36 |
||
|
||
w.enc.PutUvarint(uint64(len(d.Fields))) | ||
for _, f := range d.Fields { | ||
w.enc.PutBytes(f.Name) | ||
w.enc.PutBytes(f.Value) | ||
|
@@ -228,13 +229,19 @@ func (r *reader) Read() (doc.Document, error) { | |
return doc.Document{}, io.EOF | ||
} | ||
|
||
id, err := r.dec.Bytes() | ||
if err != nil { | ||
return doc.Document{}, err | ||
} | ||
|
||
x, err := r.dec.Uvarint() | ||
if err != nil { | ||
return doc.Document{}, err | ||
} | ||
n := int(x) | ||
|
||
d := doc.Document{ | ||
ID: id, | ||
Fields: make([]doc.Field, n), | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this call
HasID()
? maybe add a test for this case tooThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we need to require an ID here, in fact, in the segment we currently check if a document is valid before checking its ID. We might want to remove the check for the fields though in case we ever want to index just an ID. Not sure if that would ever be needed though.