Skip to content

Commit

Permalink
[SPARK-21671][CORE] Move kvstore to "util" sub-package, add private a…
Browse files Browse the repository at this point in the history
…nnotation.

Author: Marcelo Vanzin <vanzin@cloudera.com>

Closes #18886 from vanzin/SPARK-21671.
  • Loading branch information
Marcelo Vanzin committed Aug 8, 2017
1 parent 979bf94 commit 2c1bfb4
Show file tree
Hide file tree
Showing 22 changed files with 46 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

package org.apache.spark.kvstore;
package org.apache.spark.util.kvstore;

import java.util.Arrays;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

package org.apache.spark.kvstore;
package org.apache.spark.util.kvstore;

import java.util.ArrayList;
import java.util.Collection;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@
* limitations under the License.
*/

package org.apache.spark.kvstore;
package org.apache.spark.util.kvstore;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

import org.apache.spark.annotation.Private;

/**
* Tags a field to be indexed when storing an object.
*
Expand All @@ -46,6 +48,7 @@
* of those values.
* </p>
*/
@Private
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.FIELD, ElementType.METHOD})
public @interface KVIndex {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@
* limitations under the License.
*/

package org.apache.spark.kvstore;
package org.apache.spark.util.kvstore;

import java.io.Closeable;

import org.apache.spark.annotation.Private;

/**
* Abstraction for a local key/value store for storing app data.
*
Expand Down Expand Up @@ -59,6 +61,7 @@
* KVStore instances are thread-safe for both reads and writes.
* </p>
*/
@Private
public interface KVStore extends Closeable {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@
* limitations under the License.
*/

package org.apache.spark.kvstore;
package org.apache.spark.util.kvstore;

import java.util.Iterator;
import java.util.List;

import org.apache.spark.annotation.Private;

/**
* An iterator for KVStore.
*
Expand All @@ -28,6 +30,7 @@
* explicitly close iterators after they're used.
* </p>
*/
@Private
public interface KVStoreIterator<T> extends Iterator<T>, AutoCloseable {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

package org.apache.spark.kvstore;
package org.apache.spark.util.kvstore;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
Expand All @@ -25,6 +25,8 @@

import com.fasterxml.jackson.databind.ObjectMapper;

import org.apache.spark.annotation.Private;

/**
* Serializer used to translate between app-defined types and the LevelDB store.
*
Expand All @@ -33,6 +35,7 @@
* and integers to be written as values directly, which will be written as UTF-8 strings.
* </p>
*/
@Private
public class KVStoreSerializer {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@
* limitations under the License.
*/

package org.apache.spark.kvstore;
package org.apache.spark.util.kvstore;

import com.google.common.base.Preconditions;

import org.apache.spark.annotation.Private;

/**
* A configurable view that allows iterating over values in a {@link KVStore}.
*
Expand All @@ -33,6 +35,7 @@
* to be closed explicitly unless all elements are read.
* </p>
*/
@Private
public abstract class KVStoreView<T> implements Iterable<T> {

final Class<T> type;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

package org.apache.spark.kvstore;
package org.apache.spark.util.kvstore;

import java.lang.reflect.Field;
import java.lang.reflect.Method;
Expand All @@ -25,9 +25,12 @@

import com.google.common.base.Preconditions;

import org.apache.spark.annotation.Private;

/**
* Wrapper around types managed in a KVStore, providing easy access to their indexed fields.
*/
@Private
public class KVTypeInfo {

private final Class<?> type;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

package org.apache.spark.kvstore;
package org.apache.spark.util.kvstore;

import java.io.File;
import java.io.IOException;
Expand All @@ -36,9 +36,12 @@
import org.iq80.leveldb.Options;
import org.iq80.leveldb.WriteBatch;

import org.apache.spark.annotation.Private;

/**
* Implementation of KVStore that uses LevelDB as the underlying data store.
*/
@Private
public class LevelDB implements KVStore {

@VisibleForTesting
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

package org.apache.spark.kvstore;
package org.apache.spark.util.kvstore;

import java.io.IOException;
import java.util.ArrayList;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

package org.apache.spark.kvstore;
package org.apache.spark.util.kvstore;

import java.lang.reflect.Array;
import java.util.Collection;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,16 @@
* limitations under the License.
*/

package org.apache.spark.kvstore;
package org.apache.spark.util.kvstore;

import java.io.IOException;

import org.apache.spark.annotation.Private;

/**
* Exception thrown when the store implementation is not compatible with the underlying data.
*/
@Private
public class UnsupportedStoreVersionException extends IOException {

}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

package org.apache.spark.kvstore;
package org.apache.spark.util.kvstore;

import java.util.Arrays;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

package org.apache.spark.kvstore;
package org.apache.spark.util.kvstore;

import org.junit.Test;
import static org.junit.Assert.*;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

package org.apache.spark.kvstore;
package org.apache.spark.util.kvstore;

import com.google.common.base.Objects;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

package org.apache.spark.kvstore;
package org.apache.spark.util.kvstore;

import java.util.Arrays;
import java.util.ArrayList;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

package org.apache.spark.kvstore;
package org.apache.spark.util.kvstore;

public class InMemoryIteratorSuite extends DBIteratorSuite {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

package org.apache.spark.kvstore;
package org.apache.spark.util.kvstore;

import java.util.NoSuchElementException;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

package org.apache.spark.kvstore;
package org.apache.spark.util.kvstore;

import java.io.File;
import java.util.ArrayList;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

package org.apache.spark.kvstore;
package org.apache.spark.util.kvstore;

import java.io.File;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

package org.apache.spark.kvstore;
package org.apache.spark.util.kvstore;

import java.io.File;
import java.util.Arrays;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

package org.apache.spark.kvstore;
package org.apache.spark.util.kvstore;

import static java.nio.charset.StandardCharsets.UTF_8;

Expand Down

0 comments on commit 2c1bfb4

Please sign in to comment.