Package org.apache.s4.schema

Examples of org.apache.s4.schema.Schema


        long eventTime = -1;
        String streamName = eventWrapper.getStreamName();
        String fieldName = eventClockStreamsMap.get(streamName);
        if (fieldName != null) {
            Object event = eventWrapper.getEvent();
            Schema schema = schemaContainer.getSchema(event.getClass());
            Property property = schema.getProperties().get(fieldName);
            if (property != null
                    && (property.getType().equals(Long.TYPE) || property
                            .getType().equals(Long.class))) {
                try {
                    eventTime = (Long) property.getGetterMethod().invoke(event);
View Full Code Here


                JSONObject jsonEventTypeInfo = classInfo.getJSONObject(className);
                int classIndex = (Integer) jsonEventTypeInfo.getInt("classIndex");
                String streamName = jsonEventTypeInfo.getString("streamName");

                Class clazz = Class.forName(className);
                Schema schema = new Schema(clazz);
                eventTypeInfoMap.put(classIndex, new EventTypeInfo(schema,
                                                                   streamName));
            }
        } catch (JSONException je) {
            je.printStackTrace();
View Full Code Here

            } catch (Exception e) {
                e.printStackTrace();
                throw new RuntimeException(e);
            }

            Schema newEventSchema = schemaContainer.getSchema(newEvent.getClass());

            for (String streamName : eventsToJoin.keySet()) {
                Object partialEvent = eventsToJoin.get(streamName);
                Schema partialEventSchema = schemaContainer.getSchema(partialEvent.getClass());

                List<String> includeFields = eventFields.get(streamName);
                if (includeFields.size() == 1
                        && includeFields.get(0).equals("*")) {
                    for (Property partialEventProperty : partialEventSchema.getProperties()
                                                                           .values()) {
                        copyField(partialEventProperty.getName(),
                                  partialEventSchema,
                                  newEventSchema,
                                  partialEvent,
View Full Code Here

        }

        // have to compute key value and
        // partition based on hash of that value

        Schema schema = schemaContainer.getSchema(event.getClass());

        if (debug) {
            System.out.println(schema);
        }

        List<CompoundKeyInfo> partitionInfoList = new ArrayList<CompoundKeyInfo>();

        // fast path for single top-level key
        if (fastPath
                || (compoundKeyNames.size() == 1 && compoundKeyNames.get(0)
                                                                    .size() == 1)) {
            String simpleKeyName = compoundKeyNames.get(0).get(0);
            if (debug) {
                System.out.println("Using fast path!");
            }
            fastPath = true;
            KeyInfo keyInfo = new KeyInfo();
            Property property = schema.getProperties().get(simpleKeyName);
            if (property == null) {
                return null;
            }

            Object value = null;
View Full Code Here

        }
        if (property.isList()) {
            List list = (List) value;
            // TODO: handle case where key does not include property of
            // component type
            Schema componentSchema = property.getComponentProperty()
                                             .getSchema();
            int listLength = list.size();
            for (int i = 0; i < listLength; i++) {
                Object listEntry = list.get(i);
                KeyInfo keyInfoForListEntry = keyInfo.copy();
View Full Code Here

    }

    public void injectValueEvent(KeyValue keyValue, String streamName,
            int partitionId) throws JSONException {

        Schema schema = new Schema(KeyValue.class);
        JSONObject jsonRecord = new JSONObject("{key:" + keyValue.getKey()
                + ",value:" + keyValue.getValue() + "}");
        Object event = LoadGenerator.makeRecord(jsonRecord, schema);
        CompoundKeyInfo compoundKeyInfo = new CompoundKeyInfo();
        compoundKeyInfo.setCompoundKey("key");
View Full Code Here

    public void processEvent(Object event) {
        long currentTime = getCurrentTime();
        long maybeCurrentTime = -1;
        if (timestampFields != null) {
            Schema schema = schemaContainer.getSchema(event.getClass());
            String fieldName = timestampFields.get(getStreamName());
            if (fieldName != null) {
                Property property = schema.getProperties().get(fieldName);
                if (property != null
                        && (property.getType().equals(Long.TYPE) || property.getType()
                                                                            .equals(Long.class))) {
                    try {
                        maybeCurrentTime = (Long) property.getGetterMethod()
View Full Code Here

            return;
        }

        keyValue = new ArrayList<Object>();

        Schema schema = schemaContainer.getSchema(event.getClass());

        // get the value for each keyInfo
        for (KeyInfo keyInfo : compoundKeyInfo.getKeyInfoList()) {
            Object value = null;
            Object record = event;
            List<?> list = null;
            Property property = null;
            for (KeyPathElement keyPathElement : keyInfo.getKeyPath()) {
                if (keyPathElement instanceof KeyPathElementIndex) {
                    record = list.get(((KeyPathElementIndex) keyPathElement).getIndex());
                    schema = property.getComponentProperty().getSchema();
                } else {
                    String keyPathElementName = ((KeyPathElementName) keyPathElement).getKeyName();
                    property = schema.getProperties().get(keyPathElementName);
                    value = null;
                    try {
                        value = property.getGetterMethod().invoke(record);
                    } catch (Exception e) {
                        Logger.getLogger("s4").error(e);
View Full Code Here

            }
            traceSystem = new TraceSystem(null);
            trace = traceSystem.getTrace(Trace.DATABASE);
        }
        systemUser = new User(this, 0, SYSTEM_USER_NAME, true);
        mainSchema = new Schema(this, 0, Constants.SCHEMA_MAIN, systemUser, true);
        infoSchema = new Schema(this, -1, "INFORMATION_SCHEMA", systemUser, true);
        schemas.put(mainSchema.getName(), mainSchema);
        schemas.put(infoSchema.getName(), infoSchema);
        publicRole = new Role(this, 0, Constants.PUBLIC_ROLE_NAME, true);
        roles.put(Constants.PUBLIC_ROLE_NAME, publicRole);
        systemUser.setAdmin(true);
View Full Code Here

     *
     * @param schemaName the name of the schema
     * @return the schema or null
     */
    public Schema findSchema(String schemaName) {
        Schema schema = schemas.get(schemaName);
        if (schema == infoSchema) {
            initMetaTables();
        }
        return schema;
    }
View Full Code Here

TOP

Related Classes of org.apache.s4.schema.Schema

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.