void DRCubeDimension::addCube(PServer server, PDatabase database, const Dimension *dimension, bool lookup, IdentifierType *rightsCubeId, bool useDimWorker)
{
	const string cubeName = SystemCube::PREFIX_GROUP_DIMENSION_DATA + dimension->getName();
	if (!lookup || !database->lookupCubeByName(cubeName, false)) {
		PDimension groupDimension = database->findDimensionByName(SystemDatabase::NAME_GROUP_DIMENSION, PUser(), false);
		IdentifiersType dimensions;
		dimensions.push_back(groupDimension->getId());
		dimensions.push_back(dimension->getId());

		PRightsCube cube = PRightsCube(new RightsCube(database, cubeName,  &dimensions));
		cube->setDeletable(false);
		cube->setRenamable(false);

		bool newId = true;
		if (rightsCubeId && *rightsCubeId != NO_IDENTIFIER) {
			cube->setID(*rightsCubeId);
			newId = false;
		}

		database->addCube(server, cube, false, newId, NULL, NULL, NULL, useDimWorker);

		if (rightsCubeId) {
			*rightsCubeId = cube->getId();
		}
	}
}
Beispiel #2
0
void AggregationMap::compactSourceToTarget() {
  targetIdBuffer.clear();
  weightBuffer.clear();
  distributionMap.clear();
  source2TargetMap.clear();
  source2TargetVector.clear();

  for (SourceToTargetMapType::iterator stit = base2ParentMap.begin();
      stit != base2ParentMap.end(); ++stit) {
    IdentifiersType targetIds;
    vector<double> targetWeights;

    for (TargetMapType::const_iterator tmit = stit->second.begin();
        tmit != stit->second.end(); ++tmit) {
      targetIds.push_back(tmit->first);
      targetWeights.push_back(tmit->second);
    }
    SourceToTargetMapType::iterator nit = stit;
    ++nit;
    IdentifierType nextStartId =
        nit == base2ParentMap.end() ? stit->first + 1 : nit->first;
    storeDistributionSequence(stit->first, nextStartId, targetIds,
                              targetWeights);
  }
}
DimensionBrowserDocumentation::DimensionBrowserDocumentation(PDatabase database, PDimension dimension, const string& message) :
	BrowserDocumentation(message)
{
	defineDatabase(database);
	defineDimension(dimension);

	ElementsType elements = dimension->getElements(PUser(), false);
	IdentifiersType elementIds;
	elementIds.reserve(elements.size());
	for (ElementsType::const_iterator it = elements.begin(); it != elements.end(); ++it) {
		elementIds.push_back((*it)->getIdentifier());
	}
	defineElements(dimension, elementIds.begin(), elementIds.end(), "@element");
}
void AttributedDimension::addDimension(PServer server, PDatabase database, const Dimension *dimension, bool lookup, IdentifierType *attributesDimId, IdentifierType *attributesCubeId, bool useDimWorker)
{
	const string dimName = AttributesDimension::PREFIX_ATTRIBUTE_DIMENSION + dimension->getName() + AttributesDimension::SUFFIX_ATTRIBUTE_DIMENSION;
	PDimension attribDimension;
	if (lookup) {
		attribDimension = database->lookupDimensionByName(dimName, false);
	}
	if (!lookup || !attribDimension) {
		// create attributes dimension
		attribDimension = PAttributesDimension(new AttributesDimension(dimName));
		attribDimension->setDeletable(false);
		attribDimension->setRenamable(false);

		bool newId = true;
		if (attributesDimId && *attributesDimId != NO_IDENTIFIER) {
			attribDimension->setID(*attributesDimId);
			newId = false;
		}

		database->addDimension(server, attribDimension, true, newId, NULL, NULL, NULL, NULL, useDimWorker);

		if (attributesDimId) {
			*attributesDimId = attribDimension->getId();
		}
	}

	const string cubeName = Cube::PREFIX_ATTRIBUTE_CUBE + dimension->getName();
	if (!lookup || !database->lookupCubeByName(cubeName, false)) {
		IdentifiersType dimensions;
		dimensions.push_back(attribDimension->getId());
		dimensions.push_back(dimension->getId());

		PSystemCube attributesCube = PSystemCube(new AttributesCube(database, cubeName, &dimensions, true));
		attributesCube->setDeletable(false);
		attributesCube->setRenamable(false);

		bool newId = true;
		if (attributesCubeId && *attributesCubeId != NO_IDENTIFIER) {
			attributesCube->setID(*attributesCubeId);
			newId = false;
		}

		database->addCube(server, attributesCube, false, newId, NULL, NULL, NULL, useDimWorker);

		if (attributesCubeId) {
			*attributesCubeId = attributesCube->getId();
		}
	}
}
Beispiel #5
0
bool ConfigDatabase::createSystemItems(PServer server, bool forceCreate)
{
	checkCheckedOut();
	bool dbChanged = NormalDatabase::createSystemItems(server, forceCreate);

	if (getName() == Server::NAME_CONFIG_DATABASE) {
		PDatabase db = COMMITABLE_CAST(Database, shared_from_this());

		checkAndCreateDimension(server, db, NAME_CONNECTIONS_DIMENSION, 0, 0, CONNECTIONS_ATTR_ITEMS, CONNECTIONS_ATTR_ITEMS + array_size(CONNECTIONS_ATTR_ITEMS), dbChanged);
		checkAndCreateDimension(server, db, NAME_CONFIG_DIMENSION, CONFIG_ITEMS, CONFIG_ITEMS + array_size(CONFIG_ITEMS), CONFIG_ATTR_ITEMS, CONFIG_ATTR_ITEMS + array_size(CONFIG_ATTR_ITEMS), dbChanged);
		PDimension taskPropsDim = checkAndCreateDimension(server, db, NAME_TASKPROPS_DIMENSION, TASKPROPS_ITEMS, TASKPROPS_ITEMS + array_size(TASKPROPS_ITEMS), dbChanged);
		PDimension notifTypesDim = checkAndCreateDimension(server, db, NAME_NOTIFTYPES_DIMENSION, NOTIFTYPES_ITEMS, NOTIFTYPES_ITEMS + array_size(NOTIFTYPES_ITEMS), dbChanged);
		PDimension tasksDim = checkAndCreateDimension(server, db, NAME_TASKS_DIMENSION, 0, 0, dbChanged);
		checkAndCreateDimension(server, db, NAME_VARSETS_DIMENSION, 0, 0, VARSETS_ATTR_ITEMS, VARSETS_ATTR_ITEMS + array_size(VARSETS_ATTR_ITEMS), dbChanged);
		PDimension etls = checkAndCreateDimension(server, db, NAME_ETLS_DIMENSION, 0, 0, dbChanged);
		PDimension etlprops = checkAndCreateDimension(server, db, NAME_ETLPROPS_DIMENSION, ETLPROPS_ITEMS, ETLPROPS_ITEMS + array_size(ETLPROPS_ITEMS), dbChanged);

		IdentifiersType dims;
		dims.push_back(etls->getId());
		dims.push_back(etlprops->getId());
		checkAndCreateCube(server, db, NAME_ETLS_CUBE, dims, dbChanged);

		dims[0] = tasksDim->getId();
		dims[1] = taskPropsDim->getId();
		checkAndCreateCube(server, db, NAME_TASKS_CUBE, dims, dbChanged);

		PDimension userDim = lookupDimensionByName(SystemDatabase::NAME_USER_DIMENSION, false);
		dims[1] = notifTypesDim->getId();
		dims.push_back(userDim->getId());
		checkAndCreateCube(server, db, NAME_TASKS_NOTIF_CUBE, dims, dbChanged);

		dims[1] = taskPropsDim->getId();
		checkAndCreateCube(server, db, NAME_TASKS_PRIVATE_CUBE, dims, dbChanged);

		checkConfigCube(server, db, dbChanged);

		if (isDeletable()) {
			setDeletable(false);
			dbChanged = true;
		}
		if (isRenamable()) {
			setRenamable(false);
			dbChanged = true;
		}
		protect = true;
	}
	return dbChanged;
}
Beispiel #6
0
Area::Area(const IdentifiersType &path, bool useSet)
    : area(useSet ? path.size() : 0),
      areaSize(1),
      stepSizes(path.size(), 0) {
  if (useSet) {
    size_t size = path.size();
    for (size_t i = 0; i < size; i++) {
      Set* s(new Set);
      s->insert(path[i]);
      insert((IdentifierType) i, s, false);
    }
  } else {
    vpath = path;
  }
  // calcSize();
}
Beispiel #7
0
const IdentifiersType FileReaderTXT::getDataIdentifiers(int num)
{
	const vector<string> stringList = getDataStrings(num, ',');
	IdentifiersType result;
	char *p;

	for (vector<string>::const_iterator i = stringList.begin(); i != stringList.end(); ++i) {
		long li = strtol((*i).c_str(), &p, 10);

		if (*p != '\0') {
			result.push_back(0);
		} else {
			result.push_back(li);
		}
	}

	return result;
}
Beispiel #8
0
bool CompleteProcessor::next()
{
	if (!area || !defaultValue) {
		return source->next();
	} else if (isDefaultValue()) {
		bFirst = false;
		if (nextRepetition()) {
			// R
			return true;
		} else {
			// use current existing V
			return !sourceEnded;
		}
	} else {
		IdentifiersType prevKey;
		if (source) {
			// search for next existing value (V | R | E)
			bool result = false;
			if (bFirst) {
				bFirst = false;
			} else {
				prevKey = source->getKey();
			}

			while (!sourceEnded) {
				result = source->next();
				if (result) {
					setRepetition(prevKey.empty() ? 0 : &prevKey, &getKey());
					return true;
				} else {
					sourceEnded = true;
				}
			}
		} else {
			bFirst = false;
		}
		return 0 != setRepetition(prevKey.empty() ? 0 : &prevKey, 0);
	}
}
Beispiel #9
0
PPaths FileReaderTXT::getDataPaths(int num)
{
	vector<string> stringList = getDataStrings(num, ':');
	PPaths result(new vector<IdentifiersType>());

	for (vector<string>::iterator iset = stringList.begin(); iset != stringList.end(); ++iset) {
		vector<string> subsetStrings;
		IdentifiersType subset;
		splitString(*iset, &subsetStrings, ',');

		char *p;
		IdentifiersType path;
		for (vector<string>::const_iterator i = subsetStrings.begin(); i != subsetStrings.end(); ++i) {
			long li = strtol((*i).c_str(), &p, 10);

			if (*p == 0) {
				path.push_back(li);
			}
		}
		result->push_back(path);
	}

	return result;
}
Beispiel #10
0
bool ConstantProcessor::move(const IdentifiersType &key, bool *found)
{
	if (found) {
		*found = false;
	}
	if (value.isEmpty()) {
		return false;
	}
	path = area->lowerBound(key);
	first = false;
	if (path != area->pathEnd()) {
		if (found) {
			*found = key.compare(*path) == 0;
		}
		return true;
	}
	return false;
}
Beispiel #11
0
Area::PathIterator Area::find(const IdentifiersType &path) const {
  if (path.size() != area.size()) {
    return pathEnd();
  }
  if (vpath.size()) {
    return vpath == path ? pathBegin() : pathEnd();
  } else {
    vector<ConstElemIter> p;
    for (size_t i = 0; i < area.size(); i++) {
      ConstElemIter it = area[i]->find(path[i]);
      if (it == area[i]->end()) {
        return pathEnd();
      }
      p.push_back(it);
    }
    return PathIterator(*this, false, p);
  }
}
void PaloHttpRequest::setKeyValue(char * keyStart, char * keyPtr, char * valueStart, char * valuePtr)
{
	const struct CommandOption * option = Perfect_Hash::PaloValue(keyStart, (unsigned int)(keyPtr - keyStart));

	if (Server::flightRecorderEnabled()) {
		httpParams.seekg(0, ios::end);
		std::streamoff size = httpParams.tellg();
		httpParams.seekg(0, ios::beg);

		if (size == 0) {
			httpParams << "?";
		} else {
			httpParams << "&";
		}

		httpParams.write(keyStart, keyPtr - keyStart);
		httpParams << '=';

		if (option != 0 && option->code == PaloRequestHandler::CMD_SID) {
			httpParams << PaloSession::shortenSid(string(valueStart, valuePtr));
		} else if (valuePtr - valueStart > 1000000) {
			httpParams.write(valueStart, 1000000);
			httpParams << "...(argument total " << valuePtr-valueStart << " bytes)";
		} else {
			httpParams.write(valueStart, valuePtr - valueStart);
		}
	}

	if (option != 0) {
		switch (option->code) {
		case PaloRequestHandler::CMD_SID:
			fillSid(paloJobRequest->sid, valueStart, valuePtr);
			paloJobRequest->hasSession = true;
			break;

		case PaloRequestHandler::CMD_ID_CUBE:
			fillIdentifier(paloJobRequest->cube, valueStart, valuePtr);
			break;

		case PaloRequestHandler::CMD_ID_DATABASE:
			fillIdentifier(paloJobRequest->database, valueStart, valuePtr);
			break;

		case PaloRequestHandler::CMD_ID_DIMENSION:
			fillIdentifier(paloJobRequest->dimension, valueStart, valuePtr);
			break;

		case PaloRequestHandler::CMD_ID_ELEMENT:
			fillIdentifier(paloJobRequest->element, valueStart, valuePtr);
			break;

		case PaloRequestHandler::CMD_ID_LIMIT: {
			IdentifiersType *limitValues = 0;
			fillVectorIdentifier(limitValues, valueStart, valuePtr);
			if (!limitValues) {
				break;
			}
			if (limitValues->size() > 1) {
				paloJobRequest->limitCount = (*limitValues)[1];
			}
			if (limitValues->size()) {
				paloJobRequest->limitStart = (*limitValues)[0];
			}
			delete limitValues;
		}
		break;

		case PaloRequestHandler::CMD_ID_LOCK:
			fillIdentifier(paloJobRequest->lock, valueStart, valuePtr);
			break;

		case PaloRequestHandler::CMD_ID_LOCKED_PATHS:
			fillIdentifier(paloJobRequest->lock, valueStart, valuePtr);
			fillVectorVectorIdentifier(paloJobRequest->lockedPaths, valueStart, valuePtr, ':', ',');
			break;

		case PaloRequestHandler::CMD_ID_RULE:
			fillVectorIdentifier(paloJobRequest->rules, valueStart, valuePtr);
			if (paloJobRequest->rules && paloJobRequest->rules->size()) {
				paloJobRequest->rule = paloJobRequest->rules->at(0);
			}
			break;

		case PaloRequestHandler::CMD_ACTIVATE:
			fillUint(paloJobRequest->activate, valueStart, valuePtr);
			break;

		case PaloRequestHandler::CMD_ADD:
			fillBoolean(paloJobRequest->add, valueStart, valuePtr);
			break;

		case PaloRequestHandler::CMD_BASE_ONLY:
			fillBoolean(paloJobRequest->baseOnly, valueStart, valuePtr);
			break;

		case PaloRequestHandler::CMD_COMPLETE:
			fillBoolean(paloJobRequest->complete, valueStart, valuePtr);
			break;

		case PaloRequestHandler::CMD_EVENT_PROCESSOR:
			fillBoolean(paloJobRequest->eventProcess, valueStart, valuePtr);
			break;

		case PaloRequestHandler::CMD_SHOW_ATTRIBUTE:
			fillBoolean(paloJobRequest->showAttribute, valueStart, valuePtr);
			break;

		case PaloRequestHandler::CMD_SHOW_INFO:
			fillBoolean(paloJobRequest->showInfo, valueStart, valuePtr);
			break;

		case PaloRequestHandler::CMD_SHOW_GPUTYPE:
			fillBoolean(paloJobRequest->showGputype, valueStart, valuePtr);
			break;

		case PaloRequestHandler::CMD_SHOW_LOCK_INFO:
			fillBoolean(paloJobRequest->showLockInfo, valueStart, valuePtr);
			break;

		case PaloRequestHandler::CMD_SHOW_NORMAL:
			fillBoolean(paloJobRequest->showNormal, valueStart, valuePtr);
			break;

		case PaloRequestHandler::CMD_SHOW_RULE:
			fillBoolean(paloJobRequest->showRule, valueStart, valuePtr);
			break;

		case PaloRequestHandler::CMD_SHOW_SYSTEM:
			fillBoolean(paloJobRequest->showSystem, valueStart, valuePtr);
			break;

		case PaloRequestHandler::CMD_SHOW_USER_INFO:
			fillBoolean(paloJobRequest->showUserInfo, valueStart, valuePtr);
			break;

		case PaloRequestHandler::CMD_SKIP_EMPTY:
			fillBoolean(paloJobRequest->skipEmpty, valueStart, valuePtr);
			break;

		case PaloRequestHandler::CMD_USE_IDENTIFIER:
			fillBoolean(paloJobRequest->useIdentifier, valueStart, valuePtr);
			break;

		case PaloRequestHandler::CMD_USE_RULES:
			fillBoolean(paloJobRequest->useRules, valueStart, valuePtr);
			break;

		case PaloRequestHandler::CMD_ACTION:
			fillString(paloJobRequest->action, valueStart, valuePtr);
			break;

		case PaloRequestHandler::CMD_COMMENT:
			fillString(paloJobRequest->comment, valueStart, valuePtr);
			break;

		case PaloRequestHandler::CMD_CONDITION:
			fillString(paloJobRequest->condition, valueStart, valuePtr);
			break;

		case PaloRequestHandler::CMD_NAME_CUBE:
			fillString(paloJobRequest->cubeName, valueStart, valuePtr);
			break;

		case PaloRequestHandler::CMD_NAME_DATABASE:
			fillString(paloJobRequest->databaseName, valueStart, valuePtr);
			break;

		case PaloRequestHandler::CMD_DEFINITION:
			fillString(paloJobRequest->definition, valueStart, valuePtr);
			break;

		case PaloRequestHandler::CMD_NAME_DIMENSION:
			fillString(paloJobRequest->dimensionName, valueStart, valuePtr);
			break;

		case PaloRequestHandler::CMD_NAME_ELEMENT:
			fillString(paloJobRequest->elementName, valueStart, valuePtr);
			break;

		case PaloRequestHandler::CMD_EVENT:
			fillString(paloJobRequest->event, valueStart, valuePtr);
			break;

		case PaloRequestHandler::CMD_EXTERN_PASSWORD:
			fillString(paloJobRequest->externPassword, valueStart, valuePtr);
			break;

		case PaloRequestHandler::CMD_EXTERNAL_IDENTIFIER:
			fillString(paloJobRequest->externalIdentifier, valueStart, valuePtr);
			break;

		case PaloRequestHandler::CMD_FUNCTIONS:
			fillString(paloJobRequest->functions, valueStart, valuePtr);
			break;

		case PaloRequestHandler::CMD_NEW_NAME:
			fillString(paloJobRequest->newName, valueStart, valuePtr);
			break;

		case PaloRequestHandler::CMD_PASSWORD:
			fillString(paloJobRequest->password, valueStart, valuePtr);
			break;

		case PaloRequestHandler::CMD_SOURCE:
			fillString(paloJobRequest->source, valueStart, valuePtr);
			break;

		case PaloRequestHandler::CMD_NAME_USER:
			fillString(paloJobRequest->user, valueStart, valuePtr);
			break;

		case PaloRequestHandler::CMD_VALUE:
			fillString(paloJobRequest->value, valueStart, valuePtr);
			break;

		case PaloRequestHandler::CMD_BLOCKSIZE:
			fillUint(paloJobRequest->blockSize, valueStart, valuePtr);
			break;

		case PaloRequestHandler::CMD_ID_MODE:
			fillUint(paloJobRequest->mode, valueStart, valuePtr);
			break;

		case PaloRequestHandler::CMD_POSITION:
			fillUint(paloJobRequest->position, valueStart, valuePtr);
			break;

		case PaloRequestHandler::CMD_PROPERTIES:
			fillVectorIdentifier(paloJobRequest->properties, valueStart, valuePtr);
			break;

		case PaloRequestHandler::CMD_SPLASH:
			fillUint(paloJobRequest->splash, valueStart, valuePtr);
			break;

		case PaloRequestHandler::CMD_NUM_STEPS:
			fillUint(paloJobRequest->steps, valueStart, valuePtr);
			break;

		case PaloRequestHandler::CMD_ID_TYPE:
			fillUint(paloJobRequest->type, valueStart, valuePtr);
			break;

		case PaloRequestHandler::CMD_ID_TYPES:
			fillVectorUint(paloJobRequest->types, valueStart, valuePtr);
			break;

		case PaloRequestHandler::CMD_ID_DIMENSIONS:
			fillVectorIdentifier(paloJobRequest->dimensions, valueStart, valuePtr);
			break;

		case PaloRequestHandler::CMD_ID_PARENT:
			if (valueStart == valuePtr) {
				// empty parameter -> no parent specified - root
				paloJobRequest->parent = NO_IDENTIFIER;
			} else {
				fillIdentifier(paloJobRequest->parent, valueStart, valuePtr);
			}
			break;

		case PaloRequestHandler::CMD_ID_PATH:
			fillVectorIdentifier(paloJobRequest->path, valueStart, valuePtr);
			break;

		case PaloRequestHandler::CMD_ID_PATH_TO:
			fillVectorIdentifier(paloJobRequest->pathTo, valueStart, valuePtr);
			break;

		case PaloRequestHandler::CMD_ID_ELEMENTS:
			fillVectorIdentifier(paloJobRequest->elements, valueStart, valuePtr);
			break;

		case PaloRequestHandler::CMD_WEIGHTS:
			fillVectorVectorDouble(paloJobRequest->weights, valueStart, valuePtr, ':', ',');
			break;

		case PaloRequestHandler::CMD_NAME_DIMENSIONS:
			fillVectorString(paloJobRequest->dimensionsName, valueStart, valuePtr, ',');
			break;

		case PaloRequestHandler::CMD_NAME_ELEMENTS:
			fillVectorStringQuote(paloJobRequest->elementsName, valueStart, valuePtr, ',');
			break;

		case PaloRequestHandler::CMD_NAME_PATH:
			fillVectorString(paloJobRequest->pathName, valueStart, valuePtr, ',');
			break;

		case PaloRequestHandler::CMD_NAME_PATH_TO:
			fillVectorString(paloJobRequest->pathToName, valueStart, valuePtr, ',');
			break;

		case PaloRequestHandler::CMD_VALUES:
			fillVectorStringQuote(paloJobRequest->values, valueStart, valuePtr, ':');
			break;

		case PaloRequestHandler::CMD_ID_AREA:
			fillVectorVectorIdentifier(paloJobRequest->area, valueStart, valuePtr, ',', ':');
			break;

		case PaloRequestHandler::CMD_ID_CHILDREN:
			fillVectorVectorIdentifier(paloJobRequest->children, valueStart, valuePtr, ':', ',');
			break;

		case PaloRequestHandler::CMD_ID_PATHS:
			fillVectorVectorIdentifier(paloJobRequest->paths, valueStart, valuePtr, ':', ',');
			break;

		case PaloRequestHandler::CMD_NAME_AREA:
			fillVectorVectorString(paloJobRequest->areaName, valueStart, valuePtr, ',', ':');
			break;

		case PaloRequestHandler::CMD_NAME_CHILDREN:
			fillVectorVectorStringQuote(paloJobRequest->childrenName, valueStart, valuePtr, ':', ',');
			break;

		case PaloRequestHandler::CMD_NAME_PATHS:
			fillVectorVectorString(paloJobRequest->pathsName, valueStart, valuePtr, ':', ',');
			break;
		case PaloRequestHandler::CMD_FUNCTION:
			fillUint(paloJobRequest->function, valueStart, valuePtr);
			break;
		case PaloRequestHandler::CMD_EXPAND:
			fillVectorUint(paloJobRequest->expand, valueStart, valuePtr);
			break;
		case PaloRequestHandler::CMD_ACTCODE:
			fillString(paloJobRequest->actcode, valueStart, valuePtr);
			break;
		case PaloRequestHandler::CMD_LICKEY:
			fillString(paloJobRequest->lickey, valueStart, valuePtr);
			break;
		case PaloRequestHandler::CMD_MACHINE:
			fillString(paloJobRequest->machineString, valueStart, valuePtr);
			break;
		case PaloRequestHandler::CMD_REQUIRED:
			fillString(paloJobRequest->requiredFeatures, valueStart, valuePtr);
			break;
		case PaloRequestHandler::CMD_OPTIONAL:
			fillString(paloJobRequest->optionalFeatures, valueStart, valuePtr);
			break;
		}
	}
}
Beispiel #13
0
uint32_t AggregationMap::storeDistributionSequence(
    const IdentifierType startId, const IdentifierType nextStartId,
    const IdentifiersType &targetIds, const vector<double> &targetWeights) {
  uint32_t distrMapIndex = uint32_t(-1);
  uint32_t distMapSequenceStart = uint32_t(-1);

  uint32_t newSize = (uint32_t) targetIds.size();
  uint32_t currentIndex = (uint32_t) distributionMap.size() - 1;
  // TODO: -jj- duplicities search in AggregationMap disabled because of performance problems
  for (vector<TargetSequence>::const_reverse_iterator dm = distributionMap
      .rbegin(); false && dm != distributionMap.rend(); ++dm, currentIndex--) {
    if (newSize == dm->length) {
      // compare content
      if (equal(targetIds.begin(), targetIds.end(),
                &targetIdBuffer[dm->startOffset])) {
        //uint32_t currentIndex = dm-distributionMap.rbegin();
        bool identicalWeights = false;
        if (targetWeights.empty() && weightBuffer.size() <= dm->startOffset) {
          // none of weights buffers exist - null == null
          identicalWeights = true;
        }
        if (weightBuffer.size()) {
          double *findEndIt = &weightBuffer[0]
              + min(dm->startOffset + dm->length,
                    (uint32_t) weightBuffer.size());
          if (!identicalWeights && targetWeights.empty()
              && std::find_if(&weightBuffer[dm->startOffset], findEndIt,
                              ISWeightNonDefault) == findEndIt) {
            // check if weightBuffer contains only 1.0 - null == default_weights
            identicalWeights = true;
          }
        }
        if (!identicalWeights && targetWeights.size()
            && weightBuffer.size() >= dm->startOffset + targetWeights.size()
            && equal(targetWeights.begin(), targetWeights.end(),
                     &weightBuffer[dm->startOffset])) {
          // both weight buffers exist - weights == weights
          identicalWeights = true;
        }
        if (identicalWeights) {
          distrMapIndex = currentIndex;
          //  LOG(INFO) << "duplicity saves: " << newSize*sizeof(targetIds[0]) << " B" << endl;
          break;
        }
      }
    }
  }

  //DLOG(INFO) << distrMapIndex << " " << distributionMap.size() << endl;
  if (distrMapIndex == uint32_t(-1)) {
    // copy sequence to buffers
    distMapSequenceStart = (uint32_t) targetIdBuffer.size();

    if (targetWeights.size()) {
      if (weightBuffer.size() != targetIdBuffer.size()) {
        weightBuffer.resize(targetIdBuffer.size(), 1.0);
      }
      copy(targetWeights.begin(), targetWeights.end(),
           std::back_insert_iterator<vector<double> >(weightBuffer));
    }
    copy(targetIds.begin(), targetIds.end(),
         std::back_insert_iterator<IdentifiersType>(targetIdBuffer));
    // write sequence start to distributionMap
    distrMapIndex = (uint32_t) (distributionMap.size());
    distributionMap.push_back(
        TargetSequence(distMapSequenceStart, (uint32_t) targetIds.size()));
  }
  if (source2TargetVector.empty()) {
    // update "map"
    if (source2TargetMap.empty()
        || source2TargetMap.back().distrMapIndex != distrMapIndex) {
      source2TargetMap.push_back(Source2TargetMapItem(startId, distrMapIndex));
      if (source2TargetMap.size() * sizeof(source2TargetMap[0])
          > (maxBaseId - minBaseId + 1) * sizeof(source2TargetVector[0])) {
        // convert "map" to vector
        source2TargetVector.resize(maxBaseId - minBaseId + 1);
        vector<Source2TargetMapItem>::const_iterator mapIt = source2TargetMap
            .begin();
        size_t seqBegin = mapIt->sourceRangeBegin - minBaseId;
        do {
          size_t seqEnd;
          uint32_t dmIndex = mapIt->distrMapIndex;
          if (++mapIt == source2TargetMap.end()) {
            seqEnd = maxBaseId - minBaseId + 1;
          } else {
            seqEnd = mapIt->sourceRangeBegin - minBaseId;
          }
          std::fill(&source2TargetVector[seqBegin],
                    &source2TargetVector[0] + seqEnd, dmIndex);
          seqBegin = seqEnd;
        } while (mapIt != source2TargetMap.end());
        source2TargetMap.clear();
      }
    }
  } else {
    // update vector
    size_t fillEnd = min(maxBaseId + 1, nextStartId);
    std::fill(&source2TargetVector[startId - minBaseId],
              &source2TargetVector[0] + fillEnd - minBaseId, distrMapIndex);
  }
  return distrMapIndex;
}
size_t RollbackStorage::getSize(const IdentifiersType &path, const CellValue &val)
{
	return (path.size() * sizeof(IdentifierType)) + sizeof(CellValue) + (val.isString() ? val.length() : 0);
}