本文整理汇总了C++中Hash_Fetch函数的典型用法代码示例。如果您正苦于以下问题:C++ Hash_Fetch函数的具体用法?C++ Hash_Fetch怎么用?C++ Hash_Fetch使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Hash_Fetch函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DocVec_Term_Vector_IMP
TermVector*
DocVec_Term_Vector_IMP(DocVector *self, String *field,
String *term_text) {
DocVectorIVARS *const ivars = DocVec_IVARS(self);
Hash *field_vector = (Hash*)Hash_Fetch(ivars->field_vectors, (Obj*)field);
// If no cache hit, try to fill cache.
if (field_vector == NULL) {
ByteBuf *field_buf
= (ByteBuf*)Hash_Fetch(ivars->field_bufs, (Obj*)field);
// Bail if there's no content or the field isn't highlightable.
if (field_buf == NULL) { return NULL; }
field_vector = S_extract_tv_cache(field_buf);
Hash_Store(ivars->field_vectors, (Obj*)field, (Obj*)field_vector);
}
// Get a buf for the term text or bail.
ByteBuf *tv_buf = (ByteBuf*)Hash_Fetch(field_vector, (Obj*)term_text);
if (tv_buf == NULL) {
return NULL;
}
return S_extract_tv_from_tv_buf(field, term_text, tv_buf);
}
示例2: DocVec_term_vector
TermVector*
DocVec_term_vector(DocVector *self, const CharBuf *field,
const CharBuf *term_text) {
Hash *field_vector = (Hash*)Hash_Fetch(self->field_vectors, (Obj*)field);
// If no cache hit, try to fill cache.
if (field_vector == NULL) {
ByteBuf *field_buf
= (ByteBuf*)Hash_Fetch(self->field_bufs, (Obj*)field);
// Bail if there's no content or the field isn't highlightable.
if (field_buf == NULL) { return NULL; }
field_vector = S_extract_tv_cache(field_buf);
Hash_Store(self->field_vectors, (Obj*)field, (Obj*)field_vector);
}
// Get a buf for the term text or bail.
ByteBuf *tv_buf = (ByteBuf*)Hash_Fetch(field_vector, (Obj*)term_text);
if (tv_buf == NULL) {
return NULL;
}
return S_extract_tv_from_tv_buf(field, term_text, tv_buf);
}
示例3: S_init_sub_readers
static void
S_init_sub_readers(PolyReader *self, VArray *sub_readers) {
PolyReaderIVARS *const ivars = PolyReader_IVARS(self);
uint32_t num_sub_readers = VA_Get_Size(sub_readers);
int32_t *starts = (int32_t*)MALLOCATE(num_sub_readers * sizeof(int32_t));
Hash *data_readers = Hash_new(0);
DECREF(ivars->sub_readers);
DECREF(ivars->offsets);
ivars->sub_readers = (VArray*)INCREF(sub_readers);
// Accumulate doc_max, subreader start offsets, and DataReaders.
ivars->doc_max = 0;
for (uint32_t i = 0; i < num_sub_readers; i++) {
SegReader *seg_reader = (SegReader*)VA_Fetch(sub_readers, i);
Hash *components = SegReader_Get_Components(seg_reader);
CharBuf *api;
DataReader *component;
starts[i] = ivars->doc_max;
ivars->doc_max += SegReader_Doc_Max(seg_reader);
Hash_Iterate(components);
while (Hash_Next(components, (Obj**)&api, (Obj**)&component)) {
VArray *readers = (VArray*)Hash_Fetch(data_readers, (Obj*)api);
if (!readers) {
readers = VA_new(num_sub_readers);
Hash_Store(data_readers, (Obj*)api, (Obj*)readers);
}
VA_Store(readers, i, INCREF(component));
}
}
ivars->offsets = I32Arr_new_steal(starts, num_sub_readers);
CharBuf *api;
VArray *readers;
Hash_Iterate(data_readers);
while (Hash_Next(data_readers, (Obj**)&api, (Obj**)&readers)) {
DataReader *datareader
= (DataReader*)CERTIFY(S_first_non_null(readers), DATAREADER);
DataReader *aggregator
= DataReader_Aggregator(datareader, readers, ivars->offsets);
if (aggregator) {
CERTIFY(aggregator, DATAREADER);
Hash_Store(ivars->components, (Obj*)api, (Obj*)aggregator);
}
}
DECREF(data_readers);
DeletionsReader *del_reader
= (DeletionsReader*)Hash_Fetch(
ivars->components, (Obj*)VTable_Get_Name(DELETIONSREADER));
ivars->del_count = del_reader ? DelReader_Del_Count(del_reader) : 0;
}
示例4: Seg_store_metadata
void
Seg_store_metadata(Segment *self, const CharBuf *key, Obj *value) {
if (Hash_Fetch(self->metadata, (Obj*)key)) {
THROW(ERR, "Metadata key '%o' already registered", key);
}
Hash_Store(self->metadata, (Obj*)key, value);
}
示例5: SegReader_init
SegReader*
SegReader_init(SegReader *self, Schema *schema, Folder *folder,
Snapshot *snapshot, Vector *segments, int32_t seg_tick) {
Segment *segment;
IxReader_init((IndexReader*)self, schema, folder, snapshot, segments,
seg_tick, NULL);
SegReaderIVARS *const ivars = SegReader_IVARS(self);
segment = SegReader_Get_Segment(self);
ivars->doc_max = (int32_t)Seg_Get_Count(segment);
ivars->seg_name = (String*)INCREF(Seg_Get_Name(segment));
ivars->seg_num = Seg_Get_Number(segment);
Err *error = Err_trap(S_try_init_components, self);
if (error) {
// An error occurred, so clean up self and rethrow the exception.
DECREF(self);
RETHROW(error);
}
DeletionsReader *del_reader
= (DeletionsReader*)Hash_Fetch(
ivars->components, Class_Get_Name(DELETIONSREADER));
ivars->del_count = del_reader ? DelReader_Del_Count(del_reader) : 0;
return self;
}
示例6: RAMFolder_local_is_directory
bool_t
RAMFolder_local_is_directory(RAMFolder *self, const CharBuf *name)
{
Obj *entry = Hash_Fetch(self->entries, (Obj*)name);
if (entry && Obj_Is_A(entry, FOLDER)) { return true; }
return false;
}
示例7: RAMFolder_open_filedes
FileDes*
RAMFolder_open_filedes(RAMFolder *self, const CharBuf *filepath)
{
RAMFileDes *file_des
= (RAMFileDes*)Hash_Fetch(self->elems, filepath);
return file_des ? (FileDes*)INCREF(file_des) : NULL;
}
示例8: CFReader_Local_Find_Folder_IMP
Folder*
CFReader_Local_Find_Folder_IMP(CompoundFileReader *self,
String *name) {
CompoundFileReaderIVARS *const ivars = CFReader_IVARS(self);
if (Hash_Fetch(ivars->records, name)) { return false; }
return Folder_Local_Find_Folder(ivars->real_folder, name);
}
示例9: CFReader_Local_Exists_IMP
bool
CFReader_Local_Exists_IMP(CompoundFileReader *self, String *name) {
CompoundFileReaderIVARS *const ivars = CFReader_IVARS(self);
if (Hash_Fetch(ivars->records, name)) { return true; }
if (Folder_Local_Exists(ivars->real_folder, name)) { return true; }
return false;
}
示例10: CFReader_Local_Open_In_IMP
InStream*
CFReader_Local_Open_In_IMP(CompoundFileReader *self, String *name) {
CompoundFileReaderIVARS *const ivars = CFReader_IVARS(self);
Hash *entry = (Hash*)Hash_Fetch(ivars->records, name);
if (!entry) {
InStream *instream = Folder_Local_Open_In(ivars->real_folder, name);
if (!instream) {
ERR_ADD_FRAME(Err_get_error());
}
return instream;
}
else {
Obj *len = Hash_Fetch_Utf8(entry, "length", 6);
Obj *offset = Hash_Fetch_Utf8(entry, "offset", 6);
if (!len || !offset) {
Err_set_error(Err_new(Str_newf("Malformed entry for '%o' in '%o'",
name, Folder_Get_Path(ivars->real_folder))));
return NULL;
}
else if (Str_Get_Size(ivars->path)) {
String *fullpath = Str_newf("%o/%o", ivars->path, name);
InStream *instream = InStream_Reopen(ivars->instream, fullpath,
Obj_To_I64(offset), Obj_To_I64(len));
DECREF(fullpath);
return instream;
}
else {
return InStream_Reopen(ivars->instream, name, Obj_To_I64(offset),
Obj_To_I64(len));
}
}
}
示例11: RAMFolder_local_delete
bool_t
RAMFolder_local_delete(RAMFolder *self, const CharBuf *name)
{
Obj *entry = Hash_Fetch(self->entries, (Obj*)name);
if (entry) {
if (Obj_Is_A(entry, RAMFILE)) {
;
}
else if (Obj_Is_A(entry, FOLDER)) {
RAMFolder *inner_folder;
if (Obj_Is_A(entry, COMPOUNDFILEREADER)) {
inner_folder = (RAMFolder*)CERTIFY(
CFReader_Get_Real_Folder((CompoundFileReader*)entry),
RAMFOLDER);
}
else {
inner_folder = (RAMFolder*)CERTIFY(entry, RAMFOLDER);
}
if (Hash_Get_Size(inner_folder->entries)) {
// Can't delete non-empty dir.
return false;
}
}
else {
return false;
}
DECREF(Hash_Delete(self->entries, (Obj*)name));
return true;
}
else {
return false;
}
}
示例12: Hash_equals
bool_t
Hash_equals(Hash *self, Obj *other) {
Hash *twin = (Hash*)other;
Obj *key;
Obj *val;
if (twin == self) {
return true;
}
if (!Obj_Is_A(other, HASH)) {
return false;
}
if (self->size != twin->size) {
return false;
}
Hash_Iterate(self);
while (Hash_Next(self, &key, &val)) {
Obj *other_val = Hash_Fetch(twin, key);
if (!other_val || !Obj_Equals(other_val, val)) {
return false;
}
}
return true;
}
示例13: CFReader_local_open_in
InStream*
CFReader_local_open_in(CompoundFileReader *self, const CharBuf *name) {
Hash *entry = (Hash*)Hash_Fetch(self->records, (Obj*)name);
if (!entry) {
InStream *instream = Folder_Local_Open_In(self->real_folder, name);
if (!instream) {
ERR_ADD_FRAME(Err_get_error());
}
return instream;
}
else {
Obj *len = Hash_Fetch_Str(entry, "length", 6);
Obj *offset = Hash_Fetch_Str(entry, "offset", 6);
if (!len || !offset) {
Err_set_error(Err_new(CB_newf("Malformed entry for '%o' in '%o'",
name, Folder_Get_Path(self->real_folder))));
return NULL;
}
else if (CB_Get_Size(self->path)) {
CharBuf *fullpath = CB_newf("%o/%o", self->path, name);
InStream *instream = InStream_Reopen(self->instream, fullpath,
Obj_To_I64(offset), Obj_To_I64(len));
DECREF(fullpath);
return instream;
}
else {
return InStream_Reopen(self->instream, name, Obj_To_I64(offset),
Obj_To_I64(len));
}
}
}
示例14: Schema_Fetch_Analyzer_IMP
Analyzer*
Schema_Fetch_Analyzer_IMP(Schema *self, String *field) {
SchemaIVARS *const ivars = Schema_IVARS(self);
return field
? (Analyzer*)Hash_Fetch(ivars->analyzers, field)
: NULL;
}
示例15: DefDelWriter_Seg_Deletions_IMP
Matcher*
DefDelWriter_Seg_Deletions_IMP(DefaultDeletionsWriter *self,
SegReader *seg_reader) {
DefaultDeletionsWriterIVARS *const ivars = DefDelWriter_IVARS(self);
Matcher *deletions = NULL;
Segment *segment = SegReader_Get_Segment(seg_reader);
String *seg_name = Seg_Get_Name(segment);
Integer32 *tick_obj = (Integer32*)Hash_Fetch(ivars->name_to_tick,
(Obj*)seg_name);
int32_t tick = tick_obj ? Int32_Get_Value(tick_obj) : 0;
SegReader *candidate = tick_obj
? (SegReader*)VA_Fetch(ivars->seg_readers, tick)
: NULL;
if (tick_obj) {
DeletionsReader *del_reader
= (DeletionsReader*)SegReader_Obtain(
candidate, Class_Get_Name(DELETIONSREADER));
if (ivars->updated[tick] || DelReader_Del_Count(del_reader)) {
BitVector *deldocs = (BitVector*)VA_Fetch(ivars->bit_vecs, tick);
deletions = (Matcher*)BitVecMatcher_new(deldocs);
}
}
else { // Sanity check.
THROW(ERR, "Couldn't find SegReader %o", seg_reader);
}
return deletions;
}