示例#1
0
        public static Index CreateInDir(string path, BuiltSchema schema, bool copy = false)
        {
            if (schema == null)
            {
                throw new ArgumentNullException(nameof(schema));
            }
            unsafe
            {
                return(MarshalHelper.Utf8Call(path, (buffer, len) =>
                {
                    {
                        Index index;
                        TantivyError e;

                        if (copy)
                        {
                            index = CreateInDirCopyImpl(buffer, len, schema, out e);
                        }
                        else
                        {
                            index = CreateInDirMoveImpl(buffer, len, schema, out e);
                            schema.SetHandleAsInvalid();
                        }

                        if (index.IsInvalid)
                        {
                            throw new TantivyException(e);
                        }
                        return index;
                    }
                }));
            }
        }
示例#2
0
        public static Index CreateInRam(BuiltSchema schema, bool copy = false)
        {
            if (schema == null)
            {
                throw new ArgumentNullException(nameof(schema));
            }

            Index index;

            if (copy)
            {
                index = CreateInRamCopyImpl(schema);
            }
            else
            {
                index = CreateInRamMoveImpl(schema);
                schema.SetHandleAsInvalid();
            }
            return(index);
        }
示例#3
0
        public static Index CreateFromTempDir(BuiltSchema schema, bool copy = false)
        {
            Index        index;
            TantivyError e;

            if (copy)
            {
                index = CreateFromTempDirCopyImpl(schema, out e);
            }
            else
            {
                index = CreateFromTempDirMoveImpl(schema, out e);
                schema.SetHandleAsInvalid();
            }

            if (index.IsInvalid)
            {
                throw new TantivyException(e);
            }
            return(index);
        }
示例#4
0
 private static unsafe extern Index CreateInDirMoveImpl(byte *path, UIntPtr pathLength, BuiltSchema schema, out TantivyError error);
示例#5
0
 private static extern Index CreateFromTempDirMoveImpl(BuiltSchema schema, out TantivyError error);
示例#6
0
 private static extern Index CreateInRamMoveImpl(BuiltSchema schema);