@Ignore public class InputFormatTest { public static final SopremoRecordLayout NULL_LAYOUT = SopremoRecordLayout.create(); public static Collection<IJsonNode> readFromFile( final File file, final SopremoFormat format, final SopremoRecordLayout layout) throws IOException { Configuration config = new Configuration(); final EvaluationContext context = new EvaluationContext(); SopremoUtil.setEvaluationContext(config, context); SopremoUtil.setLayout(config, layout); SopremoUtil.transferFieldsToConfiguration( format, SopremoFormat.class, config, format.getInputFormat(), InputFormat.class); @SuppressWarnings("unchecked") final SopremoFileInputFormat inputFormat = FormatUtil.openInput( (Class<? extends SopremoFileInputFormat>) format.getInputFormat(), file.toURI().toString(), config); List<IJsonNode> values = new ArrayList<IJsonNode>(); while (!inputFormat.reachedEnd()) { final SopremoRecord record = new SopremoRecord(layout); if (inputFormat.nextRecord(record)) values.add(record.getNode().clone()); } inputFormat.close(); return values; } }
public static final TypeConfig<SopremoRecord> getTypeConfig(SopremoRecordLayout layout) { final TypeConfig<SopremoRecord> typeConfig; final TypeStringifier<SopremoRecord> typeStringifier = DefaultStringifier.get(); final Equaler<SopremoRecord> equaler = DefaultEqualer.get(); final int[] keys = new int[layout.getNumKeys()]; for (int index = 0; index < keys.length; index++) keys[index] = index; final boolean[] ascending = new boolean[keys.length]; Arrays.fill(ascending, true); typeConfig = new TypeConfig<SopremoRecord>( new SopremoRecordComparatorFactory(layout, keys, ascending), SopremoRecordPairComparatorFactory.get(), new SopremoRecordSerializerFactory(layout), typeStringifier, new SopremoKeyExtractor( layout.getKeyExpressions().toArray(new EvaluationExpression[0])), equaler); return typeConfig; }