Exemplo n.º 1
0
void BTree<T>::split(int p_id, int n_id) {
  BNode<T>& n = get_node(n_id);
  BNode<T>& t = manager.new_node();
  int pos = n.ascendpos();
  T& newkey = n.keys[pos];
  t.leaf = n.leaf;
  t.sibling = n.sibling;
  t.numkeys = n.numkeys - pos - 1;
  memcpy(t.keys, &(n.keys[pos+1]), sizeof(T)*(t.numkeys));
  if (!n.leaf) {
    n.numkeys = pos;  // key ascended
    memcpy(t.next, &(n.next[pos+1]), sizeof(int)*(t.numkeys+1));
  } else {
    n.numkeys = pos + 1;  // key copied
    n.sibling = t.id; 
    memcpy(t.next, &(n.next[pos+1]), sizeof(int)*(t.numkeys));
  }
  if (p_id == -1) {  // root splits
    BNode<T>& pp = manager.new_root();
    pp.leaf = 0;
    pp.sibling = -1;
    p_id = pp.id;
    return_node(pp.id);
  }
  BNode<T>& p = get_node(p_id);
  int newpos = p.findkey(newkey);
  p.addkey(newkey, newpos);
  p.addnext(n.id, t.id, newpos);
  p.numkeys++;
  update_node(n.id); return_node(n.id);
  update_node(t.id); return_node(t.id);
  update_node(p.id); return_node(p.id);
  return;
}
Exemplo n.º 2
0
bool insert_node(Node **u, int dep, int pos, Char x) {
	if (*u == NULL) {
		*u = new_node(), (*u)->x = x, update_node(*u);
		return dep <= 0;
	}
	int t = 0, lsz = (*u)->lson ? (*u)->lson->wsz : 0, wsz = (*u)->x.cnt;
	if (pos <= lsz+1) {
		t = insert_node(&((*u)->lson), dep-1, pos, x);
	} else if (pos > lsz + wsz) {
		t = insert_node(&((*u)->rson), dep-1, pos-lsz-wsz, x);
	} else {
		int remain = pos-lsz-1;
		insert_node(&((*u)->rson), dep-1, 0, clone_char((*u)->x.c, (*u)->x.cnt-remain));
		insert_node(&((*u)->rson), dep-1, 0, x);
		(*u)->x.cnt = remain;
	}
	update_node(*u);
	if (t && !isbad(*u))
		return 1;
	if (t) {
		flatsz = 0;
		flatten(*u);
		*u = build(0, flatsz-1);
	}
	return 0;
}
Exemplo n.º 3
0
Arquivo: main.c Projeto: r0fls/skvs
int main(){
    FILE *fp,*fp2;
    fp = fopen("test.db","r");
    node *j = NULL;
    j = deSerialize(fp);
    close(fp);
    update_node(j,"key13","newavalue2");
    update_node(j,"key14","newavalue2");
    update_node(j,"key15","newavalue2");
    update_node(j,"key16","newavalue2");
    update_node(j,"key17","newavalue2");
    fp2 = fopen("test2.db","w");
    serialize(fp2,j);
    close(fp2);
}
Exemplo n.º 4
0
void BTree<T>::insert(int p_id, int n_id, T& key, void *data, int length) {
  BNode<T> &n = get_node(n_id);
  int pos = n.findkey(key), sz = n.numkeys;
  if (pos < sz && key == n.keys[pos]) { // duplicated
    return_node(n_id);
    return;
  }
  if (n.leaf && n.addkey(key, pos) >= 0) {
    n.adddata(manager.new_data(data,length), pos);
    n.numkeys++;
    update_node(n_id);
    return_node(n_id);
  } else {
    int m_id = n.next[pos];
    return_node(n_id);
    insert(n_id, m_id, key, data, length);
  }
  BNode<T> &nn = get_node(n_id);
  if (nn.numkeys >= CHUNK_SIZE) {
    return_node(n_id);
    split(p_id, n_id);
  } else {
    return_node(n_id);
  }
}
Exemplo n.º 5
0
rpl_node *dag_network::update_child(network_interface *iface,
				    struct in6_addr from,
                                    struct in6_addr ip6_to,
                                    const time_t now)
{
    /* no difference for parent or child for now */
    return update_node(iface, from, ip6_to, now);
}
Exemplo n.º 6
0
// add node button
void MainWindow::on_pushButton_2_released()
{
    wierzcholek wK, tmpW;
    krawedz krawedz_w;
    QString text = ui->lineEdit->text();



    if ( text.length() > 0) {
        //sprawdzanie obecnego wierzcholka
        get_node(text, wK);
        if(wK.nazwa.length() != 0){
            krawedz_w.pojemnosc = ui->spinBox->value();
            krawedz_w.przeplyw = 0;
            krawedz_w.zbadano = 0;
            krawedz_w.cel = text;
            update_node(ui->comboBox->currentText(), krawedz_w);
            return;
        } else {

            //dodanie wierzcholka do listy
            ui->comboBox->addItem(text);

            wK.nazwa = text;
            krawedz_w.pojemnosc = ui->spinBox->value();
            krawedz_w.przeplyw = 0;
            krawedz_w.zbadano = 0;
            krawedz_w.cel = text;

            //jesli poprzednikiem jest zrodlo
            if( ui->comboBox->count() == 1 ) {
                wK.x = 0;
                wK.y = 0;
            } else {
                get_node(ui->comboBox->currentText(), tmpW);
                wK.x = tmpW.x;
                wK.y = tmpW.y;
                check_node_position(wK, tmpW.krawedzie.size(), 1);
            }
            update_node(ui->comboBox->currentText(), krawedz_w);
            wierzcholki.push_back(wK);
        }
    }
}
Exemplo n.º 7
0
THashNode* CHashMap::replace_node(void * key, void* new_data, int new_len, char* old_data, int* old_len)
{
	THashNode* node = find_node(key);
	if(node != NULL)
	{
		return update_node(node, new_data, new_len, old_data, old_len);
	}

	return insert_node(key, new_data, new_len);
}
Exemplo n.º 8
0
    // move to a new position
    Position & 
    vast_dc::setpos (Position &pt)
    {                
        // do not move if we havn't joined (no neighbors are known unless I'm gateway)
        if (is_joined () == true)
        {
            // do necessary adjustments
            adjust_aoi ();
            remove_nonoverlapped ();
            
            // check for position overlap with neighbors and make correction
            map<VAST::id_t, Node>::iterator it; 
            for (it = _id2node.begin(); it != _id2node.end(); ++it)
            {
                if (it->first == _self.id)
                    continue;
                if (it->second.pos == pt)
                {
                    pt.x++;
                    it = _id2node.begin();
                }
            }            

            // update location information
            //double dis = _self.pos.dist (pt);
            _self.pos = pt;
            _self.time = _net->get_curr_timestamp ();//_time;
            update_node (_self);
            
#ifdef DEBUG_DETAIL
            printf ("[%lu] setpos (%d, %d)\n", _self.id, (int)_self.pos.x, (int)_self.pos.y);
#endif            
            // notify all connected neighbors
            msgtype_t msgtype;            
            VAST::id_t target_id;
            
            // go over each neighbor and do a boundary neighbor check
            int n = 0;
            for (it = _id2node.begin(); it != _id2node.end(); ++it)
            {
                if ((target_id = it->first) == _self.id)
                    continue;
                
                if (_voronoi->is_boundary (target_id, _self.pos, _self.aoi) == true)
                    msgtype = DC_MOVE_B;
                else
                    msgtype = DC_MOVE;
                
                _net->sendmsg (target_id, (msgtype_t)msgtype, (char *)&_self, sizeof (Node), false);
                n++;
            }
        }
        
        return _self.pos;
    }    
Exemplo n.º 9
0
Node* build(int l, int r) {
	if (l > r)	return NULL;
	int mid = (l + r)>>1;
	Node *ret = trash[mid];
	init_node(ret);
	ret->x = flatbuf[mid];
    ret->lson = build(l, mid-1);
    ret->rson = build(mid+1, r);
	update_node(ret);
	return ret;
}
Exemplo n.º 10
0
void UpdateTuple(storage::DataTable *table) {
  auto &txn_manager = concurrency::OptimisticTxnManager::GetInstance();
  auto txn = txn_manager.BeginTransaction();
  std::unique_ptr<executor::ExecutorContext> context(
      new executor::ExecutorContext(txn));

  // Update
  std::vector<oid_t> update_column_ids = {2};
  std::vector<Value> values;
  Value update_val = ValueFactory::GetDoubleValue(23.5);

  planner::ProjectInfo::TargetList target_list;
  planner::ProjectInfo::DirectMapList direct_map_list;
  target_list.emplace_back(
      2, expression::ExpressionUtil::ConstantValueFactory(update_val));
  LOG_INFO("%lu", target_list.at(0).first);
  direct_map_list.emplace_back(0, std::pair<oid_t, oid_t>(0, 0));
  direct_map_list.emplace_back(1, std::pair<oid_t, oid_t>(0, 1));
  direct_map_list.emplace_back(3, std::pair<oid_t, oid_t>(0, 3));

  planner::UpdatePlan update_node(
      table, new planner::ProjectInfo(std::move(target_list),
                                      std::move(direct_map_list)));

  executor::UpdateExecutor update_executor(&update_node, context.get());

  // Predicate

  // WHERE ATTR_0 < 70
  expression::TupleValueExpression *tup_val_exp =
      new expression::TupleValueExpression(0, 0);
  expression::ConstantValueExpression *const_val_exp =
      new expression::ConstantValueExpression(
          ValueFactory::GetIntegerValue(70));
  auto predicate = new expression::ComparisonExpression<expression::CmpLt>(
      EXPRESSION_TYPE_COMPARE_LESSTHAN, tup_val_exp, const_val_exp);

  // Seq scan
  std::vector<oid_t> column_ids = {0};
  planner::SeqScanPlan seq_scan_node(table, predicate, column_ids);
  executor::SeqScanExecutor seq_scan_executor(&seq_scan_node, context.get());

  // Parent-Child relationship
  update_node.AddChild(&seq_scan_node);
  update_executor.AddChild(&seq_scan_executor);

  EXPECT_TRUE(update_executor.Init());
  while (update_executor.Execute())
    ;

  txn_manager.CommitTransaction();
}
Exemplo n.º 11
0
void BManager<T>::optimize_data() {
  string data_path = prefix+".data";
  string tmp_path  = prefix+".data.tmp";
  FILE *tmp_file = fopen(tmp_path.c_str(), "w");
  if (!tmp_file || !data_file || !node_file) {
    cerr << "WARNING::BManager::no file to optimize" << endl;
    return;
  }
  char *buf = new char[1024];
  int buf_len = 1024;
  int cur_node;
  vector<pair<long long, int> > backup;

  backup.swap(data_zone);

  cur_node = first_leaf_id;
  while (cur_node != -1) {
    BNode<T> &n = get_node(cur_node);
    for (int i = 0; i < n.numkeys; ++i) {
      if (n.next[i] < 0)
        continue;
      int dataid = n.next[i];
      int newlen = backup[dataid].second;
      long long oldfp = backup[dataid].first;
      long long newfp = ftell(tmp_file);
      fseek(data_file, oldfp, SEEK_SET);
      if (buf_len < newlen) {
        delete []buf;
        buf = new char[newlen];
        buf_len = newlen;
      }
      int r = fread(buf, newlen, 1, data_file);
      assert(r > 0);
      fwrite(buf, 1, newlen, tmp_file);
      n.next[i] = data_zone.size();
      data_zone.push_back(make_pair(newfp, newlen));
    }
    cur_node = n.sibling;
    update_node(n.id);
    return_node(n.id);
  }
  optimized = 1;
  cerr << "[0]" << endl;
  fclose(tmp_file);
  cerr << "[1]" << endl;
  fclose(data_file);
  cerr << "[2]" << endl;
  remove(data_path.c_str());
  rename(tmp_path.c_str(), data_path.c_str());
  data_file = fopen(data_path.c_str(), "rb+");
  delete []buf;
}
bool TransactionTestsUtil::ExecuteUpdateByValue(concurrency::Transaction *txn,
                                                storage::DataTable *table,
                                                int old_value,
                                                int new_value) {
  std::unique_ptr<executor::ExecutorContext> context(
      new executor::ExecutorContext(txn));

  Value update_val = ValueFactory::GetIntegerValue(new_value);

  // ProjectInfo
  planner::ProjectInfo::TargetList target_list;
  planner::ProjectInfo::DirectMapList direct_map_list;
  target_list.emplace_back(
      1, expression::ExpressionUtil::ConstantValueFactory(update_val));
  direct_map_list.emplace_back(0, std::pair<oid_t, oid_t>(0, 0));

  // Update plan
  std::unique_ptr<const planner::ProjectInfo> project_info(
      new planner::ProjectInfo(std::move(target_list),
                               std::move(direct_map_list)));
  planner::UpdatePlan update_node(table, std::move(project_info));

  executor::UpdateExecutor update_executor(&update_node, context.get());

  // Predicate
  auto tup_val_exp = new expression::TupleValueExpression(0, 1);
  auto const_val_exp = new expression::ConstantValueExpression(
      ValueFactory::GetIntegerValue(old_value));
  auto predicate = new expression::ComparisonExpression<expression::CmpEq>(
      EXPRESSION_TYPE_COMPARE_EQUAL, tup_val_exp, const_val_exp);

  // Seq scan
  std::vector<oid_t> column_ids = {0, 1};
  std::unique_ptr<planner::SeqScanPlan> seq_scan_node(
      new planner::SeqScanPlan(table, predicate, column_ids));
  executor::SeqScanExecutor seq_scan_executor(seq_scan_node.get(),
                                              context.get());

  update_node.AddChild(std::move(seq_scan_node));
  update_executor.AddChild(&seq_scan_executor);

  EXPECT_TRUE(update_executor.Init());
  return update_executor.Execute();
}
Exemplo n.º 13
0
static void
do_update_node (NemoFile *file,
                  FMTreeModel *model)
{
	TreeNode *root, *node = NULL;

	for (root = model->details->root_node; root != NULL; root = root->next) {
		node = get_node_from_file (root->root, file);

		if (node != NULL) {
			break;
		}
	}

	if (node == NULL) {
		return;
	}

	update_node (model, node);
}
Exemplo n.º 14
0
/*
 * cache_to_client
 * read from cache and send to client
 */
int cache_to_client(int clientfd, cache *list, cache_node *node) {
    printf(" cache to client\n");
    if (list == NULL) {
        return -1;
    }
    if (node == NULL) {
        return -1;
    }
    pthread_rwlock_rdlock(&rdlock);
    if (rio_writen(clientfd, node->content,node->size)<0) {
        return -1;
    }
    pthread_rwlock_unlock(&rdlock);

    //lru
    pthread_rwlock_wrlock(&wrlock);
    update_node(list,node->uri);
    pthread_rwlock_unlock(&wrlock);

    return 0;
}
Exemplo n.º 15
0
static void
reinit_nodes ()
{
  pwr_tStatus sts;
  LstLink(sNode) *nl;
  sNode *np;
  pwr_tObjid oid;

  /* Mark all links in the NodeLink list */
  for (nl= LstFir(&node_l); nl != LstEnd(&node_l); nl = LstNex(nl))
    LstObj(nl)->found = FALSE;

  for (
    sts = gdh_GetClassList(pwr_cClass_NodeLinkSup, &oid);
    ODD(sts);
    sts = gdh_GetNextObject(oid, &oid)
  ) {
    if ((np = get_nodes(oid)) == NULL) {
      np = init_node(oid, NULL, 1);
      if (np != NULL) {
	nl = LstIns(nl, np, node_l);
	np->found = TRUE;
      }
    } else {
      update_node(np);
    }
  }

  for (nl = LstFir(&node_l); nl != LstEnd(&node_l); nl = LstNex(nl)) {
    np = LstObj(nl);
    if (!np->found) {
      nl = LstPre(&np->node_l);
      LstRem(&np->node_l);
      LstNul(&np->node_l);
      gdh_SubUnrefObjectInfo (np->o->SubId);
      gdh_DLUnrefObjectInfo(np->dlid);
      free(np);
    }
  }	    
}
bool TransactionTestsUtil::ExecuteUpdate(concurrency::Transaction *transaction,
                                         storage::DataTable *table, int id,
                                         int value) {
  std::unique_ptr<executor::ExecutorContext> context(
      new executor::ExecutorContext(transaction));

  Value update_val = ValueFactory::GetIntegerValue(value);

  // ProjectInfo
  planner::ProjectInfo::TargetList target_list;
  planner::ProjectInfo::DirectMapList direct_map_list;
  target_list.emplace_back(
      1, expression::ExpressionUtil::ConstantValueFactory(update_val));
  direct_map_list.emplace_back(0, std::pair<oid_t, oid_t>(0, 0));

  // Update plan
  std::unique_ptr<const planner::ProjectInfo> project_info(
      new planner::ProjectInfo(std::move(target_list),
                               std::move(direct_map_list)));
  planner::UpdatePlan update_node(table, std::move(project_info));

  executor::UpdateExecutor update_executor(&update_node, context.get());

  // Predicate
  auto predicate = MakePredicate(id);

  // Seq scan
  std::vector<oid_t> column_ids = {0};
  std::unique_ptr<planner::SeqScanPlan> seq_scan_node(
      new planner::SeqScanPlan(table, predicate, column_ids));
  executor::SeqScanExecutor seq_scan_executor(seq_scan_node.get(),
                                              context.get());

  update_node.AddChild(std::move(seq_scan_node));
  update_executor.AddChild(&seq_scan_executor);

  EXPECT_TRUE(update_executor.Init());
  return update_executor.Execute();
}
Exemplo n.º 17
0
void MainWindow::add_outlet(wierzcholek &tmp)
{
    // wspolrzednie x, y ujscia
    // count jest uzywane do obliczenia sredniej odleglosci miedzy punktami w pionie
    std::list<wierzcholek> tt;
    wierzcholek nastepnik;
    krawedz krawedz_w;
    int valueY = 0, valueX = 0, count = 0;

    find_node_without_child(tt);

    for (std::list<wierzcholek>::iterator itr = tt.begin(); itr != tt.end(); itr++){
        if( itr->x > valueX ) {
            valueX = itr->x;
        }
        valueY += itr->y;
        count++;
    }

    valueY = valueY / count;

    if(valueX == 0) {
        valueX = 50;
    }
    tmp.nazwa = "ujscie";
    tmp.x = valueX + valueX;
    tmp.y = valueY;  
    wierzcholki.push_back(tmp);

    krawedz_w.cel = tmp.nazwa;
    krawedz_w.pojemnosc = INT_MAX;
    krawedz_w.przeplyw = -1;
    krawedz_w.zbadano = 2;

    for (std::list<wierzcholek>::iterator itr2 = tt.begin(); itr2 != tt.end(); itr2++){
        update_node(itr2->nazwa, krawedz_w);
    }
}
Exemplo n.º 18
0
void delete_tree(tree** t, const void* key,
                 int (*compare_keys)(const void* key1, const void* key2)) {
    /* key with key to delete */
    tree** d = del_search(t, key, compare_keys);
    if(d == NULL) /*not found*/
        return;

    tree* p = NULL; /*key to be physically deleted */

    if((*d)->parent == NULL)  /*d is the root */
        p = delete_root(d); /*fiiled if root has at least 1 child*/

    else {  /* not root */
        if(((*d)->left == NULL) || ((*d)->right == NULL))  /*0 or 1 children*/
            repoint_child(d);
        else  /*2 children*/
            p = (tree*)successor_descendant(*d);
    }

    /*move child up to replace parent and delete child*/
    if(p != NULL)
        update_node(d, p, compare_keys);
}
Exemplo n.º 19
0
static void
process_file_change (FMTreeModelRoot *root,
		     NemoFile *file)
{
	TreeNode *node, *parent;

	node = get_node_from_file (root, file);
	if (node != NULL) {
		update_node (root->model, node);
		return;
	}

	if (!should_show_file (root->model, file)) {
		return;
	}

	parent = get_parent_node_from_file (root, file);
	if (parent == NULL) {
		return;
	}

	insert_node (root->model, parent, create_node_for_file (root, file));
}
Exemplo n.º 20
0
void Dag::construct_dag(InsCtrl*& ins)
{
	InsCtrl* new_ins=new InsCtrl(ins->sstab);	//get the stack symbol table
	last_oper=0;
	std::vector<FBlock*> ins_fblk=ins->get_all_func_block();
	for(int i=0;i<ins_fblk.size();i++)
	{
		FBlock* fblk=ins_fblk[i];
		for(int j=0;j<fblk->all_blocks.size();j++)
		{
			BBlock* bblk=fblk->all_blocks[j];
			if(!bblk->has_array())	//we currently do not consider arraies, migh
			{
				for(int k=0;k<bblk->all_ins.size();k++)
				{
					Quadcode* q=bblk->all_ins[k];
				
					Quadcode* code=NULL;
					Quadcode::Quad_type oper=q->get_quad_type();
 					symbol* src_arg1=NULL;
 					symbol* src_arg2=NULL;
 					symbol* obj_arg=NULL;
					unsigned int index1;
					unsigned int index2;
					unsigned int index3;
					switch(oper)
					{
					case  Quadcode::ASSIGN:
						src_arg1=q->get_src_arg()[0];
						obj_arg=q->get_obj_arg();
						if(!find_sym(src_arg1,symbol_nodeNum,index1))	//cannot find the src node in the dag tree
						{
							index1=dag_nodes.size();
							dag_nodes.push_back(new DNode(src_arg1));	//src first leave node
							update_node(src_arg1,index1);	//update the src symbol index
						}
						update_node(obj_arg,index1);	//update the obj arg, and the index num is the tree node index obj was assigned to
						assignment[last_oper].push_back(std::pair<symbol*, unsigned int>(obj_arg,index1));	//assign information, the index begin with 0
						break;
					case Quadcode::ADD:
					case Quadcode::SUB:
					case Quadcode::MUL:
					case Quadcode::DIV:
						src_arg1=q->get_src_arg()[0];
						src_arg2=q->get_src_arg()[1];
						obj_arg=q->get_obj_arg();
						if(!find_sym(src_arg1,symbol_nodeNum,index1))	//cannot find the src node in dag tree
						{
							index1=dag_nodes.size();
							dag_nodes.push_back(new DNode(src_arg1));
							update_node(src_arg1,index1);
						}
						if(!find_sym(src_arg2,symbol_nodeNum,index2))
						{
							index2=dag_nodes.size();
							dag_nodes.push_back(new DNode(src_arg2));
							update_node(src_arg2,index2);
						}
						if(!find_operator(oper,operators,dag_nodes,index1,index2,index3))
						{
							index3=dag_nodes.size();
							dag_nodes.push_back(new DNode(oper,index1,index2));
							operators[oper].insert(index3);
							last_oper=dag_nodes.size();
						}
						update_node(obj_arg,index3);
						assignment[last_oper].push_back(std::pair<symbol*,unsigned int>(obj_arg,index3));
						break;
					case Quadcode::INV:
						src_arg1=q->get_src_arg()[0];
						obj_arg=q->get_obj_arg();
						if(!find_sym(src_arg1,symbol_nodeNum,index1))
						{
							index1=dag_nodes.size();
							dag_nodes.push_back(new DNode(src_arg1));
							update_node(src_arg1,index1);
						}
						if(!find_operator(oper,operators,dag_nodes,index1,index2))
						{
							index2=dag_nodes.size();
							dag_nodes.push_back(new DNode(oper,index1));
							operators[oper].insert(index2);
							last_oper=dag_nodes.size();
						}
						update_node(obj_arg,index2);
						assignment[last_oper].push_back(std::pair<symbol*,unsigned int>(obj_arg,index2));
						break;
					case Quadcode::CALL:
					case Quadcode::SIND:
						output_quadcode(*new_ins);
						src_arg1=q->get_src_arg()[0];
						obj_arg=q->get_obj_arg();
						if(obj_arg==NULL)
							code=Quadcode::new_Quad_code(oper,src_arg1);
						else code=Quadcode::new_Quad_code(oper,obj_arg,src_arg1);
						new_ins->new_instruction(code);
						break;

					case Quadcode::JMP:
					case Quadcode::LABEL:
//					case Quadcode::READ:
					case Quadcode::WRITE:
					case Quadcode::PUSH:
					case Quadcode::SREF:
						output_quadcode(*new_ins);
						src_arg1=q->get_src_arg()[0];
						code=Quadcode::new_Quad_code(oper,src_arg1);
						new_ins->new_instruction(code);
						break;
					case Quadcode::FUNC:
					case Quadcode::MAIN:
					case Quadcode::ENDF:
					case Quadcode::ENDM:
					case Quadcode::PARAM:
					case Quadcode::READ:
						output_quadcode(*new_ins);
						obj_arg=q->get_obj_arg();
						code=Quadcode::new_Quad_code(oper,obj_arg);
						new_ins->new_instruction(code);
						break;
					case Quadcode::JEQ:
					case Quadcode::JGE:
					case Quadcode::JGT:
					case Quadcode::JLE:
					case Quadcode::JLT:
					case Quadcode::JNE:
						output_quadcode(*new_ins);
						src_arg1=q->get_src_arg()[0];
						src_arg2=q->get_src_arg()[1];
						obj_arg=q->get_src_arg()[2];
						code=Quadcode::new_Quad_code(oper,obj_arg,src_arg1,src_arg2);
						new_ins->new_instruction(code);
						break;
					case Quadcode::LINE:
						output_quadcode(*new_ins);
						code=Quadcode::new_Quad_code(oper);
						new_ins->new_instruction(code);
						break;
					default:
						assert(0);
					}
				
//					std::cout<<"y  "<<*q;
					q->disable();
					}
					output_quadcode(*new_ins);
				}
				else
				{
					for(int m=0;m<bblk->all_ins.size();m++)
					{//	std::cout<<"s  "<<*bblk->all_ins[m];
						new_ins->new_instruction(bblk->all_ins[m]);
					}
					output_quadcode(*new_ins);
				}				
			}
			output_quadcode(*new_ins);
	}

	delete ins;
	new_ins->reorder_all_ins();
	std::ofstream file("block_dag.txt",std::ios::out);
	std::vector<FBlock*> blo=new_ins->get_all_func_block();
	for(int i1=0;i1<blo.size();i1++)
	{
		file<<*blo[i1];
	}
	ins=new_ins;
}
Exemplo n.º 21
0
int main(void) 
{
	int i;
	DARR *sturoot;

   if ((sturoot = load_darr("db.db")) == NULL){
      printf("load db error.\n");
      if ((sturoot = create_darr(sizeof(struct stu))) == NULL) {
         printf("create date error.\n");
         return -1; 
      }   
   }   

	/* 
	** 0,q for exit; 1,f for find; 2, i for insert; 3,d for delete, 4, l for list, 5, e for erase;
	** 6, a for delete duplication; 7, u for update, 8, s for sort, 9 for Save data, @ for Load data;
	*/
	while ((i = read_select()) != '0' && i != 'q' && i != 'Q')			/* 主循环,获取控制输入*/
		switch (i){
		case '1': case 'F': case 'f':
				printf("Please enter the search condition: [ID],[Name],[Scope]\n");
				{
					struct stu tmp, *ret;
					if (getline(&tmp) == 0) {
						printf("Input Format wrong!\n");
					} else if ((ret =(struct stu *)find_node(sturoot,&tmp,cmp)) == NULL)
						printf("Record is not exist!");
					else
						print_node(ret);
				}
				any_key();
				break;
		case '2': case 'I': case 'i':
				if (sturoot == NULL) {
					printf("Datebase is empty, System will re-create it.\n");
      			if ((sturoot = create_darr(sizeof(struct stu))) == NULL) {
         			printf("DB is empty,create date error.\n");
         			return -1; 
      			}
				}	   
				printf("Please enter the new record: 'ID,Name,Scope:'\n");
				{
					struct stu tmp;
					if (getline(&tmp) == 0) 
						printf("Input Format wrong!\n");
					else if (inserd_node(sturoot,&tmp,0) == -1)
						printf("Input Error!");
					else
						printf("Insert OK!");
				}
				any_key();
				break;
		case '3': case 'D': case 'd':
				printf("Please enter the condition : [ID],[Name],[Scope]\n");
				{
					struct stu tmp;
					if (getline(&tmp) == 0) 
						printf("Input Format wrong!");
					else
						delete_node(sturoot,&tmp, &cmp);
				}
				any_key();
				break;
		case '4': case 'L': case 'l':
				travel(sturoot,print_node);
				any_key();
				break;
		case '5': case 'E': case 'e':
				erase(sturoot);
				printf("All data has erase!!");
				sturoot = NULL;
				any_key();
				break;
#if 0
		case '6': case 'A': case 'a':
				printf("Please enter the condition: [ID],[Name],[Scope]\n");
				{
					struct stu tmp;
					if (getline(&tmp) == 0) {
						printf("Input Format wrong!");
					} else if (delete(&sturoot, &tmp, DELETE_ALL_YES) == 0)
						printf("Record is not exist!");
				}
				any_key();
				break;
#endif
		case '7': case 'U': case 'u':
				{
					struct stu tmp_from, tmp_to, *tmp_find;
					printf("Please enter the condition: [ID],[Name],[Scope]\n");
					if (getline(&tmp_from) == 0) {
						printf("Input Format wrong!");
					} else if ((tmp_find = (struct stu *)find_node(sturoot,&tmp_from,cmp)) != NULL) {
						print_node(tmp_find);
						printf("Please enter the new data: [ID],[Name],[Scope]\n");
						if (getline(&tmp_to) == 0) 
							printf("Input Format wrong!");
						else if (update_node(tmp_find, &tmp_to) == 0)
							printf("Update Succeed.");
					} else 
							printf("Record is not exist!");
				}
				any_key();
				break;
		case '8': case 'S': case 's':
				{
					int sel;
					int (*fun)(const void *, const void*);
					printf("Please select sort by:\n1[by ID]\t2[by name]\t3[by scope]:");
					if ((sel=get_num()) <= 3 && sel >= 1) {
						switch (sel) {
							case 1:
								fun = cmp_id;
								break;
							case 2:
								fun = cmp_name;
								break;
							case 3:
								fun = cmp_scope;
								break;
						}
						darr_sort(sturoot,fun);
						printf("Sort Succeed.");
					} else
						printf("Select wrong.");
				}
				any_key();
				break;
		case '9':
				if (save_darr(sturoot, "db.db") == -1)
					fprintf(stderr, "Open file failed.\n");
				any_key();
				break;
		default:
				break;
		}

	return 0;
}
Exemplo n.º 22
0
void radiotap(unsigned char* data, int rd) {
	struct ieee80211_radiotap_header* rth;
	struct ieee80211_frame* wh;
	char* body;
	struct node_info node;
	int8_t signal_dbm, noise_dbm;
	uint8_t signal_db, noise_db;
	int dbm = 0;
	int signal = 0;
	int i;

	rd -= 4; // 802.11 CRC

	// radiotap
	rth = (struct ieee80211_radiotap_header*) data;

	// 802.11
	wh = (struct ieee80211_frame*)
	     ((char*)rth + rth->it_len);
        rd -= rth->it_len;

	assert (rd >= 0);

	// body
	body = (char*) wh + sizeof(*wh);
	rd -= sizeof(*wh);

	if (!get_packet_info(wh, body, rd, &node))
		return;

	// signal and noise
	body = (char*) rth + sizeof(*rth);
	signal_dbm = noise_dbm = signal_db = noise_db = 0;

	for (i = IEEE80211_RADIOTAP_TSFT; i <= IEEE80211_RADIOTAP_EXT; i++) {
		if (!(rth->it_present & (1 << i)))
			continue;
		
		switch (i) {
		case IEEE80211_RADIOTAP_TSFT:
			body += sizeof(uint64_t);
			break;
		
		case IEEE80211_RADIOTAP_FLAGS:
		case IEEE80211_RADIOTAP_RATE:
			body += sizeof(uint8_t);
			break;
		
		case IEEE80211_RADIOTAP_CHANNEL:
			body += sizeof(uint16_t)*2;
			break;
		
		case IEEE80211_RADIOTAP_FHSS:
			body += sizeof(uint16_t);
			break;
		
		case IEEE80211_RADIOTAP_DBM_ANTSIGNAL:
			signal_dbm = *body;
			body++;
			dbm = 1;
			break;
		
		case IEEE80211_RADIOTAP_DBM_ANTNOISE:
			noise_dbm = *body;
			body++;
			break;
		
		case IEEE80211_RADIOTAP_DB_ANTSIGNAL:
			signal_db = *((unsigned char*)body);
			body++;
			break;

		case IEEE80211_RADIOTAP_DB_ANTNOISE:
			noise_db = *((unsigned char*)body);
			body++;
			break;
		
		case IEEE80211_RADIOTAP_EXT:
			abort();
			break;
		}
	}
	if (dbm) {
		signal = signal_dbm - noise_dbm;
	}
	else {
		signal = signal_db - noise_db;
	}
	if (signal < 0)
		signal = 0;

	node.signal = signal;
#if 0
	if (node.signal > 100 || node.signal < 0) {
		mvprintw(25,25, "sig=%d", node.signal);
	}	
#else		
	assert (node.signal <= 100 && node.signal >= 0);
#endif

	update_node(&node);
}
Exemplo n.º 23
0
void RunUpdate() {
  auto &txn_manager = concurrency::TransactionManagerFactory::GetInstance();

  auto txn = txn_manager.BeginTransaction();

  /////////////////////////////////////////////////////////
  // INDEX SCAN + PREDICATE
  /////////////////////////////////////////////////////////

  std::unique_ptr<executor::ExecutorContext> context(
      new executor::ExecutorContext(txn));

  // Column ids to be added to logical tile after scan.
  std::vector<oid_t> column_ids;
  oid_t column_count = state.column_count + 1;

  for (oid_t col_itr = 0; col_itr < column_count; col_itr++) {
    column_ids.push_back(col_itr);
  }

  // Create and set up index scan executor

  std::vector<oid_t> key_column_ids;
  std::vector<ExpressionType> expr_types;
  std::vector<Value> values;
  std::vector<expression::AbstractExpression *> runtime_keys;

  auto tuple_count = state.scale_factor * DEFAULT_TUPLES_PER_TILEGROUP;
  auto lookup_key = rand() % tuple_count;

  key_column_ids.push_back(0);
  expr_types.push_back(
      ExpressionType::EXPRESSION_TYPE_COMPARE_EQUAL);
  values.push_back(ValueFactory::GetIntegerValue(lookup_key));

  auto ycsb_pkey_index = user_table->GetIndexWithOid(user_table_pkey_index_oid);

  planner::IndexScanPlan::IndexScanDesc index_scan_desc(
      ycsb_pkey_index, key_column_ids, expr_types, values, runtime_keys);

  // Create plan node.
  auto predicate = nullptr;

  planner::IndexScanPlan index_scan_node(user_table,
                                         predicate, column_ids,
                                         index_scan_desc);

  // Run the executor
  executor::IndexScanExecutor index_scan_executor(&index_scan_node,
                                                  context.get());

  /////////////////////////////////////////////////////////
  // UPDATE
  /////////////////////////////////////////////////////////

  planner::ProjectInfo::TargetList target_list;
  planner::ProjectInfo::DirectMapList direct_map_list;

  // Update the second attribute
  for (oid_t col_itr = 0; col_itr < column_count; col_itr++) {
    if(col_itr != 1) {
      direct_map_list.emplace_back(col_itr,
                                   std::pair<oid_t, oid_t>(0, col_itr));
    }
  }

  Value update_val = ValueFactory::GetStringValue(std::string("updated"));
  target_list.emplace_back(1, expression::ExpressionUtil::ConstantValueFactory(update_val));

  planner::UpdatePlan update_node(
      user_table, new planner::ProjectInfo(std::move(target_list),
                                           std::move(direct_map_list)));

  executor::UpdateExecutor update_executor(&update_node, context.get());
  update_executor.AddChild(&index_scan_executor);

  /////////////////////////////////////////////////////////
  // EXECUTE
  /////////////////////////////////////////////////////////

  std::vector<executor::AbstractExecutor *> executors;
  executors.push_back(&update_executor);

  ExecuteTest(executors);

  txn_manager.CommitTransaction();
}
Exemplo n.º 24
0
    // process a single message in queue
    bool 
    vast_dc::handlemsg (VAST::id_t from_id, msgtype_t msgtype, timestamp_t recvtime, char *msg, int size)
    {
#ifdef DEBUG_DETAIL
        printf ("%4d [%3d] processmsg from: %3d type: (%2d)%-12s size:%3d\n", (int)_net->get_curr_timestamp (), (int)_self.id, (int)from_id, 
                msgtype, (msgtype>=10 && msgtype<=DC_UNKNOWN)?VAST_DC_MESSAGE[msgtype-10]:"UNKNOWN", size);
#endif

        // should do like this way?
        if (_joined == S_INIT)
        {
            // if I'm not suppose to join, any VAST message will incur disconnect the node
            // protential BUG: any side effects?
            if (msgtype >= DC_QUERY && msgtype < DC_UNKNOWN)
            {
                // if a query message, send it back to prevent other nodes fail to join
                if (msgtype == DC_QUERY)
                    _net->sendmsg (from_id, msgtype, msg, size);

                if (_net->is_connected (from_id))
                    _net->disconnect (from_id);
            }

            return false;
        }
        else if (_joined == S_JOINING && msgtype != DC_NODE)
            return false;

        switch ((VAST_DC_Message)msgtype)
        {
        case DC_QUERY:
            if (size == sizeof (Msg_QUERY))
            {
                // to prevent gateway server from over-connection
                if (_self.id == NET_ID_GATEWAY)
                    _net->disconnect (from_id);

                Msg_QUERY n (msg);
                Node &joiner = n.node;
                
                VAST::id_t closest_id = _voronoi->closest_to (joiner.pos);

                // forward the request if a more approprite node exists
                if (_voronoi->contains (_self.id, joiner.pos) == false &&
                    closest_id != _self.id &&
                    closest_id != from_id) 
                {                    
                    _net->sendmsg (closest_id, DC_QUERY, msg, size, true, true);
                }
                    
                else
                {
                    // I am the acceptor, send back initial neighbor list
                    vector<VAST::id_t> list;
                 
                    // insert first so we can properly find joiner's EN
                    // TODO: what if joiner exceeds connection limit?
                    //       should remove closest to AOI
                    //
                    insert_node (joiner, &n.addr);
                    int size = _neighbors.size (); 
                    for (int i=0; i<size; ++i)
                    {
                        if (_neighbors[i]->id == joiner.id)
                            continue;
                            
                        // send only relevant neighbors
                        if (_voronoi->overlaps (_neighbors[i]->id, joiner.pos, joiner.aoi) ||
                            _voronoi->is_enclosing (_neighbors[i]->id, joiner.id))
                            list.push_back (_neighbors[i]->id);
                    }
                    
                    send_nodes (joiner.id, list, true);
                }
            }
            break;

        case DC_HELLO:
            if (size == sizeof (Msg_NODE))
            {
                Msg_NODE newnode(msg);

                if (is_neighbor (from_id))
                    update_node (newnode.node);
                else
                {
                    // accept all HELLO request
                    // we assume over-connections can be taken care
                    // later by adjust_aoi mechanism
                    insert_node (newnode.node);//, newnode.addr);                                  
                }
            }
            break;

        case DC_EN:
            if ((size-1) % sizeof(VAST::id_t) == 0)
            {
                // ignore EN request if not properly connected
                if (is_neighbor (from_id) == false)
                    break;

                int n = (int)msg[0];
                char *p = msg+1;

                // BUG: potential memory leak for the allocation of map?
                map<VAST::id_t, int>  *list = new map<VAST::id_t, int>; // list of EN received
                
                vector<VAST::id_t>    missing;   // list of missing EN ids                                                
                vector<VAST::id_t> &en_list = _voronoi->get_en (_self.id); // list of my own EN
                
                int i;
                // create a searchable list of EN (BUG, mem leak for insert?)                   
                for (i=0; i<n; ++i, p += sizeof (VAST::id_t))
                    list->insert (map<VAST::id_t, int>::value_type (*(VAST::id_t *)p, STATE_OVERLAPPED));  

                // store as initial known list (clear necessary to prevent memory leak?)
                // csc 20080305: unnecessary, destructor should do it while deleting
                //_neighbor_states[from_id]->clear ();
                delete _neighbor_states[from_id];
                _neighbor_states[from_id] = list;

                int en_size = en_list.size ();
                for (i=0; i<en_size; ++i)
                {
                    // send only relevant missing neighbors
                    if (list->find (en_list[i]) == list->end () && 
                        en_list[i] != from_id &&                            
                        _voronoi->overlaps (en_list[i], _id2node[from_id].pos, _id2node[from_id].aoi))
                        missing.push_back (en_list[i]);
                }

                send_nodes (from_id, missing);
            }
            break;

        case DC_MOVE:
        case DC_MOVE_B:
            if (size == sizeof (Node))
            {
                Node *node = (Node *)msg;

                // if the remote node has just been disconnected,
                // then no need to process MOVE message in queue
                if (update_node (*node) == false)
                    break;

                // records nodes requesting neighbor discovery check
                if (msgtype == DC_MOVE_B)
                    _req_nodes[from_id] = 1;
                    //req_nodes.push_back (from_id);

                /*
                // prevent incorrect judgement when later I become a BN
                else
                    _neighbor_states[from_id]->clear ();
                */
            }
            break;

        case DC_NODE:
            if ((size-1) % sizeof (Msg_NODE) == 0)
            {
                int n = (int)msg[0];
                char *p = msg+1;
                Msg_NODE newnode;                    // new node discovered

                if (_joined < S_JOINING)
                    break;

                // TODO: find a cleaner way than to reset everytime
                _joined = S_JOINED;
                
                // store each node notified, we'll process them later in batch
                int i;
                bool store;
                map<VAST::id_t, Msg_NODE>::iterator it;

                for (i=0; i<n; ++i, p += sizeof (Msg_NODE))
                {   
                    _NM_total++;
                    
                    memcpy (&newnode, p, sizeof (Msg_NODE));

                    store = true;
                    it = _notified_nodes.find (newnode.node.id);
                    if (it != _notified_nodes.end ())
                    {
                        _NM_known++;
                        
                        // potential BUG:
                        // NOTE: we're using time to decide if using a newer one to replace
                        //       an existing notified node, however this might give
                        //       false prefererence if remote nodes' clocks are not
                        //       well-synchronized
                        if (newnode.node.time < (it->second).node.time)
                            store = false;
                    }
                    
                    if (store) 
                    {
                        // store the new notified node with my own time
                        // this is to ensure time-based disposal can work properly
                        newnode.node.time = _net->get_curr_timestamp (); //_time;
                        _notified_nodes[newnode.node.id] = newnode;
                    }

                    /*
                    if (_notified_nodes.find (newnode.node.id) != _notified_nodes.end ())
                    {
                        _NM_known++;
                        if (_notified_nodes[newnode.node.id].node.time < newnode.node.time)
                            _notified_nodes[newnode.node.id] = newnode;
                    }
                    else 
                        _notified_nodes[newnode.node.id] = newnode;                        
                    */

                    // notify network knowledge source of IP address
                    // TODO: queue all nofities in the same step
                    vector<VAST::id_t> idlist;
                    idlist.push_back (newnode.node.id);
                    _net->notify_id_mapper (from_id, idlist);
                }
            }
            break;

        case DC_OVERCAP:
            if (size == 0)
            {
                if(is_neighbor (from_id) == false)
                    break;

                // remote node has exceeded its capacity, 
                // we need to shrink our own AOI
                adjust_aoi (&_id2node[from_id].pos);
            }
            break;
        /*
        case DC_PAYLOAD:
            {                    
                // create a buffer
                netmsg *newnode = new netmsg (from_id, msg, size, msgtype, recvtime, NULL, NULL);

                // put the content into a per-neighbor queue
                if (_id2msg.find (from_id) == _id2msg.end ())
                    _id2msg[from_id] = newnode;
                else
                    _id2msg[from_id]->append (newnode, recvtime);
            }
            break;
        */

        case DISCONNECT:
            if ((size-1) % sizeof (id_t) == 0)
            {
                int n = msg[0];
                char *p = msg+1;
                id_t id;

                for (int i=0; i<n; ++i, p+=sizeof (id_t))
                {
                    memcpy (&id, p, sizeof (id_t));
                    
                    // see if it's a remote node disconnecting me
                    if (id == _self.id)
                        delete_node (from_id, false);                        
                    /*
                    // delete this node from list of known neighbors
                    else 
                    {
                      
                        map<id_t, int> *list;
                        map<id_t, int>::iterator it;
                        if (_neighbor_states.find (from_id) != _neighbor_states.end ())
                        {
                            list = _neighbor_states[from_id];
                            if ((it = list->find (id)) != list->end ())
                                list->erase (it);                                
                        }
                      
                    }
                    */
                }
                
            }
            // allow other handlers to handle the DISCONNECT message
            return false;

        default:
#ifdef DEBUG_DETAIL
            // throw to additional message handler, if it exists
            ERROR_MSG_ID (("unknown message"));
#endif
            return false;
        }

        return true;
    }
Exemplo n.º 25
0
bool RunMixed(ZipfDistribution &zipf, FastRandom &rng) {

  auto &txn_manager = concurrency::TransactionManagerFactory::GetInstance();

  concurrency::Transaction *txn = txn_manager.BeginTransaction();

  std::unique_ptr<executor::ExecutorContext> context(
      new executor::ExecutorContext(txn));

  // Column ids to be added to logical tile.
  std::vector<oid_t> column_ids;
  oid_t column_count = state.column_count + 1;

  // read all the attributes in a tuple.
  for (oid_t col_itr = 0; col_itr < column_count; col_itr++) {
    column_ids.push_back(col_itr);
  }

  // Create and set up index scan executor
  std::vector<oid_t> key_column_ids;
  std::vector<ExpressionType> expr_types;

  key_column_ids.push_back(0);
  expr_types.push_back(ExpressionType::EXPRESSION_TYPE_COMPARE_EQUAL);

  std::vector<expression::AbstractExpression *> runtime_keys;
  
  for (int i = 0; i < state.operation_count; i++) {

    auto rng_val = rng.NextUniform();

    if (rng_val < state.update_ratio) {
      /////////////////////////////////////////////////////////
      // PERFORM UPDATE
      /////////////////////////////////////////////////////////

      // set up parameter values
      std::vector<type::Value > values;

      auto lookup_key = zipf.GetNextNumber();

      values.push_back(type::ValueFactory::GetIntegerValue(lookup_key).Copy());

      auto ycsb_pkey_index = user_table->GetIndexWithOid(user_table_pkey_index_oid);
    
      planner::IndexScanPlan::IndexScanDesc index_scan_desc(
          ycsb_pkey_index, key_column_ids, expr_types, values, runtime_keys);

      // Create plan node.
      auto predicate = nullptr;

      planner::IndexScanPlan index_scan_node(user_table, predicate, column_ids,
                                             index_scan_desc);

      // Run the executor
      executor::IndexScanExecutor index_scan_executor(&index_scan_node,
                                                      context.get());

      TargetList target_list;
      DirectMapList direct_map_list;

      // update multiple attributes
      for (oid_t col_itr = 0; col_itr < column_count; col_itr++) {
        if (col_itr == 1) {
          if (state.string_mode == true) {

            std::string update_raw_value(100, 'a');
            type::Value update_val = type::ValueFactory::GetVarcharValue(update_raw_value).Copy();
            target_list.emplace_back(
                  col_itr, expression::ExpressionUtil::ConstantValueFactory(update_val));             

          } else {

            int update_raw_value = 1;
            type::Value update_val = type::ValueFactory::GetIntegerValue(update_raw_value).Copy();
            target_list.emplace_back(
                  col_itr, expression::ExpressionUtil::ConstantValueFactory(update_val)); 
          }
        }
        else {
          direct_map_list.emplace_back(col_itr,
                                       std::pair<oid_t, oid_t>(0, col_itr));
        }
      }

      std::unique_ptr<const planner::ProjectInfo> project_info(
          new planner::ProjectInfo(std::move(target_list),
                                   std::move(direct_map_list)));
      planner::UpdatePlan update_node(user_table, std::move(project_info));

      executor::UpdateExecutor update_executor(&update_node, context.get());

      update_executor.AddChild(&index_scan_executor);

      ExecuteUpdate(&update_executor);

      if (txn->GetResult() != Result::RESULT_SUCCESS) {
        txn_manager.AbortTransaction(txn);
        return false;
      }

    } else {
      /////////////////////////////////////////////////////////
      // PERFORM READ
      /////////////////////////////////////////////////////////

      // set up parameter values
      std::vector<type::Value > values;

      auto lookup_key = zipf.GetNextNumber();

      values.push_back(type::ValueFactory::GetIntegerValue(lookup_key).Copy());

      auto ycsb_pkey_index = user_table->GetIndexWithOid(user_table_pkey_index_oid);
    
      planner::IndexScanPlan::IndexScanDesc index_scan_desc(
          ycsb_pkey_index, key_column_ids, expr_types, values, runtime_keys);

      // Create plan node.
      auto predicate = nullptr;

      planner::IndexScanPlan index_scan_node(user_table, predicate, column_ids,
                                             index_scan_desc);

      // Run the executor
      executor::IndexScanExecutor index_scan_executor(&index_scan_node,
                                                      context.get());

      
      
      ExecuteRead(&index_scan_executor);

      if (txn->GetResult() != Result::RESULT_SUCCESS) {
        txn_manager.AbortTransaction(txn);
        return false;
      }
    }
  }

  // transaction passed execution.
  PL_ASSERT(txn->GetResult() == Result::RESULT_SUCCESS);

  auto result = txn_manager.CommitTransaction(txn);

  if (result == Result::RESULT_SUCCESS) {
    return true;
    
  } else {
    // transaction failed commitment.
    PL_ASSERT(result == Result::RESULT_ABORTED ||
           result == Result::RESULT_FAILURE);
    return false;
  }
}