mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-09-07 17:15:56 +00:00
Merge branch 'master' into translatekey-writable
This commit is contained in:
commit
248ec3a296
14 changed files with 114 additions and 100 deletions
40
api.go
40
api.go
|
|
@ -217,7 +217,7 @@ func (api *API) Index(ctx context.Context, indexName string) (*Index, error) {
|
|||
|
||||
index := api.holder.Index(indexName)
|
||||
if index == nil {
|
||||
return nil, newNotFoundError(ErrIndexNotFound)
|
||||
return nil, newNotFoundError(ErrIndexNotFound, indexName)
|
||||
}
|
||||
return index, nil
|
||||
}
|
||||
|
|
@ -273,7 +273,7 @@ func (api *API) CreateField(ctx context.Context, indexName string, fieldName str
|
|||
// Find index.
|
||||
index := api.holder.Index(indexName)
|
||||
if index == nil {
|
||||
return nil, newNotFoundError(ErrIndexNotFound)
|
||||
return nil, newNotFoundError(ErrIndexNotFound, indexName)
|
||||
}
|
||||
|
||||
// Create field.
|
||||
|
|
@ -312,7 +312,7 @@ func (api *API) Field(ctx context.Context, indexName, fieldName string) (*Field,
|
|||
|
||||
field := api.holder.Field(indexName, fieldName)
|
||||
if field == nil {
|
||||
return nil, newNotFoundError(ErrFieldNotFound)
|
||||
return nil, newNotFoundError(ErrFieldNotFound, fieldName)
|
||||
}
|
||||
return field, nil
|
||||
}
|
||||
|
|
@ -432,7 +432,7 @@ func (api *API) ImportRoaring(ctx context.Context, indexName, fieldName string,
|
|||
|
||||
index, field, err := api.indexField(indexName, fieldName, shard)
|
||||
if index == nil || field == nil {
|
||||
return newNotFoundError(ErrFieldNotFound)
|
||||
return err
|
||||
}
|
||||
|
||||
if err = req.ValidateWithTimestamp(index.CreatedAt(), field.CreatedAt()); err != nil {
|
||||
|
|
@ -501,7 +501,7 @@ func (api *API) DeleteField(ctx context.Context, indexName string, fieldName str
|
|||
// Find index.
|
||||
index := api.holder.Index(indexName)
|
||||
if index == nil {
|
||||
return newNotFoundError(ErrIndexNotFound)
|
||||
return newNotFoundError(ErrIndexNotFound, indexName)
|
||||
}
|
||||
|
||||
// Delete field from the index.
|
||||
|
|
@ -532,7 +532,7 @@ func (api *API) DeleteAvailableShard(_ context.Context, indexName, fieldName str
|
|||
// Find field.
|
||||
field := api.holder.Field(indexName, fieldName)
|
||||
if field == nil {
|
||||
return newNotFoundError(ErrFieldNotFound)
|
||||
return newNotFoundError(ErrFieldNotFound, fieldName)
|
||||
}
|
||||
|
||||
// Delete shard from the cache.
|
||||
|
|
@ -574,13 +574,13 @@ func (api *API) ExportCSV(ctx context.Context, indexName string, fieldName strin
|
|||
// Find index.
|
||||
index := api.holder.Index(indexName)
|
||||
if index == nil {
|
||||
return newNotFoundError(ErrIndexNotFound)
|
||||
return newNotFoundError(ErrIndexNotFound, indexName)
|
||||
}
|
||||
|
||||
// Find field from the index.
|
||||
field := index.Field(fieldName)
|
||||
if field == nil {
|
||||
return newNotFoundError(ErrFieldNotFound)
|
||||
return newNotFoundError(ErrFieldNotFound, fieldName)
|
||||
}
|
||||
|
||||
// Find the fragment.
|
||||
|
|
@ -739,7 +739,7 @@ func (api *API) TranslateData(ctx context.Context, indexName string, partition i
|
|||
// Retrieve index from holder.
|
||||
idx := api.holder.Index(indexName)
|
||||
if idx == nil {
|
||||
return nil, ErrIndexNotFound
|
||||
return nil, newNotFoundError(ErrIndexNotFound, indexName)
|
||||
}
|
||||
|
||||
// Retrieve translatestore from holder.
|
||||
|
|
@ -890,7 +890,7 @@ func (api *API) Views(ctx context.Context, indexName string, fieldName string) (
|
|||
// Retrieve views.
|
||||
f := api.holder.Field(indexName, fieldName)
|
||||
if f == nil {
|
||||
return nil, ErrFieldNotFound
|
||||
return nil, newNotFoundError(ErrFieldNotFound, fieldName)
|
||||
}
|
||||
|
||||
// Fetch views.
|
||||
|
|
@ -910,7 +910,7 @@ func (api *API) DeleteView(ctx context.Context, indexName string, fieldName stri
|
|||
// Retrieve field.
|
||||
f := api.holder.Field(indexName, fieldName)
|
||||
if f == nil {
|
||||
return ErrFieldNotFound
|
||||
return newNotFoundError(ErrFieldNotFound, fieldName)
|
||||
}
|
||||
|
||||
// Delete the view.
|
||||
|
|
@ -947,7 +947,7 @@ func (api *API) IndexAttrDiff(ctx context.Context, indexName string, blocks []At
|
|||
// Retrieve index from holder.
|
||||
index := api.holder.Index(indexName)
|
||||
if index == nil {
|
||||
return nil, newNotFoundError(ErrIndexNotFound)
|
||||
return nil, newNotFoundError(ErrIndexNotFound, indexName)
|
||||
}
|
||||
|
||||
// Retrieve local blocks.
|
||||
|
|
@ -985,7 +985,7 @@ func (api *API) FieldAttrDiff(ctx context.Context, indexName string, fieldName s
|
|||
// Retrieve index from holder.
|
||||
f := api.holder.Field(indexName, fieldName)
|
||||
if f == nil {
|
||||
return nil, ErrFieldNotFound
|
||||
return nil, newNotFoundError(ErrFieldNotFound, fieldName)
|
||||
}
|
||||
|
||||
// Retrieve local blocks.
|
||||
|
|
@ -1535,14 +1535,14 @@ func (api *API) indexField(indexName string, fieldName string, shard uint64) (*I
|
|||
index := api.holder.Index(indexName)
|
||||
if index == nil {
|
||||
api.server.logger.Printf("fragment error: index=%s, field=%s, shard=%d, err=%s", indexName, fieldName, shard, ErrIndexNotFound.Error())
|
||||
return nil, nil, newNotFoundError(ErrIndexNotFound)
|
||||
return nil, nil, newNotFoundError(ErrIndexNotFound, indexName)
|
||||
}
|
||||
|
||||
// Retrieve field.
|
||||
field := index.Field(fieldName)
|
||||
if field == nil {
|
||||
api.server.logger.Printf("field error: index=%s, field=%s, shard=%d, err=%s", indexName, fieldName, shard, ErrFieldNotFound.Error())
|
||||
return nil, nil, ErrFieldNotFound
|
||||
return nil, nil, newNotFoundError(ErrFieldNotFound, fieldName)
|
||||
}
|
||||
return index, field, nil
|
||||
}
|
||||
|
|
@ -1666,7 +1666,7 @@ func (api *API) GetTranslateEntryReader(ctx context.Context, offsets TranslateOf
|
|||
for indexName, indexMap := range offsets {
|
||||
index := api.holder.Index(indexName)
|
||||
if index == nil {
|
||||
return nil, ErrIndexNotFound
|
||||
return nil, newNotFoundError(ErrIndexNotFound, indexName)
|
||||
}
|
||||
|
||||
for partitionID, offset := range indexMap.Partitions {
|
||||
|
|
@ -1687,13 +1687,13 @@ func (api *API) GetTranslateEntryReader(ctx context.Context, offsets TranslateOf
|
|||
for indexName, indexMap := range offsets {
|
||||
index := api.holder.Index(indexName)
|
||||
if index == nil {
|
||||
return nil, ErrIndexNotFound
|
||||
return nil, newNotFoundError(ErrIndexNotFound, indexName)
|
||||
}
|
||||
|
||||
for fieldName, offset := range indexMap.Fields {
|
||||
field := index.Field(fieldName)
|
||||
if field == nil {
|
||||
return nil, ErrFieldNotFound
|
||||
return nil, newNotFoundError(ErrFieldNotFound, fieldName)
|
||||
}
|
||||
|
||||
r, err := field.TranslateStore().EntryReader(ctx, uint64(offset))
|
||||
|
|
@ -1732,7 +1732,7 @@ func (api *API) TranslateKeys(ctx context.Context, r io.Reader, writable bool) (
|
|||
}
|
||||
} else {
|
||||
if field := api.holder.Field(req.Index, req.Field); field == nil {
|
||||
return nil, ErrFieldNotFound
|
||||
return nil, newNotFoundError(ErrFieldNotFound, req.Field)
|
||||
} else if fi := field.ForeignIndex(); fi != "" {
|
||||
ids, err = api.cluster.translateIndexKeys(ctx, fi, req.Keys, writable)
|
||||
if err != nil {
|
||||
|
|
@ -1768,7 +1768,7 @@ func (api *API) TranslateIDs(ctx context.Context, r io.Reader) (_ []byte, err er
|
|||
}
|
||||
} else {
|
||||
if field := api.holder.Field(req.Index, req.Field); field == nil {
|
||||
return nil, ErrFieldNotFound
|
||||
return nil, newNotFoundError(ErrFieldNotFound, req.Field)
|
||||
} else if fi := field.ForeignIndex(); fi != "" {
|
||||
keys, err = api.cluster.translateIndexIDs(ctx, fi, req.IDs)
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -1586,7 +1586,7 @@ func (c *cluster) followResizeInstruction(instr *ResizeInstruction) error {
|
|||
// Retrieve field.
|
||||
f := c.holder.Field(src.Index, src.Field)
|
||||
if f == nil {
|
||||
return ErrFieldNotFound
|
||||
return newNotFoundError(ErrFieldNotFound, src.Field)
|
||||
}
|
||||
|
||||
// Create view.
|
||||
|
|
@ -1638,7 +1638,7 @@ func (c *cluster) followResizeInstruction(instr *ResizeInstruction) error {
|
|||
|
||||
idx := c.holder.Index(src.Index)
|
||||
if idx == nil {
|
||||
return ErrIndexNotFound
|
||||
return newNotFoundError(ErrIndexNotFound, src.Index)
|
||||
}
|
||||
|
||||
// Retrieve partition from remote node.
|
||||
|
|
@ -2472,7 +2472,7 @@ func (c *cluster) translateIndexIDSet(ctx context.Context, indexName string, idS
|
|||
|
||||
index := c.holder.Index(indexName)
|
||||
if index == nil {
|
||||
return nil, ErrIndexNotFound
|
||||
return nil, newNotFoundError(ErrIndexNotFound, indexName)
|
||||
}
|
||||
|
||||
// Split ids by partition.
|
||||
|
|
|
|||
74
executor.go
74
executor.go
|
|
@ -160,7 +160,7 @@ func (e *executor) Execute(ctx context.Context, index string, q *pql.Query, shar
|
|||
|
||||
idx := e.Holder.Index(index)
|
||||
if idx == nil {
|
||||
return resp, ErrIndexNotFound
|
||||
return resp, newNotFoundError(ErrIndexNotFound, index)
|
||||
}
|
||||
|
||||
needWriteTxn := false
|
||||
|
|
@ -505,7 +505,7 @@ func (e *executor) execute(ctx context.Context, tx Tx, index string, q *pql.Quer
|
|||
// Round up the number of shards.
|
||||
idx := e.Holder.Index(index)
|
||||
if idx == nil {
|
||||
return nil, ErrIndexNotFound
|
||||
return nil, newNotFoundError(ErrIndexNotFound, index)
|
||||
}
|
||||
shards = idx.AvailableShards().Slice()
|
||||
if len(shards) == 0 {
|
||||
|
|
@ -779,7 +779,7 @@ func (e *executor) executeCall(ctx context.Context, tx Tx, index string, c *pql.
|
|||
// Round up the number of shards.
|
||||
idx := e.Holder.Index(index)
|
||||
if idx == nil {
|
||||
return nil, ErrIndexNotFound
|
||||
return nil, newNotFoundError(ErrIndexNotFound, index)
|
||||
}
|
||||
shards = idx.AvailableShards().Slice()
|
||||
if len(shards) == 0 {
|
||||
|
|
@ -976,13 +976,13 @@ func (e *executor) executeFieldValueCall(ctx context.Context, tx Tx, index strin
|
|||
// Fetch index.
|
||||
idx := e.Holder.Index(index)
|
||||
if idx == nil {
|
||||
return ValCount{}, ErrIndexNotFound
|
||||
return ValCount{}, newNotFoundError(ErrIndexNotFound, index)
|
||||
}
|
||||
|
||||
// Fetch field.
|
||||
field := idx.Field(fieldName)
|
||||
if field == nil {
|
||||
return ValCount{}, ErrFieldNotFound
|
||||
return ValCount{}, newNotFoundError(ErrFieldNotFound, fieldName)
|
||||
}
|
||||
|
||||
var colID uint64
|
||||
|
|
@ -1203,7 +1203,7 @@ func (e *executor) executeSum(ctx context.Context, tx Tx, index string, c *pql.C
|
|||
if !opt.Remote {
|
||||
field := e.Holder.Field(index, fieldName)
|
||||
if field == nil {
|
||||
return ValCount{}, ErrFieldNotFound
|
||||
return ValCount{}, newNotFoundError(ErrFieldNotFound, fieldName)
|
||||
}
|
||||
if field.Type() == FieldTypeDecimal {
|
||||
other.DecimalVal = &pql.Decimal{
|
||||
|
|
@ -2148,7 +2148,7 @@ func (e *executor) executeGroupBy(ctx context.Context, tx Tx, index string, c *p
|
|||
|
||||
idx := e.Holder.Index(index)
|
||||
if idx == nil {
|
||||
return nil, ErrIndexNotFound
|
||||
return nil, newNotFoundError(ErrIndexNotFound, index)
|
||||
}
|
||||
|
||||
// perform necessary Rows queries (any that have limit or columns args) -
|
||||
|
|
@ -2181,7 +2181,7 @@ func (e *executor) executeGroupBy(ctx context.Context, tx Tx, index string, c *p
|
|||
}
|
||||
f := idx.Field(fieldName)
|
||||
if f == nil {
|
||||
return nil, ErrFieldNotFound
|
||||
return nil, newNotFoundError(ErrFieldNotFound, fieldName)
|
||||
}
|
||||
switch f.Type() {
|
||||
case FieldTypeInt:
|
||||
|
|
@ -2688,12 +2688,12 @@ func (e *executor) executeRowsShard(ctx context.Context, tx Tx, index string, fi
|
|||
// Fetch index.
|
||||
idx := e.Holder.Index(index)
|
||||
if idx == nil {
|
||||
return nil, ErrIndexNotFound
|
||||
return nil, newNotFoundError(ErrIndexNotFound, index)
|
||||
}
|
||||
// Fetch field.
|
||||
f := e.Holder.Field(index, fieldName)
|
||||
if f == nil {
|
||||
return nil, ErrFieldNotFound
|
||||
return nil, newNotFoundError(ErrFieldNotFound, fieldName)
|
||||
}
|
||||
|
||||
// rowIDs is the result set.
|
||||
|
|
@ -3063,7 +3063,7 @@ func (e *executor) executeExtractShard(ctx context.Context, tx Tx, index string,
|
|||
// Fetch index.
|
||||
idx := e.Holder.Index(index)
|
||||
if idx == nil {
|
||||
return ExtractedIDMatrix{}, ErrIndexNotFound
|
||||
return ExtractedIDMatrix{}, newNotFoundError(ErrIndexNotFound, index)
|
||||
}
|
||||
|
||||
// Decompress columns bitmap.
|
||||
|
|
@ -3096,7 +3096,7 @@ func (e *executor) executeExtractShard(ctx context.Context, tx Tx, index string,
|
|||
// Look up the field.
|
||||
field := idx.Field(name)
|
||||
if field == nil {
|
||||
return ExtractedIDMatrix{}, ErrFieldNotFound
|
||||
return ExtractedIDMatrix{}, newNotFoundError(ErrFieldNotFound, name)
|
||||
}
|
||||
|
||||
switch field.Type() {
|
||||
|
|
@ -3247,7 +3247,7 @@ func (e *executor) executeRowShard(ctx context.Context, tx Tx, index string, c *
|
|||
// Fetch index.
|
||||
idx := e.Holder.Index(index)
|
||||
if idx == nil {
|
||||
return nil, ErrIndexNotFound
|
||||
return nil, newNotFoundError(ErrIndexNotFound, index)
|
||||
}
|
||||
|
||||
// Fetch field name from argument.
|
||||
|
|
@ -3257,7 +3257,7 @@ func (e *executor) executeRowShard(ctx context.Context, tx Tx, index string, c *
|
|||
}
|
||||
f := idx.Field(fieldName)
|
||||
if f == nil {
|
||||
return nil, ErrFieldNotFound
|
||||
return nil, newNotFoundError(ErrFieldNotFound, fieldName)
|
||||
}
|
||||
|
||||
// Parse "from" time, if set.
|
||||
|
|
@ -3374,7 +3374,7 @@ func (e *executor) executeRowBSIGroupShard(ctx context.Context, tx Tx, index str
|
|||
|
||||
f := e.Holder.Field(index, fieldName)
|
||||
if f == nil {
|
||||
return nil, ErrFieldNotFound
|
||||
return nil, newNotFoundError(ErrFieldNotFound, fieldName)
|
||||
}
|
||||
|
||||
// EQ null _exists - frag.NotNull()
|
||||
|
|
@ -3398,7 +3398,7 @@ func (e *executor) executeRowBSIGroupShard(ctx context.Context, tx Tx, index str
|
|||
// Make sure the index supports existence tracking.
|
||||
idx := e.Holder.Index(index)
|
||||
if idx == nil {
|
||||
return nil, ErrIndexNotFound
|
||||
return nil, newNotFoundError(ErrIndexNotFound, index)
|
||||
} else if idx.existenceField() == nil {
|
||||
return nil, errors.Errorf("index does not support existence tracking: %s", index)
|
||||
}
|
||||
|
|
@ -3608,7 +3608,7 @@ func (e *executor) executeNotShard(ctx context.Context, tx Tx, index string, c *
|
|||
// Make sure the index supports existence tracking.
|
||||
idx := e.Holder.Index(index)
|
||||
if idx == nil {
|
||||
return nil, ErrIndexNotFound
|
||||
return nil, newNotFoundError(ErrIndexNotFound, index)
|
||||
} else if idx.existenceField() == nil {
|
||||
return nil, errors.Errorf("index does not support existence tracking: %s", index)
|
||||
}
|
||||
|
|
@ -3643,7 +3643,7 @@ func (e *executor) executeAllCallShard(ctx context.Context, tx Tx, index string,
|
|||
// Make sure the index supports existence tracking.
|
||||
idx := e.Holder.Index(index)
|
||||
if idx == nil {
|
||||
return nil, ErrIndexNotFound
|
||||
return nil, newNotFoundError(ErrIndexNotFound, index)
|
||||
} else if idx.existenceField() == nil {
|
||||
return nil, errors.Errorf("index does not support existence tracking: %s", index)
|
||||
}
|
||||
|
|
@ -3738,11 +3738,11 @@ func (e *executor) executeClearBit(ctx context.Context, tx Tx, index string, c *
|
|||
// Retrieve field.
|
||||
idx := e.Holder.Index(index)
|
||||
if idx == nil {
|
||||
return false, ErrIndexNotFound
|
||||
return false, newNotFoundError(ErrIndexNotFound, index)
|
||||
}
|
||||
f := idx.Field(fieldName)
|
||||
if f == nil {
|
||||
return false, ErrFieldNotFound
|
||||
return false, newNotFoundError(ErrFieldNotFound, fieldName)
|
||||
}
|
||||
|
||||
// Int field.
|
||||
|
|
@ -3805,7 +3805,7 @@ func (e *executor) executeClearRow(ctx context.Context, tx Tx, index string, c *
|
|||
}
|
||||
field := e.Holder.Field(index, fieldName)
|
||||
if field == nil {
|
||||
return false, ErrFieldNotFound
|
||||
return false, newNotFoundError(ErrFieldNotFound, fieldName)
|
||||
}
|
||||
|
||||
switch field.Type() {
|
||||
|
|
@ -3863,7 +3863,7 @@ func (e *executor) executeClearRowShard(ctx context.Context, tx Tx, index string
|
|||
|
||||
field := e.Holder.Field(index, fieldName)
|
||||
if field == nil {
|
||||
return false, ErrFieldNotFound
|
||||
return false, newNotFoundError(ErrFieldNotFound, fieldName)
|
||||
}
|
||||
|
||||
// Remove the row from all views.
|
||||
|
|
@ -3897,7 +3897,7 @@ func (e *executor) executeSetRow(ctx context.Context, tx Tx, indexName string, c
|
|||
// Find index.
|
||||
index := e.Holder.Index(indexName)
|
||||
if index == nil {
|
||||
return false, newNotFoundError(ErrIndexNotFound)
|
||||
return false, newNotFoundError(ErrIndexNotFound, indexName)
|
||||
}
|
||||
|
||||
// Create field.
|
||||
|
|
@ -3909,7 +3909,7 @@ func (e *executor) executeSetRow(ctx context.Context, tx Tx, indexName string, c
|
|||
if err != nil {
|
||||
// We wrap these because we want to indicate that it wasn't found,
|
||||
// but also the problem we encountered trying to create it.
|
||||
return false, newNotFoundError(errors.Wrap(err, "creating field"))
|
||||
return false, newNotFoundError(errors.Wrap(err, "creating field"), fieldName)
|
||||
}
|
||||
}
|
||||
// Ensure the field type supports Store().
|
||||
|
|
@ -3980,7 +3980,7 @@ func (e *executor) executeSetRowShard(ctx context.Context, tx Tx, index string,
|
|||
|
||||
field := e.Holder.Field(index, fieldName)
|
||||
if field == nil {
|
||||
return false, ErrFieldNotFound
|
||||
return false, newNotFoundError(ErrFieldNotFound, fieldName)
|
||||
}
|
||||
|
||||
// Retrieve source row.
|
||||
|
|
@ -4040,11 +4040,11 @@ func (e *executor) executeSet(ctx context.Context, tx Tx, index string, c *pql.C
|
|||
// Retrieve field.
|
||||
idx := e.Holder.Index(index)
|
||||
if idx == nil {
|
||||
return false, ErrIndexNotFound
|
||||
return false, newNotFoundError(ErrIndexNotFound, index)
|
||||
}
|
||||
f := idx.Field(fieldName)
|
||||
if f == nil {
|
||||
return false, ErrFieldNotFound
|
||||
return false, newNotFoundError(ErrFieldNotFound, fieldName)
|
||||
}
|
||||
|
||||
// Set column on existence field.
|
||||
|
|
@ -4219,7 +4219,7 @@ func (e *executor) executeSetRowAttrs(ctx context.Context, tx Tx, index string,
|
|||
// Retrieve field.
|
||||
field := e.Holder.Field(index, fieldName)
|
||||
if field == nil {
|
||||
return ErrFieldNotFound
|
||||
return newNotFoundError(ErrFieldNotFound, fieldName)
|
||||
}
|
||||
|
||||
// Parse labels.
|
||||
|
|
@ -4287,7 +4287,7 @@ func (e *executor) executeBulkSetRowAttrs(ctx context.Context, tx Tx, index stri
|
|||
// Retrieve field.
|
||||
f := e.Holder.Field(index, field)
|
||||
if f == nil {
|
||||
return nil, ErrFieldNotFound
|
||||
return nil, newNotFoundError(ErrFieldNotFound, field)
|
||||
}
|
||||
|
||||
rowID, ok, err := c.UintArg("_" + rowLabel)
|
||||
|
|
@ -4325,7 +4325,7 @@ func (e *executor) executeBulkSetRowAttrs(ctx context.Context, tx Tx, index stri
|
|||
// Retrieve field.
|
||||
field := e.Holder.Field(index, name)
|
||||
if field == nil {
|
||||
return nil, ErrFieldNotFound
|
||||
return nil, newNotFoundError(ErrFieldNotFound, name)
|
||||
}
|
||||
|
||||
// Set attributes.
|
||||
|
|
@ -4373,7 +4373,7 @@ func (e *executor) executeSetColumnAttrs(ctx context.Context, tx Tx, index strin
|
|||
// Retrieve index.
|
||||
idx := e.Holder.Index(index)
|
||||
if idx == nil {
|
||||
return ErrIndexNotFound
|
||||
return newNotFoundError(ErrIndexNotFound, index)
|
||||
}
|
||||
|
||||
col, okCol, errCol := c.UintArg("_" + columnLabel)
|
||||
|
|
@ -4744,7 +4744,7 @@ func (e *executor) collectCallKeySets(ctx context.Context, indexName string, c *
|
|||
if fieldName != "" {
|
||||
idx, exists := e.Holder.indexes[indexName]
|
||||
if !exists {
|
||||
return errors.Wrapf(ErrIndexNotFound, "%s", indexName)
|
||||
return newNotFoundError(ErrIndexNotFound, indexName)
|
||||
}
|
||||
if field := idx.Field(fieldName); field != nil && field.ForeignIndex() != "" {
|
||||
foreignIndexName := field.ForeignIndex()
|
||||
|
|
@ -4792,7 +4792,7 @@ func (e *executor) translateCall(ctx context.Context, indexName string, c *pql.C
|
|||
colKey, rowKey, fieldName := c.TranslateInfo(columnLabel, rowLabel)
|
||||
idx, exists := e.Holder.indexes[indexName]
|
||||
if !exists {
|
||||
return errors.Wrapf(ErrIndexNotFound, "%s", indexName)
|
||||
return newNotFoundError(ErrIndexNotFound, indexName)
|
||||
}
|
||||
if idx.Keys() {
|
||||
if c.Args[colKey] != nil && !isString(c.Args[colKey]) {
|
||||
|
|
@ -5120,7 +5120,7 @@ func (e *executor) translateResult(ctx context.Context, index string, idx *Index
|
|||
// TODO: It may be useful to cache this field lookup.
|
||||
field := idx.Field(g.Field)
|
||||
if field == nil {
|
||||
return nil, ErrFieldNotFound
|
||||
return nil, newNotFoundError(ErrFieldNotFound, g.Field)
|
||||
}
|
||||
if field.Keys() {
|
||||
var key string
|
||||
|
|
@ -5164,7 +5164,7 @@ func (e *executor) translateResult(ctx context.Context, index string, idx *Index
|
|||
}
|
||||
|
||||
if field := idx.Field(fieldName); field == nil {
|
||||
return nil, ErrFieldNotFound
|
||||
return nil, newNotFoundError(ErrFieldNotFound, fieldName)
|
||||
} else if field.Keys() {
|
||||
other.Keys = make([]string, len(result))
|
||||
for i, id := range result {
|
||||
|
|
@ -5188,7 +5188,7 @@ func (e *executor) translateResult(ctx context.Context, index string, idx *Index
|
|||
for i, v := range result.Fields {
|
||||
field := idx.Field(v)
|
||||
if field == nil {
|
||||
return nil, ErrFieldNotFound
|
||||
return nil, newNotFoundError(ErrFieldNotFound, v)
|
||||
}
|
||||
|
||||
datatype, err := field.Datatype()
|
||||
|
|
@ -5844,7 +5844,7 @@ func newGroupByIterator(executor *executor, tx Tx, rowIDs []RowIDs, children []*
|
|||
}
|
||||
field := holder.Field(index, fieldName)
|
||||
if field == nil {
|
||||
return nil, ErrFieldNotFound
|
||||
return nil, newNotFoundError(ErrFieldNotFound, fieldName)
|
||||
}
|
||||
gbi.fields[i].Field = fieldName
|
||||
|
||||
|
|
|
|||
|
|
@ -961,7 +961,7 @@ func (h *Holder) DeleteIndex(name string) error {
|
|||
// Confirm index exists.
|
||||
index := h.index(name)
|
||||
if index == nil {
|
||||
return newNotFoundError(ErrIndexNotFound)
|
||||
return newNotFoundError(ErrIndexNotFound, name)
|
||||
}
|
||||
|
||||
// Close index.
|
||||
|
|
@ -1329,7 +1329,7 @@ func (s *holderSyncer) syncField(index, name string) error {
|
|||
// Retrieve attributes from differing blocks.
|
||||
// Skip update and recomputation if no attributes have changed.
|
||||
m, err := s.Cluster.InternalClient.RowAttrDiff(ctx, &node.URI, index, name, blks)
|
||||
if err == ErrFieldNotFound {
|
||||
if errors.Cause(err) == ErrFieldNotFound {
|
||||
continue // field not created remotely yet, skip
|
||||
} else if err != nil {
|
||||
return errors.Wrap(err, "getting differing blocks")
|
||||
|
|
@ -1358,7 +1358,7 @@ func (s *holderSyncer) syncFragment(index, field, view string, shard uint64) err
|
|||
// Retrieve local field.
|
||||
f := s.Holder.Field(index, field)
|
||||
if f == nil {
|
||||
return ErrFieldNotFound
|
||||
return newNotFoundError(ErrFieldNotFound, field)
|
||||
}
|
||||
|
||||
// Ensure view exists locally.
|
||||
|
|
|
|||
|
|
@ -1101,7 +1101,7 @@ func (c *InternalClient) RowAttrDiff(ctx context.Context, uri *pilosa.URI, index
|
|||
resp, err := c.executeRequest(req.WithContext(ctx))
|
||||
if err != nil {
|
||||
if resp != nil && resp.StatusCode == http.StatusNotFound {
|
||||
return nil, pilosa.ErrFieldNotFound
|
||||
return nil, errors.Wrap(pilosa.ErrFieldNotFound, field)
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
|||
2
index.go
2
index.go
|
|
@ -636,7 +636,7 @@ func (i *Index) DeleteField(name string) error {
|
|||
// Confirm field exists.
|
||||
f := i.field(name)
|
||||
if f == nil {
|
||||
return newNotFoundError(ErrFieldNotFound)
|
||||
return newNotFoundError(ErrFieldNotFound, name)
|
||||
}
|
||||
|
||||
// Close field.
|
||||
|
|
|
|||
2
mtx.go
2
mtx.go
|
|
@ -280,7 +280,7 @@ func (mtx *MultiTx) tx(index string, shard uint64) (_ Tx, err error) {
|
|||
idx := mtx.index
|
||||
if mtx.holder != nil {
|
||||
if idx = mtx.holder.Index(index); idx == nil {
|
||||
return nil, ErrIndexNotFound
|
||||
return nil, newNotFoundError(ErrIndexNotFound, index)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -119,13 +119,11 @@ func newConflictError(err error) ConflictError {
|
|||
|
||||
// NotFoundError wraps an error value to signify that a resource was not found
|
||||
// such that in an HTTP scenario, http.StatusNotFound would be returned.
|
||||
type NotFoundError struct {
|
||||
error
|
||||
}
|
||||
type NotFoundError error
|
||||
|
||||
// newNotFoundError returns err wrapped in a NotFoundError.
|
||||
func newNotFoundError(err error) NotFoundError {
|
||||
return NotFoundError{err}
|
||||
func newNotFoundError(err error, name string) NotFoundError {
|
||||
return NotFoundError(errors.WithMessage(err, name))
|
||||
}
|
||||
|
||||
type PreconditionFailedError struct {
|
||||
|
|
|
|||
|
|
@ -5388,33 +5388,48 @@ func xor(a, b *Container) *Container {
|
|||
|
||||
func xorArrayArray(a, b *Container) *Container {
|
||||
statsHit("xor/ArrayArray")
|
||||
output := make([]uint16, 0)
|
||||
aa, ab := a.array(), b.array()
|
||||
na, nb := len(aa), len(ab)
|
||||
for i, j := 0, 0; i < na || j < nb; {
|
||||
if i < na && j >= nb {
|
||||
output = append(output, aa[i])
|
||||
i++
|
||||
continue
|
||||
} else if i >= na && j < nb {
|
||||
output = append(output, ab[j])
|
||||
j++
|
||||
continue
|
||||
}
|
||||
output := make([]uint16, len(aa)+len(ab))
|
||||
|
||||
i, j, k := 0, 0, 0
|
||||
for i < len(aa) && j < len(ab) {
|
||||
va, vb := aa[i], ab[j]
|
||||
if va < vb {
|
||||
output = append(output, va)
|
||||
i++
|
||||
} else if va > vb {
|
||||
output = append(output, vb)
|
||||
j++
|
||||
} else { //==
|
||||
switch {
|
||||
case va < vb:
|
||||
// The a side is lower, so copy those first.
|
||||
for i < len(aa) && aa[i] < vb {
|
||||
output[k] = aa[i]
|
||||
i++
|
||||
k++
|
||||
}
|
||||
|
||||
case va > vb:
|
||||
// The b side is lower, so copy those first.
|
||||
for j < len(ab) && ab[j] < va {
|
||||
output[k] = ab[j]
|
||||
j++
|
||||
k++
|
||||
}
|
||||
|
||||
default:
|
||||
// Both are equal.
|
||||
// Skip them.
|
||||
i++
|
||||
j++
|
||||
}
|
||||
}
|
||||
return NewContainerArray(output)
|
||||
switch {
|
||||
case i < len(aa):
|
||||
k += copy(output[k:], aa[i:])
|
||||
case j < len(ab):
|
||||
k += copy(output[k:], ab[j:])
|
||||
}
|
||||
|
||||
if k == cap(output) {
|
||||
return NewContainerArray(output)
|
||||
}
|
||||
|
||||
return NewContainerArrayCopy(output[:k])
|
||||
}
|
||||
|
||||
func xorArrayBitmap(a, b *Container) *Container {
|
||||
|
|
|
|||
4
rrtx.go
4
rrtx.go
|
|
@ -310,11 +310,11 @@ func (tx *RoaringTx) getFragment(index, field, view string, shard uint64) (*frag
|
|||
// only thing we can try is the cached index, and hope we aren't being asked for a foreign index.
|
||||
f = tx.Index.Field(field)
|
||||
if f == nil {
|
||||
return nil, ErrFieldNotFound
|
||||
return nil, newNotFoundError(ErrFieldNotFound, field)
|
||||
}
|
||||
} else {
|
||||
if f = idx.Field(field); f == nil {
|
||||
return nil, ErrFieldNotFound
|
||||
return nil, newNotFoundError(ErrFieldNotFound, field)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -621,7 +621,7 @@ func TestHandler_Endpoints(t *testing.T) {
|
|||
h.ServeHTTP(w, test.MustNewHTTPRequest("POST", "/index/i0/query", strings.NewReader(`Row(row=30)`)))
|
||||
if w.Code != gohttp.StatusBadRequest {
|
||||
t.Fatalf("unexpected status code: %d", w.Code)
|
||||
} else if body := w.Body.String(); body != `{"error":"executing: map reduce: field not found"}`+"\n" {
|
||||
} else if body := w.Body.String(); body != `{"error":"executing: map reduce: row: field not found"}`+"\n" {
|
||||
t.Fatalf("unexpected body: %q", body)
|
||||
}
|
||||
})
|
||||
|
|
@ -638,7 +638,7 @@ func TestHandler_Endpoints(t *testing.T) {
|
|||
var resp pilosa.QueryResponse
|
||||
if err := cmd.API.Serializer.Unmarshal(w.Body.Bytes(), &resp); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if s := resp.Err.Error(); s != `executing: map reduce: field not found` {
|
||||
} else if s := resp.Err.Error(); s != `executing: map reduce: row: field not found` {
|
||||
t.Fatalf("unexpected error: %s", s)
|
||||
}
|
||||
})
|
||||
|
|
@ -1156,7 +1156,7 @@ func TestHandler_Endpoints(t *testing.T) {
|
|||
h.ServeHTTP(w, r)
|
||||
if w.Code != gohttp.StatusNotFound {
|
||||
t.Errorf("unexpected status code: %d", w.Code)
|
||||
} else if w.Body.String() != `{"success":false,"error":{"message":"deleting field: field not found"}}`+"\n" {
|
||||
} else if w.Body.String() != `{"success":false,"error":{"message":"deleting field: fld1: field not found"}}`+"\n" {
|
||||
t.Errorf("unexpected body: %q", w.Body.String())
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -247,7 +247,7 @@ func extractWhere(index *pilosa.Index, expr sqlparser.Expr) (string, error) {
|
|||
|
||||
field := index.Field(parseCol.name)
|
||||
if field == nil {
|
||||
return "", pilosa.ErrFieldNotFound
|
||||
return "", errors.Wrap(pilosa.ErrFieldNotFound, parseCol.name)
|
||||
}
|
||||
|
||||
switch field.Type() {
|
||||
|
|
|
|||
|
|
@ -98,7 +98,7 @@ func (s *ShowHandler) execShowFields(ctx context.Context, showStmt *sqlparser.Sh
|
|||
return nil, errors.Wrap(err, "getting schema")
|
||||
}
|
||||
if index == nil {
|
||||
return nil, pilosa.ErrIndexNotFound
|
||||
return nil, errors.WithMessage(pilosa.ErrIndexNotFound, indexName)
|
||||
}
|
||||
fields := index.Fields()
|
||||
sz := len(fields)
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ import (
|
|||
"github.com/pilosa/pilosa/v2/boltdb"
|
||||
"github.com/pilosa/pilosa/v2/pql"
|
||||
"github.com/pilosa/pilosa/v2/testhook"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
var panicOn = pilosa.PanicOn
|
||||
|
|
@ -104,11 +105,11 @@ func (h *Holder) Row(index, field string, rowID uint64) *pilosa.Row {
|
|||
func (h *Holder) ReadRow(index, field string, rowID uint64) *pilosa.Row {
|
||||
idx := h.Holder.Index(index)
|
||||
if idx == nil {
|
||||
panic(pilosa.ErrIndexNotFound)
|
||||
panic(errors.Wrap(pilosa.ErrIndexNotFound, index))
|
||||
}
|
||||
f := idx.Field(field)
|
||||
if f == nil {
|
||||
panic(pilosa.ErrFieldNotFound)
|
||||
panic(errors.Wrap(pilosa.ErrFieldNotFound, field))
|
||||
}
|
||||
tx := idx.Txf.NewTx(pilosa.Txo{Write: false, Field: f})
|
||||
defer tx.Rollback()
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue