Exemplo n.º 1
0
void Dataset::insert() {
   edit_object->resize(field_count());
   for (int i=0; i<field_count(); i++) {
     (*fields_object)[i].val = "";
     (*edit_object)[i].val = "";
     (*edit_object)[i].props = (*fields_object)[i].props;
   }
  ds_state = dsInsert;
}
Exemplo n.º 2
0
 message_reader_impl( const gpb::Message *mess )
     :mess_(mess)
     ,reflection_(mess->GetReflection( ))
     ,descriptor_(mess->GetDescriptor( ))
 {
     name_seq_.reserve(field_count( ));
     for( int i=0, e=field_count( ); i<e; ++i ) {
         fields_map_.insert(std::make_pair(field(i)->name( ), field(i)));
         name_seq_.push_back( field(i)->name( ) );
     }
 }
Exemplo n.º 3
0
AddProjectForm::AddProjectForm(int rows, int cols,  Srv* srv, const char* projname, bool userexist) : NForm(rows,cols)
{
    this->srv = srv;
    settitle(projname);
    this->projname = projname;
    this->userexist = userexist;
    Item* project = NULL;
    if (srv !=NULL)
	project = srv->findprojectbynamefromall(projname);
    int row = 0;
    //поля
    try
    {
	genfields(row,project);
    }
    catch(const char* err)
    {
	kLogPrintf("ERROR EXCAPTION %s\n",err);
    }
    //пересчитываем высоту формы, чтобы влезли все поля и центрируем
    int r,c =0;
    scale_form(frm, &r, &c);
    kLogPrintf("field_count=%d scale_form()->%d,%d\n", field_count(frm), r, c);
    resize(r+3,c+2);
    post_form(frm);
    this->refresh();
}
Exemplo n.º 4
0
static void nexttopic( char *word )
{
    a_hstackent         *h;
    unsigned            len;

    if( word == NULL ) {
        len = 0;
    } else {
        len = strlen( word );
    }
    h = HelpMemAlloc( sizeof( a_hstackent ) + len );
    if( helpStack != NULL ) {
        helpStack->cur = field_count( helpTab, helpCur );
        helpStack->line = currLine;
    }
    h->next = helpStack;
    h->type = HSTCK_NAME;
    h->cur = 0;
    h->line = 0;
    strcpy( h->helpfname, curFile );
    if( word != NULL ) {
        strcpy( h->word, word );
    }
    h->word[len] = '\0';
    helpStack = h;
    free_fields( &helpTab );
}
Exemplo n.º 5
0
void viper_form_destroy(FORM *form,gboolean free_windows)
{
	WINDOW	*parent;
	WINDOW	*window;
	WINDOW	*subwin;
	FIELD		**fields;
	gint		count;

	unpost_form(form);
	
	window=form_win(form);
	subwin=form_sub(form);
	parent=window->_parent;
		
	count=field_count(form);
	fields=form_fields(form);
	free_form(form);
	
	while(count>0)
	{
		free_field(fields[count-1]);
		count--;
	}
	g_free(fields);

   if(free_windows==FALSE) return;
	
	/*	delete subwin if it is completely independent.	*/
	if(subwin!=parent && subwin!=window && subwin!=NULL) delwin(subwin);
		
	/*	delete window if it is not the parent window.	*/
	if(parent!=NULL && window!=parent && window!=NULL) delwin(window);
			
	return;
}
Exemplo n.º 6
0
void Dataset::insert() {
   for (int i=0; i<field_count(); i++) {
     (*fields_object)[i].val = "";
     (*edit_object)[i].val = "";
   }
  ds_state = dsInsert;
}
Exemplo n.º 7
0
const field_value Dataset::get_field_value(int index) {
    if (ds_state != dsInactive) {
        if (ds_state == dsEdit || ds_state == dsInsert) {
            if (index <0 || index >field_count())
                throw DbErrors("Field index not found: %d",index);

            return (*edit_object)[index].val;
        }
        else if (index <0 || index >field_count())
            throw DbErrors("Field index not found: %d",index);

        return (*fields_object)[index].val;
    }
    throw DbErrors("Dataset state is Inactive");
    //field_value fv;
    //return fv;
}
Exemplo n.º 8
0
int Dataset::fieldType(int n) {
  if ( n < field_count() && n >= 0){
    //cout << (*fields_object)[n].val.gft();
    return (*fields_object)[n].val.get_fType();
    //return (*fields_object)[n].props.type;
  }
  else
    return 0;
}
Exemplo n.º 9
0
double
histogram::sum()
    const
{
    double result = 0.0;
    for (size_type i = 0, n = field_count(); i < n; ++i)
      result += data_.value(i);
    return result;
}
Exemplo n.º 10
0
 void enum_all_fields(std::vector<const field_desc_type *> &result) const
 {
     std::vector<const field_desc_type *> flds;
     int count = field_count( );
     flds.reserve( count );
     for( int i=0; i<count; ++i ) {
         flds.push_back( field( i ) );
     }
     result.swap( flds );
 }
Exemplo n.º 11
0
void Dataset::edit() {
  if (ds_state != dsSelect) {
    throw DbErrors("Editing is possible only when query exists!");
  }
  edit_object->resize(field_count());
  for (unsigned int i=0; i<fields_object->size(); i++) {
       (*edit_object)[i].props = (*fields_object)[i].props;
       (*edit_object)[i].val = (*fields_object)[i].val; 
  }
  ds_state = dsEdit;
}
Exemplo n.º 12
0
static void del_field( a_field *table, a_field **field, bool changecurr )
{
    a_field             *next;
    int                 count;

    count = field_count( table, *field );
    if( *field == tabFilter.curr ) {
        tabFilter.curr = NULL;
    }
    if( changecurr && count < helpStack->cur ) {
        helpStack->cur -= 1;
    }
    next = (*field)->next;
    HelpMemFree( *field );
    *field = next;
    tabFilter.first = helpTab;
}
Exemplo n.º 13
0
AddAccMgrForm::AddAccMgrForm(int rows, int cols,  Srv* srv, const char* mgrname) : NForm(rows,cols)
{
    this->srv = srv;
    settitle(mgrname);
    this->mgrname = mgrname;
    Item* account_manager = NULL;
    if (srv !=NULL)
	account_manager = srv->findaccountmanager(mgrname);
    //поля
    int row = 0;
    genfields(row,account_manager);
    //пересчитываем высоту формы, чтобы влезли все поля и центрируем
    int r,c =0;
    scale_form(frm, &r, &c);
    kLogPrintf("field_count=%d scale_form()->%d,%d\n", field_count(frm), r, c);
    resize(r+3,c+2);

    set_current_field(frm, fields[0]); //фокус на поле

    post_form(frm);
    this->refresh();
}
Exemplo n.º 14
0
bool node::field_exists(const std::u32string& key) const throw(error)
{
	return (field_count(key) > 0);
}
Exemplo n.º 15
0
void Pb2Json::Message2Json(const ProtobufMsg& message, Json& json, bool enum2str) {
    auto descriptor = message.GetDescriptor();
    auto reflection = message.GetReflection();
    if (nullptr == descriptor || nullptr == descriptor) return;

    auto count = descriptor->field_count();

    for (auto i = 0; i < count; ++i) {
        const auto field = descriptor->field(i);

        if (field->is_repeated()) {
            if (reflection->FieldSize(message, field) > 0)
                RepeatedMessage2Json(message, field, reflection, json[field->name()], enum2str);

            continue;
        }

        if (!reflection->HasField(message, field)) {
            continue;
        }

        switch (field->type()) {
            case ProtobufFieldDescriptor::TYPE_MESSAGE: {
                const ProtobufMsg& tmp_message = reflection->GetMessage(message, field);
                if (0 != tmp_message.ByteSize()) Message2Json(tmp_message, json[field->name()]);
            } break;

            case ProtobufFieldDescriptor::TYPE_BOOL:
                json[field->name()] = reflection->GetBool(message, field) ? true : false;
                break;

            case ProtobufFieldDescriptor::TYPE_ENUM: {
                auto* enum_value_desc = reflection->GetEnum(message, field);
                if (enum2str) {
                    json[field->name()] = enum_value_desc->name();
                } else {
                    json[field->name()] = enum_value_desc->number();
                }
            } break;

            case ProtobufFieldDescriptor::TYPE_INT32:
            case ProtobufFieldDescriptor::TYPE_SINT32:
            case ProtobufFieldDescriptor::TYPE_SFIXED32:
                json[field->name()] = reflection->GetInt32(message, field);
                break;

            case ProtobufFieldDescriptor::TYPE_UINT32:
            case ProtobufFieldDescriptor::TYPE_FIXED32:
                json[field->name()] = reflection->GetUInt32(message, field);
                break;

            case ProtobufFieldDescriptor::TYPE_INT64:
            case ProtobufFieldDescriptor::TYPE_SINT64:
            case ProtobufFieldDescriptor::TYPE_SFIXED64:
                json[field->name()] = reflection->GetInt64(message, field);
                break;

            case ProtobufFieldDescriptor::TYPE_UINT64:
            case ProtobufFieldDescriptor::TYPE_FIXED64:
                json[field->name()] = reflection->GetUInt64(message, field);
                break;

            case ProtobufFieldDescriptor::TYPE_FLOAT:
                json[field->name()] = reflection->GetFloat(message, field);
                break;

            case ProtobufFieldDescriptor::TYPE_STRING:
            case ProtobufFieldDescriptor::TYPE_BYTES:
                json[field->name()] = reflection->GetString(message, field);
                break;

            default:
                break;
        }
    }
}
Exemplo n.º 16
0
bool Pb2Json::Json2Message(const Json& json, ProtobufMsg& message, bool str2enum) {
    auto descriptor = message.GetDescriptor();
    auto reflection = message.GetReflection();
    if (nullptr == descriptor || nullptr == reflection) return false;

    auto count = descriptor->field_count();
    for (auto i = 0; i < count; ++i) {
        const auto field = descriptor->field(i);
        if (nullptr == field) continue;

        auto& value = json[field->name()];
        if (value.is_null()) continue;

        if (field->is_repeated()) {
            if (!value.is_array()) {
                return false;
            } else {
                Json2RepeatedMessage(value, message, field, reflection, str2enum);
                continue;
            }
        }

        switch (field->type()) {
            case ProtobufFieldDescriptor::TYPE_BOOL: {
                if (value.is_boolean())
                    reflection->SetBool(&message, field, value.get<bool>());
                else if (value.is_number_integer())
                    reflection->SetBool(&message, field, value.get<uint32_t>() != 0);
                else if (value.is_string()) {
                    if (value.get<std::string>() == "true")
                        reflection->SetBool(&message, field, true);
                    else if (value.get<std::string>() == "false")
                        reflection->SetBool(&message, field, false);
                }
            } break;

            case ProtobufFieldDescriptor::TYPE_ENUM: {
                auto const* pedesc = field->enum_type();
                const ::google::protobuf::EnumValueDescriptor* pevdesc = nullptr;

                if (str2enum) {
                    pevdesc = pedesc->FindValueByName(value.get<std::string>());
                } else {
                    pevdesc = pedesc->FindValueByNumber(value.get<int>());
                }

                if (nullptr != pevdesc) {
                    reflection->SetEnum(&message, field, pevdesc);
                }
            } break;

            case ProtobufFieldDescriptor::TYPE_INT32:
            case ProtobufFieldDescriptor::TYPE_SINT32:
            case ProtobufFieldDescriptor::TYPE_SFIXED32: {
                if (value.is_number()) reflection->SetInt32(&message, field, value.get<int32_t>());
            } break;

            case ProtobufFieldDescriptor::TYPE_UINT32:
            case ProtobufFieldDescriptor::TYPE_FIXED32: {
                if (value.is_number()) reflection->SetUInt32(&message, field, value.get<uint32_t>());
            } break;

            case ProtobufFieldDescriptor::TYPE_INT64:
            case ProtobufFieldDescriptor::TYPE_SINT64:
            case ProtobufFieldDescriptor::TYPE_SFIXED64: {
                if (value.is_number()) reflection->SetInt64(&message, field, value.get<int64_t>());
            } break;
            case ProtobufFieldDescriptor::TYPE_UINT64:
            case ProtobufFieldDescriptor::TYPE_FIXED64: {
                if (value.is_number()) reflection->SetUInt64(&message, field, value.get<uint64_t>());
            } break;

            case ProtobufFieldDescriptor::TYPE_FLOAT: {
                if (value.is_number()) reflection->SetFloat(&message, field, value.get<float>());
            } break;

            case ProtobufFieldDescriptor::TYPE_DOUBLE: {
                if (value.is_number()) reflection->SetDouble(&message, field, value.get<double>());
            } break;

            case ProtobufFieldDescriptor::TYPE_STRING:
            case ProtobufFieldDescriptor::TYPE_BYTES: {
                if (value.is_string()) reflection->SetString(&message, field, value.get<std::string>());
            } break;

            case ProtobufFieldDescriptor::TYPE_MESSAGE: {
                if (value.is_object()) Json2Message(value, *reflection->MutableMessage(&message, field));
            } break;

            default:
                break;
        }
    }
    return true;
}
Exemplo n.º 17
0
const char *Dataset::fieldName(int n) {
  if ( n < field_count() && n >= 0)
    return (*fields_object)[n].props.name.c_str();
  else
    return NULL;
}
Exemplo n.º 18
0
int Dataset::fieldSize(int n) {
  if ( n < field_count() && n >= 0)
    return (*fields_object)[n].props.field_len;
  else
    return 0;
}
Exemplo n.º 19
0
static EVENT hlpwait( VTAB *tab )
{
    bool                done;
    static EVENT        bumpev = EV_NO_EVENT;
    char                *next_name;
    unsigned            len1;
    unsigned            len2;

    helpCur = field_find( helpTab, helpStack->cur );
    if( helpTab != NULL && helpCur == NULL ) {
        helpCur = helpTab;
    }
    tab->other = helpCur;
    tab->curr = helpCur;
    if( helpCur != NULL ) {
        tab->home = helpCur->area.col;
    }
    uipushlist( helpEventList );
    if( bumpev != EV_NO_EVENT ) {
        uitabfilter( bumpev, tab );
        helpCur = tab->curr;
        bumpev = EV_NO_EVENT;
    }
    done = false;
    while( !done ) {
        if( helpTab != NULL ) {
            uivattribute( &helpScreen, helpCur->area, AT( ATTR_CURR_EDIT ) );
        }
        do {
            uipushlist( keyShift );
            curEvent = uivget( &helpScreen );
            if( curEvent == EV_MOUSE_PRESS ) {
                ignoreMouseRelease = false;
            }
            uipoplist();
            curEvent = uigadgetfilter( curEvent, &vGadget );
            curEvent = uitabfilter( curEvent, tab );
        } while( curEvent == EV_NO_EVENT );
        if( eventMapFn != NULL ) {
            curEvent = (*eventMapFn)( curEvent );
        }
        curEvent = uihotspotfilter( &helpScreen, hotSpotFields, curEvent );
        if( helpTab != NULL ) {
            uivattribute( &helpScreen, helpCur->area, AT( ATTR_EDIT ) );
        }
        switch( curEvent ) {
        case EV_HELP:
            nexttopic( helpWord );
            done = true;
            break;
        case EV_BOTTOM:
        case E_UP:
        case EV_PAGE_UP:
        case EV_PAGE_DOWN:
        case EV_CURSOR_UP:
        case EV_CURSOR_DOWN:
        case EV_TOP:
        case E_DOWN:
        case EV_SCROLL_VERTICAL:
            if( curEvent == EV_BOTTOM ) {
                bumpev = EV_CURSOR_DOWN;
            } else if( curEvent == EV_TOP ) {
                bumpev = EV_CURSOR_UP;
            }
            helpStack->cur = field_count( helpTab, helpCur );
            done = true;
            break;
        case '-':
        case EV_MOUSE_RELEASE_R:
        case EV_ALT_B:
        case 'b':
        case 'B':
        case EV_F8:
        case EV_F4:
            prevtopic();
            if( strcmp( helpStack->helpfname, curFile ) ) {
                len1 = strlen( helpStack->word );
                len2 = strlen( helpStack->helpfname );
                helpCur = HelpMemAlloc( sizeof( a_field ) + len1 + len2 );
                memcpy( helpCur->keyword, helpStack->word, len1 );
                memcpy( helpCur->keyword + len1, helpStack->helpfname, len2 );
                helpCur->keyword[len1 + len2] = '\0';
                helpCur->key1_len = len1;
                helpCur->key2_len = len2;
                helpCur->next = NULL;
//              prevtopic();
                helpTab = helpCur;
            }
            done = true;
            break;
        case EV_ALT_S:
        case 'S':
        case 's':
            if( helpSearchHdl != NULL ) {
                uipoplist();
                next_name = HelpSearch( helpSearchHdl );
                if( next_name != NULL ) {
                    nexttopic( next_name );
                    HelpMemFree( next_name );
                    done = true;
                }
                uipushlist( helpEventList );
            }
            break;
        case EV_FIELD_CHANGE:
            helpCur = tab->curr;
            break;
        case EV_MOUSE_RELEASE:
            if( tab->other == NULL )
                break;
            if( ignoreMouseRelease ) {
                /* this mouse release is for a mouse press that occured
                 * before this help topic was opened */
                 ignoreMouseRelease = false;
                 break;
            }
            tab->other = tab->curr;
            /* fall through */
        case EV_ENTER:  /*same as page-down if there are other topics*/
        case EV_F7:
        case '+':
            // DEN 90/04/12 - next line necessary for mouse release kludge
            helpCur = tab->curr;
            if( helpTab != NULL ) {
                if( helpCur->key2_len == 0 ) {
                    nexttopic( helpCur->keyword );
                }
                done = true;
            }
            break;
        case EV_KILL_UI:
            uiforceevadd( EV_KILL_UI );
            /* fall through */
        case EV_ESCAPE:
            done = true;
            break;
        }
    }
    uipoplist();
    return( curEvent );
}
Exemplo n.º 20
0
histogram::histogram(const axes_type& axes) :
    basic_histogram(axes),
    data_(field_count())
{}
Exemplo n.º 21
0
static void
show_current_field(WINDOW *win, FORM * form)
{
    FIELD *field;
    FIELDTYPE *type;
    char *buffer;
    int nbuf;
    int field_rows, field_cols, field_max;
    int currow, curcol;

    if (has_colors()) {
	wbkgd(win, (chtype) COLOR_PAIR(1));
    }
    werase(win);
    form_getyx(form, currow, curcol);
    wprintw(win, "Cursor: %d,%d", currow, curcol);
    if (data_ahead(form))
	waddstr(win, " ahead");
    if (data_behind(form))
	waddstr(win, " behind");
    waddch(win, '\n');
    if ((field = current_field(form)) != 0) {
	wprintw(win, "Page %d%s, Field %d/%d%s:",
		form_page(form),
		new_page(field) ? "*" : "",
		field_index(field), field_count(form),
		field_arg(field) ? "(arg)" : "");
	if ((type = field_type(field)) != 0) {
	    if (type == TYPE_ALNUM)
		waddstr(win, "ALNUM");
	    else if (type == TYPE_ALPHA)
		waddstr(win, "ALPHA");
	    else if (type == TYPE_ENUM)
		waddstr(win, "ENUM");
	    else if (type == TYPE_INTEGER)
		waddstr(win, "INTEGER");
#ifdef NCURSES_VERSION
	    else if (type == TYPE_IPV4)
		waddstr(win, "IPV4");
#endif
	    else if (type == TYPE_NUMERIC)
		waddstr(win, "NUMERIC");
	    else if (type == TYPE_REGEXP)
		waddstr(win, "REGEXP");
	    else
		waddstr(win, "other");
	}

	if ((unsigned) field_opts(field) & O_EDIT)
	    waddstr(win, " editable");
	else
	    waddstr(win, " readonly");

	if (field_status(field))
	    waddstr(win, " modified");

	if (dynamic_field_info(field, &field_rows, &field_cols, &field_max)
	    != ERR) {
	    wprintw(win, " size %dx%d (max %d)",
		    field_rows, field_cols, field_max);
	}

	waddch(win, ' ');
	(void) wattrset(win, (int) field_fore(field));
	waddstr(win, "fore");
	wattroff(win, (int) field_fore(field));

	waddch(win, '/');

	(void) wattrset(win, (int) field_back(field));
	waddstr(win, "back");
	wattroff(win, (int) field_back(field));

	wprintw(win, ", pad '%c'",
		field_pad(field));

	waddstr(win, "\n");
	for (nbuf = 0; nbuf <= 2; ++nbuf) {
	    if ((buffer = field_buffer(field, nbuf)) != 0) {
		wprintw(win, "buffer %d:", nbuf);
		(void) wattrset(win, A_REVERSE);
		waddstr(win, buffer);
		wattroff(win, A_REVERSE);
		waddstr(win, "\n");
	    }
	}
    }
    wrefresh(win);
}
Exemplo n.º 22
0
 const field_desc_type *get_field( int index ) const
 {
     if( index >= field_count( ) || index < 0 )
         throw std::runtime_error( "Bad field index" );
     return field( index );
 }
Exemplo n.º 23
0
RddResultCode TopNAction::action(ActionContext* ctx, const BaseRddPartition* input) {
  TopNActionRequest request;
  if (!ctx->getActionParam(ACTION_PARAM, &request)) {
    LOG(ERROR)<< input->getPartitionName() << " parse top N expression error";
    return RRC_INVALID_ACTION_PARAM;
  }

  int32_t fieldSize = request.order_field_size();
  vector<FieldInfo> fields;
  vector<bool> fieldDesc;
  fields.resize(fieldSize);
  fieldDesc.resize(fieldSize);
  string typeName = input->getRddName();
  for (int32_t i = 0; i < fieldSize; ++ i) {
    auto& field = request.order_field(i);
    auto rc = ExpressionFactory::build(&fields[i].expr, field.expr(), ctx->getKeyTemplate(), ctx->getValueTemplate());
    if (idgs::RC_SUCCESS != rc) {
      LOG(ERROR)<< input->getPartitionName() << " parsed filter expression error, caused by " << idgs::getErrorDescription(rc);
      return RRC_NOT_SUPPORT;
    }

    if (field.has_field_name()) {
      fields[i].name = field.field_name();
    } else if (field.expr().name() == "FIELD") {
      fields[i].name = field.expr().value();
    } else {
      fields[i].name = "column" + to_string(i);
    }

    if (field.has_field_type()) {
      fields[i].type = field.field_type();
    } else if (field.expr().name() == "FIELD") {
      FieldExtractor* fieldExt = dynamic_cast<FieldExtractor*>(fields[i].expr);
      auto fldType = fieldExt->getFieldType();
      fields[i].type = static_cast<idgs::pb::DataType>(fldType);
    } else {
      fields[i].type = idgs::pb::STRING;
    }

    fieldDesc[i] = field.desc();
    typeName.append("_").append(fields[i].name);
  }

  string fullTypeName = "idgs.rdd.pb." + typeName;

  auto helper = idgs_rdd_module()->getMessageHelper();
  if (!helper->isMessageRegistered(fullTypeName)) {
    std::lock_guard<std::mutex> lockGuard(lock);
    if (!helper->isMessageRegistered(fullTypeName)) {
      registerTempKeyMessage(input->getPartition(), typeName, fields);
    }
  }

  if (input->empty()) {
    return RRC_SUCCESS;
  }

  PbMessagePtr tmpKeyTemp = helper->createMessage(fullTypeName);
  if (!tmpKeyTemp) {
    LOG(ERROR)<< "RDD \"" << input->getRddName() << "\" partition[" << input->getPartition() << "] generate dynamic key error.";
    return RRC_INVALID_KEY;
  }

  orderless compare(fieldDesc);
  multimap<PbMessagePtr, KeyValueMessagePair, orderless> tmpMap(compare);
  auto tmpDescriptor = tmpKeyTemp->GetDescriptor();

  uint64_t start = 1, dataSize = 0;
  bool hasTop = request.has_top_n();
  if (request.has_start()) {
    start = request.start();
  }

  if (request.has_top_n()) {
    auto topN = request.top_n();
    dataSize = topN + start - 1;
  }

  input->foreach(
    [&ctx, &tmpMap, fields, tmpKeyTemp, tmpDescriptor, dataSize, hasTop, helper]
     (const PbMessagePtr& key, const PbMessagePtr& value) {
      ctx->setKeyValue(&key, &value);
      if (!ctx->evaluateFilterExpr()) {
        return;
      }

      PbMessagePtr tmpKey(tmpKeyTemp->New());
      for (int32_t i = 0; i < tmpDescriptor->field_count(); ++ i) {
        auto field = tmpDescriptor->field(i);
        PbVariant var = fields[i].expr->evaluate(ctx->getExpressionContext());
        helper->setMessageValue(tmpKey.get(), field, var);
      }

      KeyValueMessagePair pair;
      pair.key = &key;
      pair.value = &value;

      tmpMap.insert(std::pair<PbMessagePtr, KeyValueMessagePair>(tmpKey, pair));

      if (hasTop && tmpMap.size() > dataSize) {
        auto itTmp = tmpMap.end();
        -- itTmp;
        tmpMap.erase(itTmp);
      }
    });

  if (!tmpMap.empty()) {
    TopNActionData data;
    data.set_key_name(fullTypeName);

    auto serdesMode = ctx->getSerdesMode();
    auto itfst = tmpMap.begin();
    auto itlst = tmpMap.end();
    for (; itfst != itlst; ++ itfst) {
      auto pair = data.add_data();
      ProtoSerdesHelper::serialize(serdesMode, itfst->first.get(), pair->mutable_key());
      ProtoSerdesHelper::serialize(serdesMode, itfst->second.key->get(), pair->mutable_pair()->mutable_key());
      ProtoSerdesHelper::serialize(serdesMode, itfst->second.value->get(), pair->mutable_pair()->mutable_value());
    }

    string var;
    ProtoSerdesHelper::serialize(serdesMode, &data, &var);
    ctx->addPartitionResult(var);
  }
  return RRC_SUCCESS;
}