Example #1
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();
}
Example #2
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);
  }
}
Example #3
0
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;
		}
	}
}
Example #4
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;
}
Example #5
0
size_t RollbackStorage::getSize(const IdentifiersType &path, const CellValue &val)
{
	return (path.size() * sizeof(IdentifierType)) + sizeof(CellValue) + (val.isString() ? val.length() : 0);
}