Exemple #1
0
    /**
     * @see PhysicalOperator::execute
     */
    shared_ptr<Array> execute(vector< shared_ptr<Array> >& inputArrays, shared_ptr<Query> query)
    {
        assert(inputArrays.size() == 1);
        shared_ptr<Array>& srcArray = inputArrays[0];
        ArrayDesc const& srcArrayDesc = srcArray->getArrayDesc();

        Attributes const& destAttrs = _schema.getAttributes(true); // true = exclude empty tag.
        Dimensions const& destDims = _schema.getDimensions();

        vector<AggregatePtr> aggregates (destAttrs.size());
        vector<size_t> attrMapping(destAttrs.size());
        vector<size_t> dimMapping(_schema.getDimensions().size());

        setupMappings(srcArrayDesc, aggregates, attrMapping, dimMapping, destAttrs, destDims);
        ElapsedMilliSeconds timing;

        RedistributeMode redistributeMode(AUTO);
        if (haveAggregatesOrSynthetic(srcArrayDesc)) {
            //XXX TODO: until redistributeAggregate() is cut over to pullRedistribute(),
            // the aggreagted SG does not enforce data integrity
            redistributeMode = AGGREGATED;
        } else if ( isStrict()) {
            redistributeMode = VALIDATED;
        }
        return redimensionArray(srcArray,
                                attrMapping,
                                dimMapping,
                                aggregates,
                                query,
                                timing,
                                redistributeMode);
    }
Exemple #2
0
 /**
  * @see PhysicalOperator::getOutputDistribution
  */
 virtual ArrayDistribution getOutputDistribution(std::vector<ArrayDistribution> const& inputDistros,
                                                 std::vector< ArrayDesc> const& inputSchemas) const
 {
     if (haveAggregatesOrSynthetic(inputSchemas[0]) ||
         isStrict()) {
         return ArrayDistribution(psHashPartitioned);
     }
     return ArrayDistribution(psUndefined);
 }
Exemple #3
0
	void serialize(Archive& ar, const uint32 ver) {
		ensure_msg(!isStrict(), "Strict handle node-serialization not yet supported");
		if (Archive::is_saving::value) {
			game::WorldEntityId id= getId();
			ar & id;
		} else {
			game::WorldEntityId id;
			ar & id;
			setId(id);
		}
	}
Exemple #4
0
// read numner at file pos
bool
CJson::
readNumber(CStrParse &parse, std::string &str1)
{
  if (parse.eof())
    return false;

  if (parse.isChar('-'))
    str1 += parse.readChar();

  // TODO: octal, hexadecimal
  if      (parse.isChar('0'))
    str1 += parse.readChar();
  else if (parse.isDigit()) {
    while (parse.isDigit())
      str1 += parse.readChar();
  }
  else
    return false;

  if (parse.isChar('.')) {
    str1 += parse.readChar();

    if (isStrict()) {
      if (! parse.isDigit())
        return false;
    }

    while (parse.isDigit())
      str1 += parse.readChar();
  }

  // [Ee][+-][0-9][0-9]*
  if (parse.isOneOf("eE")) {
    str1 += parse.readChar();

    if (parse.isOneOf("+-"))
      str1 += parse.readChar();

    if (! parse.isDigit())
      return false;

    while (parse.isDigit())
      str1 += parse.readChar();
  }

  return true;
}
Exemple #5
0
/* Copy a string token into the given UnicodeString.  Upon entry, we
   have already read the first character of the string token, which is
   not a whitespace character (but may be a QUOTE or ESCAPE). This
   function reads all subsequent characters that belong with this
   string, and copy them into the token parameter. The other
   important, and slightly convoluted purpose of this function is to
   merge adjacent strings.  It looks forward a bit, and if the next
   non comment, non whitespace item is a string, it reads it in as
   well.  If two adjacent strings are quoted, they are merged without
   intervening space.  Otherwise a single SPACE character is
   inserted. */
static enum ETokenType getStringToken(UCHARBUF* buf,
                                      UChar32 initialChar,
                                      struct UString *token,
                                      UErrorCode *status) {
    UBool    lastStringWasQuoted;
    UChar32  c;
    UChar    target[3] = { '\0' };
    UChar    *pTarget   = target;
    int      len=0;
    UBool    isFollowingCharEscaped=FALSE;
    UBool    isNLUnescaped = FALSE;
    UChar32  prevC=0;

    /* We are guaranteed on entry that initialChar is not a whitespace
       character. If we are at the EOF, or have some other problem, it
       doesn't matter; we still want to validly return the initialChar
       (if nothing else) as a string token. */

    if (U_FAILURE(*status)) {
        return TOK_ERROR;
    }

    /* setup */
    lastStringWasQuoted = FALSE;
    c = initialChar;
    ustr_setlen(token, 0, status);

    if (U_FAILURE(*status)) {
        return TOK_ERROR;
    }

    for (;;) {
        if (c == QUOTE) {
            if (!lastStringWasQuoted && token->fLength > 0) {
                ustr_ucat(token, SPACE, status);

                if (U_FAILURE(*status)) {
                    return TOK_ERROR;
                }
            }

            lastStringWasQuoted = TRUE;

            for (;;) {
                c = ucbuf_getc(buf,status);

                /* EOF reached */
                if (c == U_EOF) {
                    return TOK_EOF;
                }

                /* Unterminated quoted strings */
                if (U_FAILURE(*status)) {
                    return TOK_ERROR;
                }

                if (c == QUOTE && !isFollowingCharEscaped) {
                    break;
                }

                if (c == ESCAPE  && !isFollowingCharEscaped) {
                    pTarget = target;
                    c       = unescape(buf, status);

                    if (c == U_ERR) {
                        return TOK_ERROR;
                    }
                    if(c == CR || c == LF){
                        isNLUnescaped = TRUE;
                    }
                }               

                if(c==ESCAPE && !isFollowingCharEscaped){
                    isFollowingCharEscaped = TRUE;
                }else{
                    U_APPEND_CHAR32(c, pTarget,len);
                    pTarget = target;
                    ustr_uscat(token, pTarget,len, status);
                    isFollowingCharEscaped = FALSE;
                    len=0;
                    if(c == CR || c == LF){
                        if(isNLUnescaped == FALSE && prevC!=CR){
                            lineCount++;
                        }
                        isNLUnescaped = FALSE;
                    }
                }
                
                if (U_FAILURE(*status)) {
                    return TOK_ERROR;
                }
                prevC = c;
            }
        } else {
            if (token->fLength > 0) {
                ustr_ucat(token, SPACE, status);

                if (U_FAILURE(*status)) {
                    return TOK_ERROR;
                }
            }
            
            if(lastStringWasQuoted){
                if(getShowWarning()){
                    warning(lineCount, "Mixing quoted and unquoted strings");
                }
                if(isStrict()){
                    return TOK_ERROR;
                }

            }

            lastStringWasQuoted = FALSE;
            
            /* if we reach here we are mixing 
             * quoted and unquoted strings
             * warn in normal mode and error in
             * pedantic mode
             */

            if (c == ESCAPE) {
                pTarget = target;
                c       = unescape(buf, status);

                /* EOF reached */
                if (c == U_EOF) {
                    return TOK_ERROR;
                }
            }

            U_APPEND_CHAR32(c, pTarget,len);
            pTarget = target;
            ustr_uscat(token, pTarget,len, status);
            len=0;
            
            if (U_FAILURE(*status)) {
                return TOK_ERROR;
            }

            for (;;) {
                /* DON'T skip whitespace */
                c = getNextChar(buf, FALSE, NULL, status);

                /* EOF reached */
                if (c == U_EOF) {
                    ucbuf_ungetc(c, buf);
                    return TOK_STRING;
                }

                if (U_FAILURE(*status)) {
                    return TOK_STRING;
                }

                if (c == QUOTE
                        || c == OPENBRACE
                        || c == CLOSEBRACE
                        || c == COMMA
                        || c == COLON) {
                    ucbuf_ungetc(c, buf);
                    break;
                }

                if (isWhitespace(c)) {
                    break;
                }

                if (c == ESCAPE) {
                    pTarget = target;
                    c       = unescape(buf, status);

                    if (c == U_ERR) {
                        return TOK_ERROR;
                    }
                }

                U_APPEND_CHAR32(c, pTarget,len);
                pTarget = target;
                ustr_uscat(token, pTarget,len, status);
                len=0;
                if (U_FAILURE(*status)) {
                    return TOK_ERROR;
                }
            }
        }

        /* DO skip whitespace */
        c = getNextChar(buf, TRUE, NULL, status);

        if (U_FAILURE(*status)) {
            return TOK_STRING;
        }

        if (c == OPENBRACE || c == CLOSEBRACE || c == COMMA || c == COLON) {
            ucbuf_ungetc(c, buf);
            return TOK_STRING;
        }
    }
}
Exemple #6
0
 /**
  * @see PhysicalOperator::outputFullChunks
  */
 virtual bool outputFullChunks(std::vector< ArrayDesc> const& inputSchemas) const
 {
     return (isStrict() || haveAggregatesOrSynthetic(inputSchemas[0]));
 }
Exemple #7
0
// read string at file pos
bool
CJson::
readString(CStrParse &parse, std::string &str1)
{
  if (! parse.isChar('\"'))
    return false;

  parse.skipChar();

  while (! parse.eof()) {
    if      (parse.isChar('\\') && ! parse.neof(1)) {
      parse.skipChar();

      char c = parse.readChar();

      switch (c) {
        case '\"': str1 += '\"'; break;
        case '\\': str1 += '\\'; break;
        case '/' : str1 += '/' ; break;
        case 'b' : str1 += '\b'; break;
        case 'f' : str1 += '\f'; break;
        case 'n' : str1 += '\n'; break;
        case 'r' : str1 += '\r'; break;
        case 't' : str1 += '\t'; break;
        case 'u' : {
          // 4 hexadecimal digits
          long i = 0;

          for (int j = 0; j < 4; ++j) {
            if (! parse.isXDigit())
              return false;

            char c = parse.readChar();

            i = (i << 4) | (hexCharValue(c) & 0xF);
          }

          CUtf8::append(str1, i);

          break;
        }
        default: {
          if (isStrict())
            return false;

          str1 += c;

          break;
        }
      }
    }
    else if (parse.isChar('\"'))
      break;
    else
      str1 += parse.readChar();
  }

  if (parse.eof() || ! parse.isChar('\"'))
    return false;

  parse.skipChar();

  return true;
}