本文整理汇总了Golang中simplejsondb/core.Uint32Index.Find方法的典型用法代码示例。如果您正苦于以下问题:Golang Uint32Index.Find方法的具体用法?Golang Uint32Index.Find怎么用?Golang Uint32Index.Find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类simplejsondb/core.Uint32Index
的用法示例。
在下文中一共展示了Uint32Index.Find方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Find
func Find(index core.Uint32Index, buffer dbio.DataBuffer, id uint32) (*core.Record, error) {
rowID, err := index.Find(id)
if err != nil {
return nil, err
}
return core.NewRecordLoader(buffer).Load(id, rowID)
}
示例2: Update
func Update(index core.Uint32Index, buffer dbio.DataBuffer, record *core.Record) error {
rowID, err := index.Find(record.ID)
if err != nil {
return err
}
allocator := core.NewRecordAllocator(buffer)
if err = allocator.Update(rowID, record); err != nil {
return err
}
return nil
}
示例3: Delete
func Delete(index core.Uint32Index, buffer dbio.DataBuffer, id uint32) error {
rowID, err := index.Find(id)
if err != nil {
return err
}
allocator := core.NewRecordAllocator(buffer)
if err := allocator.Remove(rowID); err != nil {
return err
}
return index.Delete(id)
}
示例4: assertIndexCanInsertAndFind
func assertIndexCanInsertAndFind(t *testing.T, index core.Uint32Index, key int, rowID core.RowID) (core.Uint32Key, core.RowID) {
insertOnIndex(t, index, key, rowID)
rowIDFound, err := index.Find(uint32(key))
if err != nil {
t.Fatalf("Error when trying to find rowID with key=%+v: %s", key, err)
}
if rowIDFound == (core.RowID{}) {
t.Errorf("Could not retrieve %d from index right after inserting it", key)
}
if rowIDFound != rowID {
t.Errorf("Invalid value returned from the index: %+v", rowIDFound)
}
return core.Uint32Key(key), rowID
}
示例5: Insert
func Insert(index core.Uint32Index, buffer dbio.DataBuffer, record *core.Record) error {
cb := core.NewDataBlockRepository(buffer).ControlBlock()
buffer.MarkAsDirty(cb.DataBlockID())
rowID, _ := index.Find(record.ID)
if rowID != (core.RowID{}) {
return fmt.Errorf("Key already exists: %d", record.ID)
}
allocator := core.NewRecordAllocator(buffer)
rowID, err := allocator.Add(record)
if err != nil {
return err
}
return index.Insert(record.ID, rowID)
}
示例6: assertIndexCantFindByKey
func assertIndexCantFindByKey(t *testing.T, index core.Uint32Index, key int) {
if _, err := index.Find(uint32(key)); err == nil {
t.Error("Did not remove key from index")
}
}