This repository has been archived by the owner on Oct 30, 2020. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merged from javasoze/master and fix the facethandler fail to load error.
- Loading branch information
Showing
29 changed files
with
1,058 additions
and
235 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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
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
34 changes: 34 additions & 0 deletions
34
sensei-gateways/src/main/java/com/senseidb/gateway/kafka/AvroDataSourceFilter.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,34 @@ | ||
package com.senseidb.gateway.kafka; | ||
|
||
import org.apache.avro.io.BinaryDecoder; | ||
import org.apache.avro.io.DecoderFactory; | ||
import org.apache.avro.specific.SpecificDatumReader; | ||
import org.json.JSONObject; | ||
|
||
import com.senseidb.indexing.DataSourceFilter; | ||
|
||
public class AvroDataSourceFilter<D> extends DataSourceFilter<DataPacket> { | ||
|
||
private final Class<D> _cls; | ||
private BinaryDecoder binDecoder; | ||
private final SpecificDatumReader<D> reader; | ||
private final DataSourceFilter<D> _dataMapper; | ||
|
||
public AvroDataSourceFilter(Class<D> cls,DataSourceFilter<D> dataMapper){ | ||
_cls = cls; | ||
binDecoder = null; | ||
reader = new SpecificDatumReader<D>(_cls); | ||
_dataMapper = dataMapper; | ||
if (_dataMapper == null){ | ||
throw new IllegalArgumentException("source filter is null"); | ||
} | ||
} | ||
|
||
@Override | ||
protected JSONObject doFilter(DataPacket packet) throws Exception { | ||
binDecoder = DecoderFactory.defaultFactory().createBinaryDecoder(packet.data,packet.offset,packet.size, binDecoder); | ||
D avroObj = _cls.newInstance(); | ||
reader.read(avroObj,binDecoder); | ||
return _dataMapper.filter(avroObj); | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
sensei-gateways/src/main/java/com/senseidb/gateway/kafka/DataPacket.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,14 @@ | ||
package com.senseidb.gateway.kafka; | ||
|
||
public final class DataPacket { | ||
|
||
public final byte[] data; | ||
public final int offset; | ||
public final int size; | ||
|
||
public DataPacket(byte[] data,int offset,int size){ | ||
this.data = data; | ||
this.offset = offset; | ||
this.size = size; | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
sensei-gateways/src/main/java/com/senseidb/gateway/kafka/DefaultJsonDataSourceFilter.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,17 @@ | ||
package com.senseidb.gateway.kafka; | ||
|
||
import java.nio.charset.Charset; | ||
|
||
import org.json.JSONObject; | ||
|
||
import com.senseidb.indexing.DataSourceFilter; | ||
|
||
public class DefaultJsonDataSourceFilter extends DataSourceFilter<DataPacket> { | ||
public final static Charset UTF8 = Charset.forName("UTF-8"); | ||
|
||
@Override | ||
protected JSONObject doFilter(DataPacket packet) throws Exception { | ||
String jsonString = new String(packet.data,packet.offset,packet.size,UTF8); | ||
return new JSONObject(jsonString); | ||
} | ||
} |
37 changes: 0 additions & 37 deletions
37
sensei-gateways/src/main/java/com/senseidb/gateway/kafka/KafkaAvroStreamDataProvider.java
This file was deleted.
Oops, something went wrong.
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.