Package org.json_voltpatches

Examples of org.json_voltpatches.JSONArray


    }

    @Override
    public void loadFromJSONObject( JSONObject jobj, Database db ) throws JSONException {
        helpLoadFromJSONObject(jobj, db);
        JSONArray jarray = jobj.getJSONArray( Members.AGGREGATE_COLUMNS.name() );
        int size = jarray.length();
        for (int i = 0; i < size; i++) {
            JSONObject tempObj = jarray.getJSONObject( i );
            m_aggregateTypes.add( ExpressionType.get( tempObj.getString( Members.AGGREGATE_TYPE.name() )));
            m_aggregateDistinct.add( tempObj.getInt( Members.AGGREGATE_DISTINCT.name() ) );
            m_aggregateOutputColumns.add( tempObj.getInt( Members.AGGREGATE_OUTPUT_COLUMN.name() ));

            if (jobj.isNull(Members.AGGREGATE_EXPRESSION.name())) {
                m_aggregateExpressions.add(null);
            }
            else {
                m_aggregateExpressions.add(
                    AbstractExpression.fromJSONChild(tempObj, Members.AGGREGATE_EXPRESSION.name()));
            }
        }
        AbstractExpression.loadFromJSONArrayChild(m_groupByExpressions, jobj,
                                                  Members.GROUPBY_EXPRESSIONS.name(), null);

        if ( ! jobj.isNull(Members.PARTIAL_GROUPBY_COLUMNS.name())) {
            JSONArray jarray2 = jobj.getJSONArray(Members.PARTIAL_GROUPBY_COLUMNS.name());
            int numCols = jarray2.length();
            m_partialGroupByColumns = new ArrayList<>(numCols);
            for (int ii = 0; ii < numCols; ++ii) {
                m_partialGroupByColumns.add(jarray2.getInt(ii));
            }
        }

        m_prePredicate = AbstractExpression.fromJSONChild(jobj, Members.PRE_PREDICATE.name());
        m_postPredicate = AbstractExpression.fromJSONChild(jobj, Members.POST_PREDICATE.name());
View Full Code Here


    protected final void helpLoadFromJSONObject( JSONObject jobj, Database db ) throws JSONException {
        assert( jobj != null );
        m_id = jobj.getInt( Members.ID.name() );

        JSONArray jarray = null;
        //load inline nodes
        if( !jobj.isNull( Members.INLINE_NODES.name() ) ){
            jarray = jobj.getJSONArray( Members.INLINE_NODES.name() );
            PlanNodeTree pnt = new PlanNodeTree();
            pnt.loadFromJSONArray(jarray, db);
            List<AbstractPlanNode> list = pnt.getNodeList();
            for( AbstractPlanNode pn : list ) {
                m_inlineNodes.put( pn.getPlanNodeType(), pn);
            }
        }
        //children and parents list loading implemented in planNodeTree.loadFromJsonArray

        // load the output schema if it was marked significant.
        if ( !jobj.isNull( Members.OUTPUT_SCHEMA.name() ) ) {
            m_outputSchema = new NodeSchema();
            m_hasSignificantOutputSchema = true;
            jarray = jobj.getJSONArray( Members.OUTPUT_SCHEMA.name() );
            int size = jarray.length();
            for( int i = 0; i < size; i++ ) {
                m_outputSchema.addColumn( SchemaColumn.fromJSONObject(jarray.getJSONObject(i)) );
            }
        }
    }
View Full Code Here

    @Override
    public void loadFromJSONObject( JSONObject jobj, Database db ) throws JSONException {
        super.loadFromJSONObject(jobj, db);
        m_multiPartition = jobj.getBoolean( Members.MULTI_PARTITION.name() );
        if (!jobj.isNull(Members.FIELD_MAP.name())) {
            JSONArray jarray = jobj.getJSONArray(Members.FIELD_MAP.name());
            int numFields = jarray.length();
            m_fieldMap = new int[numFields];
            for (int i = 0; i < numFields; ++i) {
                m_fieldMap[i] = jarray.getInt(i);
            }
        }

        m_isUpsert = false;
        if (jobj.has(Members.UPSERT.name())) {
View Full Code Here

        m_wherePredicate = AbstractExpression.fromJSONChild(jobj, Members.WHERE_PREDICATE.name());

        if ( !jobj.isNull( Members.OUTPUT_SCHEMA_PRE_AGG.name() ) ) {
            m_outputSchemaPreInlineAgg = new NodeSchema();
            m_hasSignificantOutputSchema = true;
            JSONArray jarray = jobj.getJSONArray( Members.OUTPUT_SCHEMA_PRE_AGG.name() );
            int size = jarray.length();
            for( int i = 0; i < size; i++ ) {
                m_outputSchemaPreInlineAgg.addColumn( SchemaColumn.fromJSONObject(jarray.getJSONObject(i)) );
            }
        } else {
            m_outputSchemaPreInlineAgg = m_outputSchema;
        }
    }
View Full Code Here

    }

    @Override
    public void loadFromJSONObject( JSONObject jobj, Database db ) throws JSONException {
        helpLoadFromJSONObject(jobj, db);
        JSONArray jarray = null;
        if( !jobj.isNull(Members.SORT_COLUMNS.name()) ){
            jarray = jobj.getJSONArray( Members.SORT_COLUMNS.name() );
        }
        int size = jarray.length();
        for( int i = 0; i < size; i++ ) {
            JSONObject tempObj = jarray.getJSONObject(i);
            m_sortDirections.add( SortDirectionType.get(tempObj.getString( Members.SORT_DIRECTION.name())) );
            m_sortExpressions.add( AbstractExpression.fromJSONChild(tempObj, Members.SORT_EXPRESSION.name()) );
        }
    }
View Full Code Here

            //link children and parents
            for( int i = 0; i < size; i++ ) {
                JSONObject jobj;
                jobj = jArray.getJSONObject(i);
                if (jobj.has("CHILDREN_IDS")) {
                    JSONArray children = jobj.getJSONArray("CHILDREN_IDS");
                    for( int j = 0; j < children.length(); j++ ) {
                        m_planNodes.get(i).addAndLinkChild( getNodeofId( children.getInt(j) ) );
                    }
                }
            }
        }
        catch (JSONException e) {
View Full Code Here

    private List<String> getLogPaths(String voltDbRootPath) throws Exception {
        File configLogDir = new File(voltDbRootPath, "config_log");
        File configInfo = new File(configLogDir, "config.json");
        JSONObject jsonObject = Collector.parseJSONFile(configInfo.getCanonicalPath());
        List<String> logPaths = new ArrayList<String>();
        JSONArray jsonArray = jsonObject.getJSONArray("log4jDst");
        for (int i = 0; i < jsonArray.length(); i++) {
            String path = jsonArray.getJSONObject(i).getString("path");
            logPaths.add(path);
        }
        return logPaths;
    }
View Full Code Here

    private void createLogFiles() throws Exception {

        try {
           String configInfoPath = voltDbRootPath + File.separator + "config_log" + File.separator + "config.json";;
           JSONObject jsonObject= Collector.parseJSONFile(configInfoPath);
           JSONArray jsonArray = jsonObject.getJSONArray("log4jDst");

           //maintain the file naming format
           String fileNamePrefix = "volt-junit-fulllog.txt.";
           String fileText = "This is a dummy log file.";
           String workingDir = getWorkingDir(voltDbRootPath);
           VoltFile logFolder = new VoltFile(workingDir + "/obj/release/testoutput/");
           logFolder.mkdir();

           for(File oldLogFile : logFolder.listFiles()) {
               if(oldLogFile.getName().startsWith(fileNamePrefix)) {
                   oldLogFile.delete();
               }
           }

           SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
           String[] fileDates = new String[6];
           Calendar cal, cal2;
           cal = Calendar.getInstance();
           cal2 = Calendar.getInstance();
           for(int i=-1; i < 2; i++) {
               cal.add(Calendar.DATE, -i-1);
               fileDates[i+1] = formatter.format(cal.getTime());
           }
           cal = Calendar.getInstance();
           cal.add(Calendar.YEAR, -1);
           cal2.set(cal.get(Calendar.YEAR), 11, 31);
           fileDates[3] = formatter.format(cal2.getTime());
           cal2.add(Calendar.DATE, -4);
           fileDates[4] = formatter.format(cal2.getTime());
           cal2 = Calendar.getInstance();
           cal2.set(cal2.get(Calendar.YEAR), 0, 02);
           fileDates[5] = formatter.format(cal2.getTime());

           for(String fileDate: fileDates) {
               VoltFile file = new VoltFile(logFolder, fileNamePrefix + fileDate);
               file.createNewFile();

               BufferedWriter writer = new BufferedWriter(new FileWriter(file.getAbsolutePath()));
               writer.write(fileText);
               writer.close();

               formatter.format(file.lastModified());
               file.setLastModified(formatter.parse(fileDate).getTime());

               JSONObject object = new JSONObject();
               object.put("path", file.getCanonicalPath());
               object.put("format", "'.'" + fileDate);
               jsonArray.put(object);
           }
           FileOutputStream fos = new FileOutputStream(configInfoPath);
           fos.write(jsonObject.toString(4).getBytes(Charsets.UTF_8));
           fos.close();
        } catch (JSONException e) {
View Full Code Here

        return new ParameterSet(params, size, encodedStrings, encodedStringArrays);
    }

    public static ParameterSet fromJSONString(String json) throws JSONException, IOException {
        JSONArray jArray = new JSONArray(json);
        return fromJSONArray(jArray);
    }
View Full Code Here

        if (value instanceof JSONObject) {
            JSONObject jsonObj = (JSONObject) value;
            return VoltTable.fromJSONObject(jsonObj);
        }
        if (value instanceof JSONArray) {
            JSONArray array = (JSONArray) value;
            Object[] retval = new Object[array.length()];
            for (int i = 0; i < array.length(); i++) {
                Object valueAtIndex = array.get(i);
                retval[i] = paramFromPossibleJSON(valueAtIndex);
            }
            return retval;
        }
        return value;
View Full Code Here

TOP

Related Classes of org.json_voltpatches.JSONArray

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.