Java Code Examples for com.indeed.util.io.Files#buildPath()
The following examples show how to use
com.indeed.util.io.Files#buildPath() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MMapGOV4Function.java From mph-table with Apache License 2.0 | 6 votes |
public static <T> void writeTo(final GOV4Function<T> gov4Function, final String path) throws NoSuchFieldException, IllegalAccessException, IOException { final Field dataField = gov4Function.getClass().getDeclaredField("data"); dataField.setAccessible(true); final AbstractBitVector.LongBigListView signaturesData = (AbstractBitVector.LongBigListView) dataField.get(gov4Function); final Field bitVectorField = signaturesData.getClass().getDeclaredField("bitVector"); bitVectorField.setAccessible(true); final BitVector bitVector = (BitVector)bitVectorField.get(signaturesData); try (final LittleEndianDataOutputStream outputStream = new LittleEndianDataOutputStream( new BufferedOutputStream(new FileOutputStream(Files.buildPath(path, "signatures.bin"))))) { for (final long value : bitVector.bits()) { outputStream.writeLong(value); } } dataField.set(gov4Function, null); try (final OutputStream outputStream = new FileOutputStream(Files.buildPath(path, "GOV4Function.bin")); final ObjectOutput objectOutput = new ObjectOutputStream(outputStream)) { objectOutput.writeObject(gov4Function); } }
Example 2
Source File: MMapGOV4Function.java From mph-table with Apache License 2.0 | 6 votes |
public static <T> MMapGOV4Function<T> readFrom(final String path) throws IOException, NoSuchFieldException, IllegalAccessException, ClassNotFoundException { final GOV4Function<T> gov4Function; try (final InputStream file = new FileInputStream(Files.buildPath(path, "GOV4Function.bin")); final ObjectInput input = new ObjectInputStream(file)) { gov4Function = (GOV4Function<T>)(input.readObject()); } final Field widthField = gov4Function.getClass().getDeclaredField("width"); widthField.setAccessible(true); final int width = (Integer) widthField.get(gov4Function); final MMapBuffer buffer = new MMapBuffer(new File(Files.buildPath(path, "signatures.bin")), FileChannel.MapMode.READ_ONLY, ByteOrder.LITTLE_ENDIAN); final MMapLongBigList signaturesData = new MMapLongBigList(buffer.memory().longArray(0, buffer.memory().length() / 8), width); final Field dataField = gov4Function.getClass().getDeclaredField("data"); dataField.setAccessible(true); dataField.set(gov4Function, signaturesData); return new MMapGOV4Function<>(gov4Function, buffer, width); }
Example 3
Source File: GenericFlamdexReader.java From imhotep with Apache License 2.0 | 5 votes |
@Override public IntTermIterator getIntTermIterator(String field) { final String termsFilename = Files.buildPath(directory, factory.getIntTermsFilename(field)); final String docsFilename = Files.buildPath(directory, factory.getIntDocsFilename(field)); try { return factory.createIntTermIterator(termsFilename, docsFilename); } catch (IOException e) { throw new RuntimeException(e); } }
Example 4
Source File: GenericFlamdexReader.java From imhotep with Apache License 2.0 | 5 votes |
@Override public StringTermIterator getStringTermIterator(String field) { final String termsFilename = Files.buildPath(directory, factory.getStringTermsFilename(field)); final String docsFilename = Files.buildPath(directory, factory.getStringDocsFilename(field)); try { return factory.createStringTermIterator(termsFilename, docsFilename); } catch (IOException e) { throw new RuntimeException(e); } }
Example 5
Source File: SimpleFlamdexReader.java From imhotep with Apache License 2.0 | 5 votes |
protected static void buildIntBTrees(final String directory, final List<String> intFields) throws IOException { for (final String intField : intFields) { final File btreeDir = new File(Files.buildPath(directory, "fld-" + intField + ".intindex")); final File btreeDir64 = new File(Files.buildPath(directory, "fld-" + intField + ".intindex64")); if (!btreeDir.exists() && !btreeDir64.exists()) { SimpleFlamdexWriter.writeIntBTree(directory, intField, btreeDir64); } } }
Example 6
Source File: SimpleFlamdexReader.java From imhotep with Apache License 2.0 | 5 votes |
protected static void buildStringBTrees(final String directory, final List<String> stringFields) throws IOException { for (final String stringField : stringFields) { final File btreeDir = new File(Files.buildPath(directory, "fld-" + stringField + ".strindex")); if (!btreeDir.exists()) { SimpleFlamdexWriter.writeStringBTree(directory, stringField, btreeDir); } } }
Example 7
Source File: SimpleStringFieldWriter.java From imhotep with Apache License 2.0 | 4 votes |
public static SimpleStringFieldWriter open(String outputDirectory, String field, long numDocs, boolean writeBTreesOnClose) throws FileNotFoundException { final OutputStream termsOutput = new BufferedOutputStream(new FileOutputStream(Files.buildPath(outputDirectory, getTermsFilename(field))), 65536); final OutputStream docsOutput = new BufferedOutputStream(new FileOutputStream(Files.buildPath(outputDirectory, getDocsFilename(field))), 65536); return new SimpleStringFieldWriter(outputDirectory, field, writeBTreesOnClose, termsOutput, docsOutput, numDocs); }
Example 8
Source File: SimpleIntFieldWriter.java From imhotep with Apache License 2.0 | 4 votes |
public static SimpleIntFieldWriter open(String outputDirectory, String field, long numDocs, boolean writeBTreesOnClose) throws FileNotFoundException { final OutputStream termsOutput = new BufferedOutputStream(new FileOutputStream(Files.buildPath(outputDirectory, getTermsFilename(field))), 65536); final OutputStream docsOutput = new BufferedOutputStream(new FileOutputStream(Files.buildPath(outputDirectory, getDocsFilename(field))), 65536); return new SimpleIntFieldWriter(outputDirectory, field, writeBTreesOnClose, termsOutput, docsOutput, numDocs); }