bluge_directory_elf

package module
v0.0.0-...-ad131b9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 6, 2020 License: Apache-2.0 Imports: 10 Imported by: 0

README

bluge_directory_elf

An implementation of the Bluge Directory interface which can operate on index data which has been stored inside additional sections of an elf executable.

This can be useful to create an executable with search code, that can access index data attached to the executable itself.

Usage

To begin, you need an existing Bluge index. While not required, it is recommended that one builds an index with the Bluge Offline Index Writer. This creates an index with single segment, which is optimized for this use case.

Next, create an application which has some search logic. This could be a command-line program which takes search queries from the command-line arguemnts, or it could be a serverless executable desgined to service HTTP requests. This program should use the provided Directory implementation to access the index in a read-only manner:

	cfg := bluge.DefaultConfigWithDirectory(func() index.Directory {
		return bluge_directory_elf.NewElfDirectory(os.Args[0], "index")
	})

	reader, err := bluge.OpenReader(cfg)
	if err != nil {
		log.Fatalf("error opening index reader: %v", err)
	}

In this example we see that the application creates a Bluge configuration using this module's Elf Directory implementation, and it passes itself (os.Args[0]) as the elf-executable. The second argument here is a hard-coded index named index. This allows you to store and reference multiple indexes in the executable. Finally, one opens a reader using this configuration. From this point it behaves like any other index reader.

Next one compiles this application.

The last step is to combine these two pieces. We want to take the index we built, and add it to the elf-executable we just compiled. This can be done with the provided application.

NOTE: this requires the host machine have the objcopy application installed.

The provided bluge_add_to_elf command takes 3 arguments:

  • path to elf-executable to modify
  • name of the index (to allow for multiple indexes in the executable)
  • path to the exiting bluge index

For example:

$ bluge_add_to_elf compiled-application index path-to-index

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SectionPrefixForIndex

func SectionPrefixForIndex(name string) string

Types

type ElfDirectory

type ElfDirectory struct {
	// contains filtered or unexported fields
}

func NewElfDirectory

func NewElfDirectory(elfPath, dirName string) *ElfDirectory

func (*ElfDirectory) List

func (e *ElfDirectory) List(kind string) ([]uint64, error)

func (*ElfDirectory) Load

func (e *ElfDirectory) Load(kind string, id uint64) (*segment.Data, io.Closer, error)

func (*ElfDirectory) Lock

func (e *ElfDirectory) Lock() error

func (*ElfDirectory) Persist

func (e *ElfDirectory) Persist(kind string, id uint64, w index.WriterTo, closeCh chan struct{}) error

func (*ElfDirectory) Remove

func (e *ElfDirectory) Remove(kind string, id uint64) error

func (*ElfDirectory) Setup

func (e *ElfDirectory) Setup(readOnly bool) (err error)

func (*ElfDirectory) Stats

func (e *ElfDirectory) Stats() (numItems uint64, numBytes uint64)

func (*ElfDirectory) Sync

func (e *ElfDirectory) Sync() error

func (*ElfDirectory) Unlock

func (e *ElfDirectory) Unlock() error

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL