public static DPSegment open(int version, SegmentMode mode, Path path, String name, SegmentSchema schema, OpenOption... options) throws IOException {
        //Preconditions.checkArgument(name != null);
        Preconditions.checkArgument(path != null);

        if (OpenOption.Overwrite.in(options)) {
            FileUtils.deleteDirectory(path.toFile());
        }

        if (!Files.exists(path)) {
            Files.createDirectories(path);
        }

        Metadata metadata;
        SegmentSchema segmentSchema;

        Path metadataPath = path.resolve("metadata.json");
        Path schemaPath = path.resolve("schema.json");
        if (Files.exists(metadataPath) && Files.exists(schemaPath)) {
            metadata = JsonUtil.loadWithRE(metadataPath, Metadata.class);
            segmentSchema = JsonUtil.loadWithRE(schemaPath, SegmentSchema.class);

            if (schema != null) {
                Preconditions.checkState(segmentSchema.equals(schema), "Provided segment schema and the current one not match!");
            }
        } else {
            Preconditions.checkArgument(schema != null, "Segment schema should be provided while not exists yet!");
            Preconditions.checkArgument(Version.fromId(version) != null, "Illegal version!");

            mode = mode == null ? SegmentMode.DEFAULT : mode;
            metadata = new Metadata(version, mode.name(), 0);
            segmentSchema = schema;

            saveInfo(path, metadata, segmentSchema);
        }

        return new DPSegment(metadata, path, name, segmentSchema);
    }
Open a DPSegment.

The newly open segment cannot be updated.
You can use {@link #update()} to enable update.

@param version The segment version, check {@link Version}.
@param mode    The segment mode.
@param path    The path of segment.
@param name    The unique segment identifier in the whole system.
@param schema  The schema of segment.
@param options The open options.
@return A segment resides on the path.
indexr-segment/src/main/java/io/indexr/segment/storage/DPSegment.java