Giter Club home page Giter Club logo

simpleope's Introduction

SOPE: Simple Order-Preserving Encoding

This code creates a Simple Order-Preserving Encoding. Written in C++, the code includes basic examples to illustrate how it can be used.

The code encodes a tuple or record of fields with various types into an array of bytes so that byte comparison on the encoded records returns the same results as comparing fields based on types. This can be used in many scenarios to avoid custom functions for comparison. It speeds up performance significantly. It works for both big endian and little endian machines.

Encoding/decoding code

src/sope_encode.h: Provides encoding and decoding functions for types: int, long, double, string, binary. Date and Timestamp are supported as long and unsigned long as examples illustrated in the encoded record example.

Examples

  1. examples/sope_simple_test.cc: illustrates a simple encoding use example.

  2. encoded record example: illustrates a little more sophisticated record encoding example

  • examples/sope_types.h: defines types used in defining schema for records.
  • examples/sope_encoded_record.h: supports encoding and decoding for records of fields.
  • examples/sope_record_test.cc: illustrates a record encoding example, including ascending or descending order, and support for null values. Records or rows in a table are strongly typed by a schema. Every field is nullable. The main function is just to display the rows before and after sorting. (note that pretty formatting is not the goal.) Search can be done by providing start condition record (low key) and end condition record (high key), which is not included in the example. The record construction provides facility for it and since we use [low, high) convention in constructing the condition records, null encoding is different for record fields and conditions.

Notes

  • The example code is minimalistic, and for illustration purposes only.
  • Further optimization can be done to reduce the encoded result size.

License

Copyright 2018 eBay Inc. Architect/Developer(s): Gene Zhang, Jung-Sang Ahn, Kun Ren

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

3rd Party Code License

This code base includes some third-party code, as detailed below:

URL: https://github.com/couchbase/forestdb
License: https://github.com/couchbase/forestdb/blob/master/LICENSE
Originally licensed under the Apache 2.0 license.

simpleope's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.