Package org.lilyproject.repository.bulk

Examples of org.lilyproject.repository.bulk.LineMapper


        }
        long start = System.currentTimeMillis();
        int numLines = 0;

        try {
            LineMapper lineMapper = new JythonLineMapper(Files.toString(new File(pythonMapperPath), Charsets.UTF_8),
                    pythonSymbol);
            LineMappingContext mappingContext = new LineMappingContext(bulkIngester, recordWriter);
            String line;
            while ((line = bufferedReader.readLine()) != null) {
                lineMapper.mapLine(line, mappingContext);
                numLines++;
            }
        } catch (PyException pe) {
            pe.printStackTrace();    // Print the Jython-native stack trace
            log.error("Exception encountered in Python code", pe);
View Full Code Here


        when(mappingContext.newRecordId()).thenReturn(recordId);
    }

    @Test
    public void testMap_SimpleCase() throws RecordException, IOException, InterruptedException {
        LineMapper lineMapper = new JythonLineMapper(pythonCode, "singleFieldRecord");
       
        QName stringFieldName = QName.fromString("{org.lilyproject}Name");
        QName intFieldName = QName.fromString("{org.lilyproject}IntField");
        QName recordTypeName = QName.fromString("{org.lilyproject}NameRecord");
       
        when(mappingContext.qn("{org.lilyproject}Name")).thenReturn(stringFieldName);
        when(mappingContext.qn("{org.lilyproject}IntField")).thenReturn(intFieldName);
        when(mappingContext.qn("{org.lilyproject}NameRecord")).thenReturn(recordTypeName);
       
        lineMapper.mapLine("nameValue", mappingContext);
       
        verify(record).setField(stringFieldName, "nameValue");
        verify(record).setField(intFieldName, 42);
        verify(record).setRecordType(recordTypeName);
        verify(mappingContext).writeRecord(record);
View Full Code Here

        verify(mappingContext).writeRecord(record);
    }
   
    @Test
    public void testMap_SimpleCase_WithInstance() throws RecordException, IOException, InterruptedException {
        LineMapper lineMapper = new JythonLineMapper(pythonCode, "mapperInstanceMethod");
       
        QName fieldName = QName.fromString("{org.lilyproject}Name");
        QName recordTypeName = QName.fromString("{org.lilyproject}NameRecord");
       
        when(mappingContext.qn("{org.lilyproject}Name")).thenReturn(fieldName);
        when(mappingContext.qn("{org.lilyproject}NameRecord")).thenReturn(recordTypeName);
       
        lineMapper.mapLine("nameValue", mappingContext);
       
        verify(record).setField(fieldName, "nameValue");
        verify(record).setRecordType(recordTypeName);
        verify(mappingContext).writeRecord(record);
    }
View Full Code Here

        verify(mappingContext).writeRecord(record);
    }
   
    @Test
    public void testMap_NullFromJythonMapper() throws IOException, InterruptedException {
        LineMapper lineMapper = new JythonLineMapper(pythonCode, "mapsNothing");
        lineMapper.mapLine("inputValue", mappingContext);
        verify(mappingContext, never()).writeRecord(any(Record.class));
    }
View Full Code Here

TOP

Related Classes of org.lilyproject.repository.bulk.LineMapper

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.