-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change NULL array, struct to Empty array, struct
- Loading branch information
Showing
24 changed files
with
772 additions
and
170 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
src/main/java/jp/co/yahoo/yosegi/spark/inmemory/loader/SparkEmptyArrayLoader.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/** | ||
* Licensed to the Apache Software Foundation (ASF) under one or more contributor license | ||
* agreements. See the NOTICE file distributed with this work for additional information regarding | ||
* copyright ownership. The ASF licenses this file to you 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 | ||
* | ||
* <p>http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* <p>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. | ||
*/ | ||
package jp.co.yahoo.yosegi.spark.inmemory.loader; | ||
|
||
import jp.co.yahoo.yosegi.inmemory.ILoader; | ||
import jp.co.yahoo.yosegi.inmemory.LoadType; | ||
import org.apache.spark.sql.execution.vectorized.WritableColumnVector; | ||
|
||
import java.io.IOException; | ||
|
||
public class SparkEmptyArrayLoader implements ILoader<WritableColumnVector> { | ||
|
||
private final WritableColumnVector vector; | ||
private final int loadSize; | ||
|
||
public SparkEmptyArrayLoader(final WritableColumnVector vector, final int loadSize) { | ||
this.vector = vector; | ||
this.loadSize = loadSize; | ||
this.vector.getChild(0).reset(); | ||
this.vector.getChild(0).reserve(0); | ||
if (this.vector.getChild(0).hasDictionary()) { | ||
this.vector.getChild(0).reserveDictionaryIds(0); | ||
this.vector.getChild(0).setDictionary(null); | ||
} | ||
} | ||
|
||
@Override | ||
public LoadType getLoaderType() { | ||
return LoadType.NULL; | ||
} | ||
|
||
@Override | ||
public int getLoadSize() { | ||
return loadSize; | ||
} | ||
|
||
@Override | ||
public void setNull(final int index) throws IOException { | ||
// FIXME: | ||
} | ||
|
||
@Override | ||
public void finish() throws IOException { | ||
// FIXME: | ||
} | ||
|
||
@Override | ||
public WritableColumnVector build() throws IOException { | ||
for (int i = 0; i < loadSize; i++) { | ||
vector.putArray(i, 0, 0); | ||
} | ||
return vector; | ||
} | ||
|
||
@Override | ||
public boolean isLoadingSkipped() { | ||
return true; | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
src/main/java/jp/co/yahoo/yosegi/spark/inmemory/loader/SparkEmptyLoader.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package jp.co.yahoo.yosegi.spark.inmemory.loader; | ||
|
||
import org.apache.spark.sql.execution.vectorized.WritableColumnVector; | ||
import org.apache.spark.sql.types.ArrayType; | ||
import org.apache.spark.sql.types.MapType; | ||
import org.apache.spark.sql.types.StructType; | ||
|
||
import java.io.IOException; | ||
|
||
public class SparkEmptyLoader { | ||
public static void load(final WritableColumnVector vector, final int loadSize) throws IOException { | ||
final Class klass = vector.dataType().getClass(); | ||
if (klass == ArrayType.class) { | ||
new SparkEmptyArrayLoader(vector, loadSize).build(); | ||
} else if (klass == StructType.class) { | ||
new SparkEmptyStructLoader(vector, loadSize).build(); | ||
} else if (klass == MapType.class) { | ||
new SparkEmptyMapLoader(vector, loadSize).build(); | ||
} else { | ||
new SparkNullLoader(vector, loadSize).build(); | ||
} | ||
} | ||
} |
66 changes: 66 additions & 0 deletions
66
src/main/java/jp/co/yahoo/yosegi/spark/inmemory/loader/SparkEmptyMapLoader.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/** | ||
* Licensed to the Apache Software Foundation (ASF) under one or more contributor license | ||
* agreements. See the NOTICE file distributed with this work for additional information regarding | ||
* copyright ownership. The ASF licenses this file to you 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 | ||
* | ||
* <p>http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* <p>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. | ||
*/ | ||
package jp.co.yahoo.yosegi.spark.inmemory.loader; | ||
|
||
import jp.co.yahoo.yosegi.inmemory.ILoader; | ||
import jp.co.yahoo.yosegi.inmemory.LoadType; | ||
import org.apache.spark.sql.execution.vectorized.WritableColumnVector; | ||
|
||
import java.io.IOException; | ||
|
||
public class SparkEmptyMapLoader implements ILoader<WritableColumnVector> { | ||
|
||
private final WritableColumnVector vector; | ||
private final int loadSize; | ||
|
||
public SparkEmptyMapLoader(final WritableColumnVector vector, final int loadSize) { | ||
this.vector = vector; | ||
this.loadSize = loadSize; | ||
} | ||
|
||
@Override | ||
public LoadType getLoaderType() { | ||
return LoadType.NULL; | ||
} | ||
|
||
@Override | ||
public int getLoadSize() { | ||
return loadSize; | ||
} | ||
|
||
@Override | ||
public void setNull(final int index) throws IOException { | ||
// FIXME: | ||
} | ||
|
||
@Override | ||
public void finish() throws IOException { | ||
// FIXME: | ||
} | ||
|
||
@Override | ||
public WritableColumnVector build() throws IOException { | ||
vector.getChild(0).reset(); | ||
vector.getChild(0).reserve(0); | ||
vector.getChild(1).reset(); | ||
vector.getChild(1).reserve(0); | ||
return vector; | ||
} | ||
|
||
@Override | ||
public boolean isLoadingSkipped() { | ||
return true; | ||
} | ||
} |
80 changes: 80 additions & 0 deletions
80
src/main/java/jp/co/yahoo/yosegi/spark/inmemory/loader/SparkEmptyStructLoader.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
/** | ||
* Licensed to the Apache Software Foundation (ASF) under one or more contributor license | ||
* agreements. See the NOTICE file distributed with this work for additional information regarding | ||
* copyright ownership. The ASF licenses this file to you 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 | ||
* | ||
* <p>http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* <p>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. | ||
*/ | ||
package jp.co.yahoo.yosegi.spark.inmemory.loader; | ||
|
||
import jp.co.yahoo.yosegi.inmemory.ILoader; | ||
import jp.co.yahoo.yosegi.inmemory.LoadType; | ||
import org.apache.spark.sql.execution.vectorized.WritableColumnVector; | ||
import org.apache.spark.sql.types.ArrayType; | ||
import org.apache.spark.sql.types.DataType; | ||
import org.apache.spark.sql.types.MapType; | ||
import org.apache.spark.sql.types.StructType; | ||
|
||
import java.io.IOException; | ||
|
||
public class SparkEmptyStructLoader implements ILoader<WritableColumnVector> { | ||
|
||
private final WritableColumnVector vector; | ||
private final int loadSize; | ||
private final String[] names; | ||
|
||
public SparkEmptyStructLoader(final WritableColumnVector vector, final int loadSize) { | ||
this.vector = vector; | ||
this.loadSize = loadSize; | ||
final StructType structType = (StructType) vector.dataType(); | ||
this.names = structType.fieldNames(); | ||
for (int i = 0; i < names.length; i++) { | ||
vector.getChild(i).reset(); | ||
vector.getChild(i).reserve(loadSize); | ||
if (vector.getChild(i).hasDictionary()) { | ||
vector.getChild(i).reserveDictionaryIds(0); | ||
vector.getChild(i).setDictionary(null); | ||
} | ||
} | ||
} | ||
|
||
@Override | ||
public LoadType getLoaderType() { | ||
return LoadType.NULL; | ||
} | ||
|
||
@Override | ||
public int getLoadSize() { | ||
return loadSize; | ||
} | ||
|
||
@Override | ||
public void setNull(final int index) throws IOException { | ||
// FIXME: | ||
} | ||
|
||
@Override | ||
public void finish() throws IOException { | ||
// FIXME: | ||
} | ||
|
||
@Override | ||
public WritableColumnVector build() throws IOException { | ||
for (int i = 0; i < names.length; i++) { | ||
SparkEmptyLoader.load(vector.getChild(i), loadSize); | ||
} | ||
return vector; | ||
} | ||
|
||
@Override | ||
public boolean isLoadingSkipped() { | ||
return true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.