예제 #1
0
파일: index.go 프로젝트: kidaa/lucy
func (obj *IndexerIMP) findFieldC(name string) *C.cfish_String {
	self := ((*C.lucy_Indexer)(unsafe.Pointer(obj.TOPTR())))
	if obj.fieldNames == nil {
		obj.fieldNames = make(map[string]clownfish.String)
	}
	f, ok := obj.fieldNames[name]
	if !ok {
		schema := C.LUCY_Indexer_Get_Schema(self)
		fieldList := C.LUCY_Schema_All_Fields(schema)
		defer C.cfish_dec_refcount(unsafe.Pointer(fieldList))
		for i := 0; i < int(C.CFISH_Vec_Get_Size(fieldList)); i++ {
			cfString := unsafe.Pointer(C.CFISH_Vec_Fetch(fieldList, C.size_t(i)))
			field := clownfish.CFStringToGo(cfString)
			if strings.EqualFold(name, field) {
				C.cfish_inc_refcount(cfString)
				f = clownfish.WRAPString(cfString)
				obj.fieldNames[name] = f
			}
		}
	}
	return (*C.cfish_String)(unsafe.Pointer(f.TOPTR()))
}
예제 #2
0
파일: index.go 프로젝트: rlugojr/lucy
func (obj *IndexerIMP) findRealField(name string) (string, error) {
	self := ((*C.lucy_Indexer)(unsafe.Pointer(obj.TOPTR())))
	if obj.fieldNames == nil {
		obj.fieldNames = make(map[string]string)
	}
	if field, ok := obj.fieldNames[name]; ok {
		return field, nil
	} else {
		schema := C.LUCY_Indexer_Get_Schema(self)
		fieldList := C.LUCY_Schema_All_Fields(schema)
		defer C.cfish_dec_refcount(unsafe.Pointer(fieldList))
		for i := 0; i < int(C.CFISH_Vec_Get_Size(fieldList)); i++ {
			cfString := unsafe.Pointer(C.CFISH_Vec_Fetch(fieldList, C.size_t(i)))
			field := clownfish.CFStringToGo(cfString)
			if strings.EqualFold(name, field) {
				obj.fieldNames[name] = field
				return field, nil
			}
		}
	}
	return "", clownfish.NewErr(fmt.Sprintf("Unknown field: '%v'", name))
}
예제 #3
0
파일: plan.go 프로젝트: rlugojr/lucy
func (s *SchemaIMP) AllFields() []string {
	self := (*C.lucy_Schema)(unsafe.Pointer(s.TOPTR()))
	fieldsCF := C.LUCY_Schema_All_Fields(self)
	defer C.cfish_decref(unsafe.Pointer(fieldsCF))
	return vecToStringSlice(fieldsCF)
}