Exemple #1
0
func (s *SortCacheIMP) Value(ord int32) (retval interface{}, err error) {
	err = clownfish.TrapErr(func() {
		self := (*C.lucy_SortCache)(clownfish.Unwrap(s, "s"))
		retvalCF := C.LUCY_SortCache_Value(self, C.int32_t(ord))
		defer C.cfish_decref(unsafe.Pointer(retvalCF))
		retval = clownfish.ToGo(unsafe.Pointer(retvalCF))
	})
	return retval, err
}
Exemple #2
0
//export GOLUCY_Doc_Deserialize
func GOLUCY_Doc_Deserialize(d *C.lucy_Doc, instream *C.lucy_InStream) *C.lucy_Doc {
	ivars := C.lucy_Doc_IVARS(d)
	hash := unsafe.Pointer(C.lucy_Freezer_read_hash(instream))
	defer C.cfish_decref(hash)
	fields := clownfish.ToGo(hash)
	fieldsID := registry.store(fields)
	ivars.fields = unsafe.Pointer(fieldsID)
	ivars.doc_id = C.int32_t(C.LUCY_InStream_Read_C32(instream))
	return d
}
Exemple #3
0
func (im *IndexManagerIMP) MakeSnapshotFilename() (retval string, err error) {
	err = clownfish.TrapErr(func() {
		self := (*C.lucy_IndexManager)(clownfish.Unwrap(im, "im"))
		retvalC := C.LUCY_IxManager_Make_Snapshot_Filename(self)
		if retvalC != nil {
			defer C.cfish_decref(unsafe.Pointer(retvalC))
			retval = clownfish.ToGo(unsafe.Pointer(retvalC)).(string)
		}
	})
	return retval, err
}
Exemple #4
0
func (im *IndexManagerIMP) ReadMergeData() (retval map[string]interface{}, err error) {
	err = clownfish.TrapErr(func() {
		self := (*C.lucy_IndexManager)(clownfish.Unwrap(im, "im"))
		retvalC := C.LUCY_IxManager_Read_Merge_Data(self)
		if retvalC != nil {
			defer C.cfish_decref(unsafe.Pointer(retvalC))
			retval = clownfish.ToGo(unsafe.Pointer(retvalC)).(map[string]interface{})
		}
	})
	return retval, err
}
Exemple #5
0
func (f *FolderIMP) SlurpFile(path string) (retval []byte, err error) {
	err = clownfish.TrapErr(func() {
		self := (*C.lucy_Folder)(clownfish.Unwrap(f, "f"))
		pathC := (*C.cfish_String)(clownfish.GoToClownfish(path, unsafe.Pointer(C.CFISH_STRING), false))
		defer C.cfish_decref(unsafe.Pointer(pathC))
		retvalC := C.LUCY_Folder_Slurp_File(self, pathC)
		defer C.cfish_decref(unsafe.Pointer(retvalC))
		retval = clownfish.ToGo(unsafe.Pointer(retvalC)).([]byte)
	})
	return retval, err
}
Exemple #6
0
func (s *SortReaderIMP) fetchSortCache(field string) (retval SortCache, err error) {
	err = clownfish.TrapErr(func() {
		self := (*C.lucy_SortReader)(clownfish.Unwrap(s, "s"))
		fieldC := (*C.cfish_String)(clownfish.GoToClownfish(field, unsafe.Pointer(C.CFISH_STRING), false))
		defer C.cfish_decref(unsafe.Pointer(fieldC))
		retvalCF := C.LUCY_SortReader_Fetch_Sort_Cache(self, fieldC)
		if retvalCF != nil {
			retval = clownfish.ToGo(unsafe.Pointer(C.cfish_incref(unsafe.Pointer(retvalCF)))).(SortCache)
		}
	})
	return retval, err
}
Exemple #7
0
func vecToSpanSlice(v *C.cfish_Vector) []Span {
	if v == nil {
		return nil
	}
	length := int(C.CFISH_Vec_Get_Size(v))
	slice := make([]Span, length)
	for i := 0; i < length; i++ {
		elem := C.CFISH_Vec_Fetch(v, C.size_t(i))
		slice[i] = clownfish.ToGo(unsafe.Pointer(elem)).(Span)
	}
	return slice
}
Exemple #8
0
func (p *PostingListReaderIMP) PostingList(field string, term interface{}) (retval PostingList, err error) {
	err = clownfish.TrapErr(func() {
		self := (*C.lucy_PostingListReader)(clownfish.Unwrap(p, "p"))
		fieldC := (*C.cfish_String)(clownfish.GoToClownfish(field, unsafe.Pointer(C.CFISH_STRING), false))
		defer C.cfish_decref(unsafe.Pointer(fieldC))
		termC := (*C.cfish_Obj)(clownfish.GoToClownfish(term, unsafe.Pointer(C.CFISH_OBJ), true))
		defer C.cfish_decref(unsafe.Pointer(termC))
		retvalCF := C.LUCY_PListReader_Posting_List(self, fieldC, termC)
		if retvalCF != nil {
			retval = clownfish.ToGo(unsafe.Pointer(retvalCF)).(PostingList)
		}
	})
	return retval, err
}
Exemple #9
0
func (lr *LexiconReaderIMP) fetchTermInfo(field string, term interface{}) (retval TermInfo, err error) {
	err = clownfish.TrapErr(func() {
		self := (*C.lucy_LexiconReader)(clownfish.Unwrap(lr, "lr"))
		fieldC := (*C.cfish_String)(clownfish.GoToClownfish(field, unsafe.Pointer(C.CFISH_STRING), false))
		defer C.cfish_decref(unsafe.Pointer(fieldC))
		termC := (*C.cfish_Obj)(clownfish.GoToClownfish(term, unsafe.Pointer(C.CFISH_OBJ), true))
		defer C.cfish_decref(unsafe.Pointer(termC))
		retvalCF := C.LUCY_LexReader_Fetch_Term_Info(self, fieldC, termC)
		if retvalCF != nil {
			retval = clownfish.ToGo(unsafe.Pointer(retvalCF)).(TermInfo)
		}
	})
	return retval, err
}
Exemple #10
0
func (d *DataReaderIMP) GetSegments() []Segment {
	self := (*C.lucy_DataReader)(clownfish.Unwrap(d, "d"))
	retvalCF := C.LUCY_DataReader_Get_Segments(self)
	if retvalCF == nil {
		return nil
	}
	size := C.CFISH_Vec_Get_Size(retvalCF)
	retval := make([]Segment, int(size))
	for i := 0; i < int(size); i++ {
		elem := unsafe.Pointer(C.CFISH_Vec_Fetch(retvalCF, C.size_t(i)))
		retval[i] = clownfish.ToGo(unsafe.Pointer(C.cfish_incref(elem))).(Segment)
	}
	return retval
}
Exemple #11
0
func (r *IndexReaderIMP) SegReaders() []SegReader {
	self := (*C.lucy_IndexReader)(clownfish.Unwrap(r, "r"))
	retvalCF := C.LUCY_IxReader_Seg_Readers(self)
	defer C.cfish_decref(unsafe.Pointer(retvalCF))
	if retvalCF == nil {
		return nil
	}
	size := C.CFISH_Vec_Get_Size(retvalCF)
	retval := make([]SegReader, int(size))
	for i := 0; i < int(size); i++ {
		elem := unsafe.Pointer(C.CFISH_Vec_Fetch(retvalCF, C.size_t(i)))
		retval[i] = clownfish.ToGo(unsafe.Pointer(C.cfish_incref(elem))).(SegReader)
	}
	return retval
}
Exemple #12
0
func (d *DataReaderIMP) Aggregator(readers []DataReader, offsets []int32) (retval DataReader, err error) {
	err = clownfish.TrapErr(func() {
		self := (*C.lucy_DataReader)(clownfish.Unwrap(d, "d"))
		size := len(readers)
		readersC := C.cfish_Vec_new(C.size_t(size))
		defer C.cfish_decref(unsafe.Pointer(readersC))
		for i := 0; i < size; i++ {
			elemC := clownfish.Unwrap(readers[i], "readers[i]")
			C.CFISH_Vec_Push(readersC, C.cfish_incref(elemC))
		}
		offs := NewI32Array(offsets)
		offsetsC := (*C.lucy_I32Array)(clownfish.Unwrap(offs, "offs"))
		retvalCF := C.LUCY_DataReader_Aggregator(self, readersC, offsetsC)
		defer C.cfish_decref(unsafe.Pointer(retvalCF))
		if retvalCF != nil {
			retval = clownfish.ToGo(unsafe.Pointer(retvalCF)).(DataReader)
		}
	})
	return retval, err
}
Exemple #13
0
//export GOLUCY_Doc_Store
func GOLUCY_Doc_Store(d *C.lucy_Doc, field *C.cfish_String, value *C.cfish_Obj) {
	fields := fetchDocFields(d)
	fieldGo := clownfish.CFStringToGo(unsafe.Pointer(field))
	valGo := clownfish.ToGo(unsafe.Pointer(value))
	fields[fieldGo] = valGo
}