Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 62 additions & 0 deletions NOTICE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,65 @@ ADDITIONAL THIRD PARTY NOTICES:
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/

------------------------------------------------------------------------
Apache Cassandra
------------------------------------------------------------------------
Apache Cassandra
Copyright 2022 The Apache Software Foundation

cassandra-hadoop-util/src/main/java/org/apache/cassandra/db/SystemKeyspace.java
from
https://github.com/apache/cassandra/blob/cassandra-4.0.6/src/java/org/apache/cassandra/db/SystemKeyspace.java

cassandra-hadoop-util/src/main/java/org/apache/cassandra/hadoop/cql3/CqlClientHelper.java
from
https://github.com/apache/cassandra/blob/cassandra-4.0.6/src/java/org/apache/cassandra/hadoop/cql3/CqlClientHelper.java

cassandra-hadoop-util/src/main/java/org/apache/cassandra/hadoop/cql3/CqlConfigHelper.java
from
https://github.com/apache/cassandra/blob/cassandra-4.0.6/src/java/org/apache/cassandra/hadoop/cql3/CqlConfigHelper.java

cassandra-hadoop-util/src/main/java/org/apache/cassandra/hadoop/cql3/CqlInputFormat.java
from
https://github.com/apache/cassandra/blob/cassandra-4.0.6/src/java/org/apache/cassandra/hadoop/cql3/CqlInputFormat.java

cassandra-hadoop-util/src/main/java/org/apache/cassandra/hadoop/cql3/CqlRecordReader.java
from
https://github.com/apache/cassandra/blob/cassandra-4.0.6/src/java/org/apache/cassandra/hadoop/cql3/CqlRecordReader.java

cassandra-hadoop-util/src/main/java/org/apache/cassandra/hadoop/cql3/LimitedLocalNodeFirstLocalBalancingPolicy.java
from
https://github.com/apache/cassandra/blob/cassandra-4.0.6/src/java/org/apache/cassandra/hadoop/cql3/LimitedLocalNodeFirstLocalBalancingPolicy.java

cassandra-hadoop-util/src/main/java/org/apache/cassandra/hadoop/ColumnFamilySplit.java
from
https://github.com/apache/cassandra/blob/cassandra-4.0.6/src/java/org/apache/cassandra/hadoop/ColumnFamilySplit.java

cassandra-hadoop-util/src/main/java/org/apache/cassandra/hadoop/ConfigHelper.java
from
https://github.com/apache/cassandra/blob/cassandra-4.0.6/src/java/org/apache/cassandra/hadoop/ConfigHelper.java

cassandra-hadoop-util/src/main/java/org/apache/cassandra/hadoop/HadoopCompat.java
from
https://github.com/apache/cassandra/blob/cassandra-4.0.6/src/java/org/apache/cassandra/hadoop/HadoopCompat.java

cassandra-hadoop-util/src/main/java/org/apache/cassandra/hadoop/ReporterWrapper.java
from
https://github.com/apache/cassandra/blob/cassandra-4.0.6/src/java/org/apache/cassandra/hadoop/ReporterWrapper.java

cassandra-hadoop-util/src/main/java/org/apache/cassandra/schema/SchemaConstants.java
from
https://github.com/apache/cassandra/blob/cassandra-4.0.6/src/java/org/apache/cassandra/schema/SchemaConstants.java

cassandra-hadoop-util/src/main/java/org/apache/cassandra/utils/AbstractIterator.java
from
https://github.com/apache/cassandra/blob/cassandra-4.0.6/src/java/org/apache/cassandra/utils/AbstractIterator.java

cassandra-hadoop-util/src/main/java/org/apache/cassandra/utils/BiMultiValMap.java
from
https://github.com/apache/cassandra/blob/cassandra-4.0.6/src/java/org/apache/cassandra/utils/BiMultiValMap.java

cassandra-hadoop-util/src/main/java/org/apache/cassandra/utils/Pair.java
from
https://github.com/apache/cassandra/blob/cassandra-4.0.6/src/java/org/apache/cassandra/utils/Pair.java
49 changes: 49 additions & 0 deletions cassandra-hadoop-util/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.janusgraph</groupId>
<artifactId>janusgraph</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>

<artifactId>cassandra-hadoop-util</artifactId>
<name>Cassandra hadoop util extraction</name>
<url>https://janusgraph.org</url>


<properties>
<top.level.basedir>${basedir}/..</top.level.basedir>
</properties>

<dependencies>
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-client</artifactId>
</dependency>

<dependency>
<groupId>com.datastax.cassandra</groupId>
<artifactId>cassandra-driver-core</artifactId>
<version>3.11.2</version>
<exclusions>
<exclusion>
<groupId>com.github.jnr</groupId>
<artifactId>jnr-ffi</artifactId>
</exclusion>
<exclusion>
<groupId>com.github.jnr</groupId>
<artifactId>jnr-posix</artifactId>
</exclusion>
<exclusion>
<groupId>io.dropwizard.metrics</groupId>
<artifactId>metrics-core</artifactId>
</exclusion>
<exclusion>
<groupId>io.netty</groupId>
<artifactId>netty-handler</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* 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
*
* http://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.
*/
package org.apache.cassandra.db;

public final class SystemKeyspace
{
public static final String TABLE_ESTIMATES = "table_estimates";
public static final String TABLE_ESTIMATES_TYPE_LOCAL_PRIMARY = "local_primary";
@Deprecated public static final String LEGACY_SIZE_ESTIMATES = "size_estimates";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
/*
* 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
*
* http://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.
*/
package org.apache.cassandra.hadoop;

import org.apache.hadoop.io.Writable;
import org.apache.hadoop.mapreduce.InputSplit;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.EOFException;
import java.io.IOException;
import java.util.Arrays;

public class ColumnFamilySplit extends InputSplit implements Writable, org.apache.hadoop.mapred.InputSplit
{
private String startToken;
private String endToken;
private long length;
private String[] dataNodes;

@Deprecated
public ColumnFamilySplit(String startToken, String endToken, String[] dataNodes)
{
this(startToken, endToken, Long.MAX_VALUE, dataNodes);
}

public ColumnFamilySplit(String startToken, String endToken, long length, String[] dataNodes)
{
assert startToken != null;
assert endToken != null;
this.startToken = startToken;
this.endToken = endToken;
this.length = length;
this.dataNodes = dataNodes;
}

public String getStartToken()
{
return startToken;
}

public String getEndToken()
{
return endToken;
}

// getLength and getLocations satisfy the InputSplit abstraction

public long getLength()
{
return length;
}

public String[] getLocations()
{
return dataNodes;
}

// This should only be used by KeyspaceSplit.read();
protected ColumnFamilySplit() {}

// These three methods are for serializing and deserializing
// KeyspaceSplits as needed by the Writable interface.
public void write(DataOutput out) throws IOException
{
out.writeUTF(startToken);
out.writeUTF(endToken);
out.writeInt(dataNodes.length);
for (String endpoint : dataNodes)
{
out.writeUTF(endpoint);
}
out.writeLong(length);
}

public void readFields(DataInput in) throws IOException
{
startToken = in.readUTF();
endToken = in.readUTF();
int numOfEndpoints = in.readInt();
dataNodes = new String[numOfEndpoints];
for(int i = 0; i < numOfEndpoints; i++)
{
dataNodes[i] = in.readUTF();
}
try
{
length = in.readLong();
}
catch (EOFException e)
{
//We must be deserializing in a mixed-version cluster.
}
}

@Override
public String toString()
{
return "ColumnFamilySplit(" +
"(" + startToken
+ ", '" + endToken + ']'
+ " @" + (dataNodes == null ? null : Arrays.asList(dataNodes)) + ')';
}

public static ColumnFamilySplit read(DataInput in) throws IOException
{
ColumnFamilySplit w = new ColumnFamilySplit();
w.readFields(in);
return w;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
/*
*
* 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
*
* http://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.
*
*/
package org.apache.cassandra.hadoop;

import org.apache.cassandra.utils.Pair;
import org.apache.hadoop.conf.Configuration;

public class ConfigHelper
{
private static final String INPUT_PARTITIONER_CONFIG = "cassandra.input.partitioner.class";
private static final String INPUT_KEYSPACE_CONFIG = "cassandra.input.keyspace";
private static final String INPUT_COLUMNFAMILY_CONFIG = "cassandra.input.columnfamily";
private static final String INPUT_KEYRANGE_CONFIG = "cassandra.input.keyRange";
private static final String INPUT_SPLIT_SIZE_CONFIG = "cassandra.input.split.size";
private static final String INPUT_SPLIT_SIZE_IN_MB_CONFIG = "cassandra.input.split.size_mb";
private static final String INPUT_WIDEROWS_CONFIG = "cassandra.input.widerows";
private static final int DEFAULT_SPLIT_SIZE = 64 * 1024;
private static final String INPUT_INITIAL_ADDRESS = "cassandra.input.address";
private static final String READ_CONSISTENCY_LEVEL = "cassandra.consistencylevel.read";

/**
* Set the keyspace and column family for the input of this job.
*
* @param conf Job configuration you are about to run
* @param keyspace
* @param columnFamily
* @param widerows
*/
public static void setInputColumnFamily(Configuration conf, String keyspace, String columnFamily, boolean widerows)
{
if (keyspace == null)
throw new UnsupportedOperationException("keyspace may not be null");

if (columnFamily == null)
throw new UnsupportedOperationException("table may not be null");

conf.set(INPUT_KEYSPACE_CONFIG, keyspace);
conf.set(INPUT_COLUMNFAMILY_CONFIG, columnFamily);
conf.set(INPUT_WIDEROWS_CONFIG, String.valueOf(widerows));
}

public static int getInputSplitSize(Configuration conf)
{
return conf.getInt(INPUT_SPLIT_SIZE_CONFIG, DEFAULT_SPLIT_SIZE);
}


/**
* cassandra.input.split.size will be used if the value is undefined or negative.
* @param conf Job configuration you are about to run
* @return split size in MB or -1 if it is undefined.
*/
public static int getInputSplitSizeInMb(Configuration conf)
{
return conf.getInt(INPUT_SPLIT_SIZE_IN_MB_CONFIG, -1);
}


/**
* The start and end token of the input key range as a pair.
*
* may be null if unset.
*/
public static Pair<String, String> getInputKeyRange(Configuration conf)
{
String str = conf.get(INPUT_KEYRANGE_CONFIG);
if (str == null)
return null;

String[] parts = str.split(",");
assert parts.length == 2;
return Pair.create(parts[0], parts[1]);
}

public static String getInputKeyspace(Configuration conf)
{
return conf.get(INPUT_KEYSPACE_CONFIG);
}

public static String getInputColumnFamily(Configuration conf)
{
return conf.get(INPUT_COLUMNFAMILY_CONFIG);
}


public static String getReadConsistencyLevel(Configuration conf)
{
return conf.get(READ_CONSISTENCY_LEVEL, "LOCAL_ONE");
}

public static String getInputInitialAddress(Configuration conf)
{
return conf.get(INPUT_INITIAL_ADDRESS);
}

public static void setInputInitialAddress(Configuration conf, String address)
{
conf.set(INPUT_INITIAL_ADDRESS, address);
}

public static String getInputPartitioner(Configuration conf)
{
return conf.get(INPUT_PARTITIONER_CONFIG);
}
}
Loading